This file contains hidden or 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
| function reverseArray(argArray){ | |
| var newArray=[]; | |
| var arrayLength=argArray.length-1; | |
| for(var i=0;i<argArray.length;i++){ | |
| newArray[arrayLength]=argArray[i]; | |
| arrayLength--; | |
| } | |
| console.log(newArray); |
This file contains hidden or 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
| function indexOf(argArray,argElement){ | |
| if(argArray.indexOf(argElement)){ | |
| console.log(argArray.indexOf(argElement)); | |
| } | |
| } | |
| indexOf([1,2,3],2); |
This file contains hidden or 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
| function removeZero(arg){ | |
| debugger; | |
| var argToString=arg.toString(); | |
| var argToArray=argToString.split(""); | |
| while(argToArray.indexOf("0")>=0){ | |
| argToArray.splice(argToArray.indexOf("0"), 1); | |
| } | |
| argToString=argToArray.join(""); | |
| arg=Number(argToString); | |
| console.log(arg); |
This file contains hidden or 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
| function isTruthy(arg){ | |
| var theType= typeof arg; | |
| var theBool= !!arg; //the original bool of the param | |
| var theMessage= ""; | |
| console.log(theType+" "+theBool); | |
| if(theType==="undefined"){ | |
| theMessage= theType+" is falsey"; | |
| }else if(theType==="null"){ | |
| theMessage= "The "+theType+" value is falsey"; | |
| }else if(theType==="boolean"){ |
This file contains hidden or 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
| function howEqual(valA, valB){ | |
| if(valA===valB){ | |
| console.log("strictly"); | |
| }else if(valA==valB){ | |
| console.log("loosely"); | |
| }else{ | |
| console.log("not equal"); | |
| } | |
| } | |
| howEqual(0,"0") // => "loosely" |
This file contains hidden or 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
| function fizzBuzz(num){ | |
| debugger; | |
| for(var i = 1;i <= num ;i++){ | |
| if(!(i%3) && !(i%5)){ | |
| console.log('fizzbuzz'); | |
| } else if (!(i%3)) { | |
| console.log('fizz'); | |
| } else if (!(i%5)) { | |
| console.log('buzz'); | |
| } else { |
This file contains hidden or 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
| function count(n,m,direction){ | |
| //n is limit | |
| //m is interval | |
| //direction up or down | |
| if(direction==="up"){ | |
| for(var i=m; i<=n; i+=m){ | |
| console.log(i); | |
| } | |
| }else{ |
This file contains hidden or 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
| function bactrianCase(message){ | |
| var resultMessage=""; | |
| for(i=0;i<message.length;i++){ | |
| if(i%2===0){ | |
| resultMessage+=message[i].toUpperCase(); | |
| }else{ | |
| resultMessage+=message[i].toLowerCase(); | |
| } | |
| //(i%2===0) ? resultMessage+=message[i].toUpperCase() : resultMessage+=message[i].toLowerCase(); | |
| } |
This file contains hidden or 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
| function nicknameGenerator(fullName){ | |
| var nickName=""; | |
| var fullNameTemp=fullName.toLowerCase(); | |
| if(fullNameTemp[2]==="a" || | |
| fullNameTemp[2]==="e" || | |
| fullNameTemp[2]==="i" || | |
| fullNameTemp[2]==="o" || | |
| fullNameTemp[2]==="u"){ | |
| //log 4 letters | |
| nickName=fullName.slice(0,4); |
This file contains hidden or 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
| function converter(degrees){ | |
| var degreesCelsius = (degrees - 32) * (5 / 9); | |
| var degreesKelvin = degreesCelsius + 273.15; | |
| console.log(degrees + " degrees Fahrenheit"); | |
| console.log("equals " + degreesCelsius + " degrees Celsius"); | |
| console.log("equals " + degreesKelvin + " degrees Kelvin"); | |
| } | |
| //converter(77); | |
| function converter2(degrees){ |