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
<script> | |
for (var i = 100; i <=150; i++) { | |
if (i % 2 == 1) { | |
console.log (i * i); | |
} | |
else { | |
console.log (i); | |
} | |
} | |
</script> |
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
for (var i = 10; i >= 0; i--) { | |
console.log(i); | |
if (i === 0) { | |
console.log("Blast Off!"); | |
} | |
} |
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 () { | |
console.log("hi"); | |
}; | |
//The following calls the function | |
hi(); |
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
var fullName = ""; | |
var name; | |
var firstLetter; | |
var fixName = function () { | |
} | |
name = prompt("Enter your first name (all in lower case):"); |
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
var sayHelloTo = function (name) { | |
console.log("Hello " + name); | |
}; | |
sayHelloTo("Kokoro"); |
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
var identity = function (x) { | |
return x; | |
}; |
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
var isOdd = function (n) { | |
if (n % 2 === 0) { | |
return false; | |
} else { | |
return true; | |
} | |
}; | |
console.log(isOdd(1)); | |
console.log(isOdd(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
var lost = [4, 8, 15, 16, 23, 42]; | |
var count = lost.length; | |
var isLost = function (n) { | |
for (var i = 0; i < 6; i++ ) { | |
if ( n === lost[i]) { | |
return true; | |
} | |
} | |
return false; |
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
var isMultipleOfThree = function (x) { | |
return x % 3 === 0; | |
}; | |
var isNotMultipleOfThree = function (x) { | |
return !isMultipleOfThree(x); | |
}; |
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
var power = function (base, exponent) { | |
var result = 1; | |
for (var i = 0; i < exponent; i++) { | |
result = result * base; | |
} | |
return result; | |
}; | |
power(2, 2); |