Created
August 13, 2021 02:56
-
-
Save natafaye/59e6912676671752f68b7fb291a9eb81 to your computer and use it in GitHub Desktop.
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 getAnswer(question) { | |
const answer = prompt(question); | |
return answer; | |
} | |
function start() { | |
let name = getAnswer("What is your name?") | |
alert("Hello " + name) | |
name = getAnswer("What is your name?") | |
alert("Hello " + name) | |
let hometown = getAnswer("Where are you from?") | |
alert(hometown + " is a great place!") | |
} |
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 setName(animal) { | |
const name = prompt("What is the name of your " + animal.type + "?"); | |
animal.name = name; | |
} | |
function start() { | |
let cat = { | |
color: "brown", | |
type: "cat" | |
} | |
setName(cat); | |
let dog = { | |
color: "red", | |
type: "dog" | |
} | |
setName(dog); | |
alert("Cat named: " + cat.name); | |
alert("Dog named: " + dog.name); | |
} |
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 addVote(animal, voteList) { | |
voteList.push(animal); | |
} | |
function displayVotes(voteList) { | |
alert(voteList.join(", ")); | |
} | |
function start() { | |
let voteList = []; | |
let vote = prompt("What is your vote?"); | |
addVote(vote, voteList); | |
vote = prompt("What is your vote?"); | |
addVote(vote, voteList); | |
vote = prompt("What is your vote?"); | |
addVote(vote, voteList); | |
displayVotes(voteList); | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<button onclick="start()">Start</button> | |
<script src="week3.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment