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 color = ['blue', 'yellow', 'black'] | |
| var presidents = ['clinton', 'obama', 'bush'] | |
| var whatever = ['cats', 'dogs', 'hot sause'] | |
| for (i = 0; i < color.length; i++) { | |
| console.log( i + " is a color I like " + color[i]) | |
| console.log( i + " president: " + presidents[i]) | |
| console.log( i + " random list " + whatever[i]) | |
| } |
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 current = 0; current <= 20; current++) { | |
| if (current % 2 == 0) { | |
| console.log('even: ' + current); | |
| } else { | |
| console.log('odd: ' + current); | |
| } | |
| } |
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 greaterNum(num1, num2){ | |
| if (num1 > num2) { | |
| return num1 + " is greater than " + num2; | |
| } else { | |
| return num2 + " is greater than " + num1; | |
| } | |
| } | |
| console.log(greaterNum(20, 32)) | |
| console.log(greaterNum(60, 32)) |
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 pluralizer(noun, number) { | |
| if (number == 1) { | |
| if (noun == 'geese') { | |
| return "" + number + " goose."; | |
| } | |
| else { | |
| return "" + number + " " + noun + ""; | |
| } | |
| } else | |
| { |
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 assignGrade(num_score) { | |
| if (num_score >= 90) { | |
| return "A"; | |
| } else if (num_score >= 80 && num_score <= 90) { | |
| return "B"; | |
| } else if (num_score >= 70 && num_score <= 80) { | |
| return "C"; | |
| } else if (num_score >= 60 && num_score <= 70) { | |
| return "D"; | |
| } else if (num_score <= 60) { |
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 helloWorld(lang_type) { | |
| if (lang_type == 'en') { | |
| return "hello world!" | |
| } else if (lang_type == 'es') { | |
| return "hola mundo" | |
| } else if (lang_type == 'fr') { | |
| return "bonjour tout le monde" | |
| } | |
| } | |
| console.log(helloWorld('fr')) |
NewerOlder