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 myString = true; | |
if (myString) { | |
// this should evaluate to true because myString = "true", and it does. Good! | |
} | |
if (!myString) { | |
// uh oh! This evaluates to true as well. Why? Because if(!myString) | |
// is checking to see if myString *exists*, not if it's *true*. | |
} |
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
myArray.forEach(function(element, index, array) { | |
console.log(element); // element is the current element in the array | |
console.log(index); // index is the position of that element in the array | |
console.log(array); // this is the array the forEach loop was called on | |
}); |
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
myArray.forEach(function(element, index, array) { | |
console.log(element); // element is the current element in the array | |
console.log(index); // index is the position of that element in the array | |
console.log(array); // this is the array the forEach loop was called on | |
}); |
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) { | |
// statement | |
if(condition == false) { | |
break; | |
} | |
} |
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
do { | |
// statement | |
} while (false); |
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
do { | |
statement; | |
} while (condition); |
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
do { | |
statement; | |
} while (condition); |
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(condition) { | |
// do something | |
} |
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
<?xml version="1.0" standalone="no"?> | |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" | |
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | |
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"> | |
<circle cx="100" cy="50" r="40" stroke="black" | |
stroke-width="2" fill="red" /> | |
</svg> |
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
// get the element we want | |
var myElement = document.getElementById("myElement"); | |
// get its inner HTML and put it in an array | |
var myInnerHTML = [myElement.innerHTML]; | |
for(var i = 0; i < 10; i++) { | |
// add a string to the end of the myInnerHTML array | |
myInnerHTML.push("some value"); | |
} |