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
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (Loops and arrays 1) assignment | |
// Dr. Steven B. Combs, coding novice | |
// Print out every element within an array using a for loop | |
var cities = ["Melbourne", "Amman", "Helsinki", "NYC", "Columbus"]; | |
for (var i = 0; i < cities.length; i++) { | |
console.log("I would like to visit " + cities[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
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (Function as Argument) assignment | |
// Dr. Steven B. Combs, coding novice | |
function dogCare(){ | |
alert("walk 9am, Feed at 4pm, walk at 10pm"); | |
} | |
// add a parameter called chores | |
function doTwice(chores){ |
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
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (Rock, Paper, Scissors) assignment | |
// Dr. Steven B. Combs, coding novice | |
var userChoice = prompt("Do you choose rock, paper or scissors?"); | |
var computerChoice = Math.random(); | |
if (computerChoice < 0.34) { | |
computerChoice = "rock"; | |
} else if (computerChoice <= 0.67) { | |
computerChoice = "paper"; |
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
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (Another Function If Else) assignment | |
// Dr. Steven B. Combs, coding novice | |
var creditCheck = function(income){ | |
if (income >= 100){ | |
return "You earn a lot of money! You qualify for a credit card."; | |
} else { | |
return "Alas you do not qualify for a credit card. Capitalism is cruel like that."; | |
} |
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
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (Functions with two Parameters) assignment | |
// Dr. Steven B. Combs, coding novice | |
var perimeterBox = function(length, width) { // Define function with two variables | |
return 2 * (length + width); // Multiply length + width times 2 | |
}; | |
perimeterBox(2,2) // Call function with two variables |
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
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (Conclusion Part 2) assignment | |
// Dr. Steven B. Combs, coding novice | |
// Define quarter function | |
var quarter = function(number){ | |
return number / 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
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (How does a Function work) assignment | |
// Dr. Steven B. Combs, coding novice | |
// Create function | |
var foodDemand = function (food) { | |
console.log("I want to eat" + " " + food); | |
}; | |
// Call function |
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
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (Choose Your Own Adventure) assignment | |
// Dr. Steven B. Combs, coding novice | |
// Check if the user is ready to play! | |
confirm("I am ready to play!"); | |
var age = prompt("how old are you"); | |
if (age < 18){ | |
console.log("You may play, but I do not accept responsibility"); | |
} else { |
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
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (Conclusion Part 2) assignment | |
// Dr. Steven B. Combs, coding novice | |
if (1 == 1){ // Evaluate for True | |
console.log("I finished my first course!") // Print to console if True | |
} else { // Else | |
console.log("I messed up!") // Print to console | |
} |
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
# Computer the bill for a shopping list | |
# A Codecademy Python (Making a Purchase) assignment | |
# Dr. Steven B. Combs, coding novice | |
groceries = ["banana", "orange", "apple"] | |
stock = { | |
"banana": 6, | |
"apple": 0, | |
"orange": 32, |