Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

my solution #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
83 changes: 63 additions & 20 deletions scripts.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,75 @@
// FILL IN THE FUNCTIONS BELOW

var sprintFunctions = {
largestEl: function(){
// your code here
},

reversed: function(){
// your code here
largestEl : function(array){
var larger = array[0]
for (var i = 0; i < array.length; i++) {
if (larger < array[i]) {
larger = array[i];
}
}
return larger;
},

loudSnakeCase: function(){
// your code here

reversed: function(word){
var arrayOfWord = [];
arrayOfWord=Array.from(word);
var reversedArray=arrayOfWord.reverse();
var reversedWord=reversedArray.join('');
return reversedWord;
},

compareArrays: function(){
// your code here (replace the return)
return "Finish compareArrays first!"
loudSnakeCase: function(sentence){
var cleanArray= sentence.toLowerCase().replace(/[^\w\s]|_/g, "").replace(' ',' ').split(" ");
var capInit = function() {
for (i=0; i<cleanArray.length; i++) {
cleanArray[i]=cleanArray[i].charAt(0).toUpperCase() + cleanArray[i].substring(1);
}
return cleanArray.join('_');
};
return capInit();
},

fizzBuzz: function(){
// your code here
},
compareArrays: function(array1, array2){
if (array1.length !== array2.length) return false;
for (var i = 0; i < array1.length; i++){
if (array1[i] !== array2[i]){return false;}
}
return true;
},

myMap: function(){
// your code here
},
fizzBuzz: function(m){
var emptyArray=[];
for (i=1; i<=m; i++) {
if (i%3===0 && i%5===0) {emptyArray.push('FIZZBUZZ');}
else if (i%3===0) {emptyArray.push('FIZZ');}
else if (i%5===0) {emptyArray.push('BUZZ');}
else {emptyArray.push(i);}
} //end of for

return emptyArray;
},//endof fizzBuzz

myMap: function(arr, func){
var newArray= [];
for (i=0; i<arr.length;i++) {
var y = func(arr[i]);
newArray.push(y);
} //end for

return newArray;
},//my map end

primes: function(n){
var newArray=[];
var counter=0;
for(var j=1;j<=n;j++){
for(var i=1;i<=j;i++){if(j%i===0){counter++;}}
if(counter===2){newArray.push(j);}
counter=0;
}
return newArray;
},

primes: function(){
// your code here
},
}