Created
November 19, 2015 12:16
-
-
Save fehler/19f2014c89c21e64173e to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Variables - 02</title> | |
</head> | |
<body> | |
<p>With the money my parents left me I can buy <span id="quantity"></span> cans of <span id="beverage"></span> at a total cost of <span id="totalPrice"></span>.</p> | |
<script> | |
var beverage = "Guinness"; | |
var guinnessPrice = 1.20; | |
var beverage = "Buckfast"; | |
var guinnessPrice = 6.00; | |
var quantity = 6; | |
var totalPrice = guinnessPrice * quantity | |
var totalPrice = buckfastPrice * quantity // This isn't going to work as I have two variables called "totalPrice", we'll need to find another way to do this. | |
document.getElementById("quantity").innerHTML = quantity; | |
document.getElementById("beverage").innerHTML = beverage; | |
document.getElementById("totalPrice").innerHTML = totalPrice; | |
</script> | |
</body> | |
</html> | |
<!-- | |
Notes | |
===== | |
In this example we're defining more values for different beverages. Somehow I need to use variables to calcualte out different prices and quantities. A little stumped. Google is my friend. (So is David Turner!) | |
--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment