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
// Your code here. | |
function arrayToList(arr){ | |
var list = null; | |
for (var i = arr.length-1; i>=0; i--) | |
list = {value:arr[i], rest:list}; | |
return list; | |
} | |
function listToArray(list){ | |
var arr=[]; |
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
var reverseArray = function(arr) { | |
var arr2 = []; | |
for (var i = arr.length - 1; i >= 0; i--) | |
arr2.push(arr[i]); | |
return arr2; | |
}; | |
var reverseArrayInPlace = function(arr) { | |
var arr2 = 0; | |
for (var i = 0; i < arr.length / 2; i++) { | |
arr2 = arr[i]; |
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
function countBs(word){ | |
var sum=0; | |
for( var i = 0; i < word.length; i++){ | |
if (word.charAt(i)==="B") sum++; | |
}; | |
console.log(sum); | |
}; | |
function countChar(word, index){ | |
var sum=0; |
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
// Your code here. | |
function ifEven(number){ | |
if (number==0) console.log(true); | |
else console.log(false); | |
isEven(number-2); | |
} |
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
var number = 0; | |
for(var i = 1; i<=100; i++){ | |
number = i; | |
if(number % 5===0 && number % 3===0) console.log("Fizz Buzz"); | |
else if(number % 5===0) console.log("Buzz"); | |
else if(number % 3===0) console.log("Fizz"); | |
else console.log(number); | |
} |
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
var size = 8; //this is the variable setting | |
var board = ""; | |
for (var y = 0; y < size; y++) { | |
for (var x = 0; x < size; x++) { | |
if ((x + y) % 2 == 0) | |
board += " "; | |
else | |
board += "#"; |
NewerOlder