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 sumMachine(a, b) { | |
var sum = a + b; | |
return sum; | |
} | |
console.log(sumMachine(2, 2)); | |
console.log(sumMachine(4, 4)); |
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 funcName = function() { | |
console.log('Hello I am from the function'); | |
} | |
funcName(); |
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 funcName() { | |
console.log('Hello I am from the function'); | |
} | |
funcName(); |
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 items = [1, 2, 3, 4, 5, 6]; | |
for(item in items) { | |
console.log(item); | |
} |
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
for(var i = 0; i < 10; i++) { | |
if(i === 5) { | |
console.log(i + ' is skipped'); | |
continue; | |
} | |
console.log('i is now at: ' + 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
for(var i = 0; i < 10; i++) { | |
if(i === 5) { | |
break; | |
} | |
console.log('i is now at: ' + 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
var num = 20; | |
while(num < 10) { | |
console.log('Inside the Loop'); | |
num = prompt('Enter the number: '); | |
} | |
console.log('Out of the loop'); |
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 num = 0; | |
while(num < 10) { | |
num = prompt('Enter the number: '); | |
} | |
console.log('Out of the loop'); |
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 num; | |
do { | |
console.log('Inside the Loop'); | |
num = prompt('Enter the number: '); | |
} while(num < 10); | |
console.log('Outside the Loop'); |
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
for(var i = 0; i < 10; i++) { | |
console.log('Go ' + i + ' step'); | |
} |