forked from sf-wdi-14/notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path141119_lab.js
95 lines (69 loc) · 1.51 KB
/
141119_lab.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//sillySum(arr)
//Write a function that takes an array of numbers,
//and returns the sum of each number multiplied by its index.
// var prodIndex = 0;
// var sumProdIndex = 0;
// var inputArray = [3,4,5];
// var l = inputArray.length;
// var plusProdIndex = function(x) {
// for (i=0;i<l;i++) {
// prodIndex = (inputArray[i]*i);;
// sumProdIndex += prodIndex;}
// return sumProdIndex;
// };
// plusProdIndex(inputArray);
// numSquare(max)
// Create a function called numSquare that
// will return an array of all perfect square numbers up to, but not exceeding a max number.
// var perSq = [];
// var numSquare = function(max) {
// for (i=0;i<=max;i++) {
// if (i%Math.sqrt(i)===0) {
// perSq.push(i);
// }
// }
// return perSq;
// }
// numSquare(max);
// function isPrime(num) {
// var arTp = [];
// for (var i=2;i<num;i++) {
// if (num%i===0) {
// arTp.push(i);
// }
// }
// if (arTp==0) {
// return true;
// }
// else {
// return false;
// }
// }
// primes(max)
// Using your isPrime() function, create
// a function primes that will return an array of
// all prime numbers up to a certain amount.
//primes(max)
// function isPrime(num) {
// var arTp = [];
// for (var i=2;i<num;i++) {
// if (num%i===0) {
// arTp.push(i);
// }
// }
// if (arTp==0) {
// return true;
// }
// else {
// return false;
// }
// }
// function primes(max) {
// primA = []
// for (var x=2; x<max; x++) {
// if (isPrime(x)===true) {
// primA.push(x);
// }
// }
// return primA
// }