Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 83 additions & 13 deletions scripts.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,102 @@
// FILL IN THE FUNCTIONS BELOW

var sprintFunctions = {
largestEl: function(){
// your code here
allNum: function(num){
var n = 1
var arr = []
while(true){
arr.push(n)
if(n >= num){break}
n += 1
}
return arr
},

reversed: function(){
// your code here

primeQuestion: function(number){
divisors = sprintFunctions.allNum(number-1)
divisors.shift()
question = true
divisors.forEach(function(x){
if (number % x == 0) {question = false}
})
return question
},

loudSnakeCase: function(){
largestEl: function(array){
// your code here
return array.sort().pop()
},

compareArrays: function(){
// your code here (replace the return)
return "Finish compareArrays first!"
reversed: function(string){
// your code here
return string.split("").reverse().join("")
},

fizzBuzz: function(){
loudSnakeCase: function(string){
// your code here
var i = 0
while(true){
string = string.replace(/[.!@#$%^&*()<>,.?]/,"")
i += 1
if (i > 100) {break}
}
while(true){
string = string.replace(" ", "_")
i += 1
if (i > 200) {break}
}
string = string.replace("__", "_")
return string.split("_").map(function(str){
return str.charAt(0).toUpperCase() + str.slice(1)
}).join("_");
},

myMap: function(){
compareArrays: function(startarr, diffarr){
// your code here
question = true
var i = startarr.length - 1
while(true){
if (startarr[i] != diffarr[i]) {question = false}
return question
}
//return true
},

primes: function(){
fizzBuzz: function(number){
// your code here
var arr = []
var i = 1
while(true){
if (i % 3 == 0 && i % 5 == 0){arr.push("FIZZBUZZ")}
else if(i % 3 == 0){arr.push("FIZZ")}
else if(i % 5 == 0){arr.push("BUZZ")}
else{arr.push(i)}
i += 1
if(i > number){break}
}
return arr
},

myMap: function(input, func){
arr = []
input.forEach(function(x){
arr.push(func(x))
})
return arr
},

primes: function(thenumber){
array = []
posnum = sprintFunctions.allNum(thenumber)
posnum.shift()
posnum.pop()
//return posnum
posnum.forEach(function(x){
if(sprintFunctions.primeQuestion(x) == true){
array.push(x);
//console.log(array);
}
})
return array
},
}
}
102 changes: 102 additions & 0 deletions test/holding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
var sprintFunctions = {
allNum: function(num){
var n = 1
var arr = []
while(true){
arr.push(n)
if(n >= num){break}
n += 1
}
return arr
},

primeQuestion: function(number){
divisors = sprintFunctions.allNum(number-1)
divisors.shift()
question = true
divisors.forEach(function(x){
if (number % x == 0) {question = false}
})
return question
},

largestEl: function(array){
// your code here
return array.sort().pop()
},

reversed: function(string){
// your code here
return string.split("").reverse().join("")
},

loudSnakeCase: function(string){
// your code here
var i = 0
while(true){
string = string.replace(/[.!@#$%^&*()<>,.?]/,"")
i += 1
if (i > 100) {break}
}
while(true){
string = string.replace(" ", "_")
i += 1
if (i > 200) {break}
}
string = string.replace("__", "_")
return string.split("_").map(function(str){
return str.charAt(0).toUpperCase() + str.slice(1)
}).join("_");
},

compareArrays: function(startarr, diffarr){
// your code here
question = true
var i = startarr.length - 1
while(true){
if (startarr[i] != diffarr[i]) {question = false}
return question
}
//return true
},

fizzBuzz: function(number){
// your code here
var arr = []
var i = 1
while(true){
if (i % 3 == 0 && i % 5 == 0){arr.push("FIZZBUZZ")}
else if(i % 3 == 0){arr.push("FIZZ")}
else if(i % 5 == 0){arr.push("BUZZ")}
else{arr.push(i)}
i += 1
if(i > number){break}
}
return arr
},

myMap: function(input, func){
arr = []
input.forEach(function(x){
arr.push(func(x))
})
return arr
},

primes: function(thenumber){
array = []
posnum = sprintFunctions.allNum(thenumber)
posnum.shift()
posnum.pop()
//return posnum
posnum.forEach(function(x){
if(sprintFunctions.primeQuestion(x) == true){
array.push(x);
//console.log(array);
}
})
return array
},
}

console.log(sprintFunctions.primes(12));
24 changes: 24 additions & 0 deletions test/holdingtest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var sprintFunctions = {
allNum: function(num){
var n = 1
var arr = []
while(true){
arr.push(n)
if(n >= num){break}
n += 1
}
return arr
},

primeQuestion: function(number){
divisors = sprintFunctions.allNum(number-1)
divisors.shift()
question = true
divisors.forEach(function(x){
if (number % x == 0) {question = false}
})
return question
},
}

console.log(sprintFunctions.primeQuestion(11));
44 changes: 44 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//var inputArr = [1,2,3,4,5];
//var inputFunc = function(el){ return el*2; };
//var exp = [2,4,6,8,10];
//var actual = this.sprintObj.myMap(inputArr,inputFunc);
//if (typeof actual === 'undefined') { actual = [] };
//this.results.myMap = ( this.sprintObj.compareArrays(exp, actual) );

var allNum = function(num){
var n = 1
var arr = []
while(true){
arr.push(n)
if(n >= num){break}
n += 1
}
return arr
}

var primeQuestion = function(number){
divisors = allNum(number)
divisors.pop()
divisors.shift()
question = true
divisors.forEach(function(x){
if (number % x == 0) {question = false}
})
return question
}

var primes = function(thenumber){
array = []
posnum = allNum(thenumber)
posnum.pop()
posnum.shift()
posnum.forEach(function(x){
if(primeQuestion(x)){
array.push(x)
}
})
return array
}

console.log(primes(12))
//replace(" " || " ", "_")