Last active
September 24, 2018 20:53
-
-
Save colorful-tones/49cbf2ac9ce8efdc0357edea8a3e65c5 to your computer and use it in GitHub Desktop.
[Fun with `for` loops] #JavaScript
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
// https://courses.wesbos.com/account/access/5b6921eb99ce1f5578c26a50/view/174357559 | |
const cuts = [ 'Chuck', 'Brisket', 'Shank', 'Short Rib' ]; | |
for ( const index in cuts ) { | |
console.log( cuts[index] ); | |
} |
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
// https://courses.wesbos.com/account/access/5b6921eb99ce1f5578c26a50/view/174357559 | |
const cuts = [ 'Chuck', 'Brisket', 'Shank', 'Short Rib' ]; | |
for ( let i = 0; i < cuts; i++ ) { | |
console.log( cuts[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
// https://courses.wesbos.com/account/access/5b6921eb99ce1f5578c26a50/view/174357559 | |
const cuts = [ 'Chuck', 'Brisket', 'Shank', 'Short Rib' ]; | |
cuts.forEach( ( cut ) -> { | |
console.log( cut ); | |
} ); |
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
// https://courses.wesbos.com/account/access/5b6921eb99ce1f5578c26a50/view/174357559 | |
const cuts = [ 'Chuck', 'Brisket', 'Shank', 'Short Rib' ]; | |
for ( const cut of cuts ) { | |
console.log( cut ); | |
} |
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
const buttons = document.querySelectorAll( '.button' ); | |
for ( const button of buttons ) { | |
button.addEventListener( 'click', function() { | |
console.log( this.textContent ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment