Created
May 28, 2015 01:25
-
-
Save ericpkatz/123f7d5f76f83f1d43f4 to your computer and use it in GitHub Desktop.
JS Bin 9053-Summer-2015-Lesson1-b // source http://jsbin.com/dediro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="9053-Summer-2015-Lesson1-b"> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
console.clear(); | |
function generateRandom(min, max){ | |
return min + Math.ceil(Math.random() * (max - min)); | |
} | |
var arr = []; | |
function buildArray(count){ | |
while(arr.length < count){ | |
arr.push(generateRandom(50, 100)); | |
} | |
} | |
buildArray(10); | |
console.log(arr); | |
var stats = {}; | |
for(var i = 0; i < arr.length; i++){ | |
var key = arr[i]; | |
if(stats[key] == undefined){ | |
stats[key] = 0; | |
} | |
stats[key]++; | |
} | |
console.log(Object.keys(stats)); | |
for(var key in stats){ | |
console.log(key + " was generated " + stats[key] + " times"); | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">console.clear(); | |
function generateRandom(min, max){ | |
return min + Math.ceil(Math.random() * (max - min)); | |
} | |
var arr = []; | |
function buildArray(count){ | |
while(arr.length < count){ | |
arr.push(generateRandom(50, 100)); | |
} | |
} | |
buildArray(10); | |
console.log(arr); | |
var stats = {}; | |
for(var i = 0; i < arr.length; i++){ | |
var key = arr[i]; | |
if(stats[key] == undefined){ | |
stats[key] = 0; | |
} | |
stats[key]++; | |
} | |
console.log(Object.keys(stats)); | |
for(var key in stats){ | |
console.log(key + " was generated " + stats[key] + " times"); | |
} | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.clear(); | |
function generateRandom(min, max){ | |
return min + Math.ceil(Math.random() * (max - min)); | |
} | |
var arr = []; | |
function buildArray(count){ | |
while(arr.length < count){ | |
arr.push(generateRandom(50, 100)); | |
} | |
} | |
buildArray(10); | |
console.log(arr); | |
var stats = {}; | |
for(var i = 0; i < arr.length; i++){ | |
var key = arr[i]; | |
if(stats[key] == undefined){ | |
stats[key] = 0; | |
} | |
stats[key]++; | |
} | |
console.log(Object.keys(stats)); | |
for(var key in stats){ | |
console.log(key + " was generated " + stats[key] + " times"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment