Skip to content

Instantly share code, notes, and snippets.

@LuisMDeveloper
Created April 25, 2014 22:05
Show Gist options
  • Save LuisMDeveloper/11304849 to your computer and use it in GitHub Desktop.
Save LuisMDeveloper/11304849 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://jashkenas.github.io/underscore/underscore-min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
// without underscore.js
var scores = [84, 99, 91, 65, 87, 55, 72, 68, 95, 42],
topScorers = [], scoreLimit = 90;
for (i=0; i<=scores.length; i++)
{
if (scores[i]>scoreLimit)
{
topScorers.push(scores[i]);
}
}
console.log(topScorers);
scores = [84, 99, 91, 65, 87, 55, 72, 68, 95, 42];
topScorers = [];
scoreLimit = 90;
//topScorers = _.select(scores, function (score) { return score >= scoreLimit; });
topScorers = _(scores).select(function (score) { return score >= scoreLimit; });
console.log(topScorers);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment