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 i; | |
for (i = 2; i <= 6; i+=2) { | |
console.log(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 i; | |
var animals = ["cat", "dog", "ferret"]; | |
// Loop goes here | |
for (i=0;i<animals.length;i++){ | |
console.log(animals[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 i; | |
var animals = ["cat", "dog", "ferret"]; | |
var length = animals.length; | |
// Loop goes here | |
for (i=0;i<length;i++){ | |
console.log(animals[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 word = "code"; | |
// Loop goes here | |
for(i=0;i<word.length;i++){ | |
console.log(word[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
// Define substring here | |
function subString(input, start, end){ | |
var i; | |
this.input = input; | |
this.start = start; | |
this.end = end; | |
for(i=start;i<=end;i++){ | |
console.log(input[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 name = "John Doe"; | |
function getFirstName (fullName){ | |
var i=0; | |
var firstName =""; | |
var next = fullName[0]; | |
var length=fullName.length; | |
while(i<length && next!==" "){ | |
firstName+=fullName[i]; | |
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 person = { | |
name: "Morgan Jones", | |
telephone: "(650) 777 - 7777", | |
email: "morgan.jones@example.com" | |
}; | |
for (var propertyName in person) { | |
console.log(propertyName +": "+ person[propertyName]); | |
} |
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 (i=1;i<4;i++){ | |
for(j=1;j<6;j++){ | |
console.log(j); | |
}} |
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 table, rows, i; | |
table = [ | |
["Person", "Age", "City"], | |
["Sue", 22, "San Francisco"], | |
["Joe", 45, "Halifax"] | |
]; | |
rows = table.length; | |
for (i = 0; i < rows; i++) { | |
console.log(table[i].join(" ")); |
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
while (true) { | |
console.log("I only print once!"); | |
break; | |
} |
OlderNewer