Subject: Quickly Search Information on Govt Grants

From: Grant Options <[email-masked]>
Date: Mon, 15 Dec 2014 10:13:13 -0800

From: Reporting. 7fdd3942-123d-4c21-98ec-f8c783fbfb3f - 687144731

26f41ca1de2bce47cf65c6925d2e22c3

Attn: [email-masked]

Your Federal Grant Options have been Updated and are now Available.

- Utility Bill Assisstance - Rent Assisstance - Medical Bills -

Your Options as of December 14, 2014 [viewable-here]

26f41ca1de2bce47cf65c6925d2e22c3

26f41ca1de2bce47cf65c6925d2e22c3

This is an adv. sent by a 3rd party on behalf of the advertiser. Adnet.com| PO Box 29502 #47|148| LasVegas|NV|89126-9502Unsubscribe

% for c in comments %}

<div class="col-md-3 pull-right">

Wrote:

<span class="grey"> </span>

</div>

<br>

class="col-md-1">

<i class="glyphicon glyphicon-heart" id="likecomment" name="

</i>

<class="likecomment"> </i>

</div>

<div class=">

{{c.body

</div>

<br>

<hr>

{% endfor}

Use === instead of == whenever possible ... == checks values only, whereas === checks both value and type, so "2" == 2 is true, whereas "2" === 2 is false
Learn how to leverage the element-level items. There are a lot of places to do this, but doing (this).attr('id') is approximately 600,000 times slower than using this.id with the same result. You definitely can't do this everywhere, but things like this.id and this.checked are super easy, cross-browser, and a lot faster
When I mentioned "cache your instance of (this)", I tried to provide a rudimentary example here (although it didn't really apply). General rule is that if you need to reference the same element / object more than once, you cache it, because you'll see a massive improvement in speed and resource consumption. I did an example of caching this in the .on('click') function, but you can do it with anything.
Personal recommendation, learn to use .on() instead of the shorthand. .click() works well if you only need to bind one event, but what if you bind .mouseenter() and.mouseleave()?

How would I go about creating a recursive function that can search through a list for a node where x = 10?

I do not have any javascript experience so I am not sure where to start so would appreciate and input

I have come across the following code and tried to adapt it but I am not sure if I am on the right track:

function search(_for, _in) {
var r;
for (var p in _in) {
if ( p === 10 ) {
return _in[p];
}
if ( typeof _in[p] === 'object' ) {
if ( (r = search(_for, _in[p])) == null ) {
return r;
}
}
}
return null;
}
Thank you in advance

javascript recursion
share|improve this question
asked 1 hour ago

user3400893
32
add a comment
1 Answer
activeoldestvotes
up vote
1
down vote
accepted
Try this

var finder = function(needle, {
if (haystack.length == 0)
return false

if (haystack[0] == needle)
return true

return finder(pin, haystack.slice(1))
}
Or

var finder = function(pin, haystack) {
return (haystack[0] == pin) || (.length = 0) && finder(pin, haystack.slice(1))
}
Recursion FTW

share|improve this answer
edited 31 mins ago

answered 1 hour ago

Simon H
978616

Thank @Simon but if I may ask how does it know that X should be 10 if there is no 10 in the code? Sorry for asking, I am just trying to understand it as I go along user3400893 1 hour ago

finder(needle, haystack) searches for needle in haysta