Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions js/assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ const ageInputEl = document.getElementById("age-input")
const submissionBtn = document.getElementById("submission-btn");

// create a mutable variable called age and do not assign it a value.

let age = "";

function checkAgeAndRespond() {
age = parseInt(ageInputEl.value);

// Write your code below
if (age >= 21){
console.log("You can vote and purchase alcohol.");
} else if (age <21 && age >= 18) {
console.log("You can vote, but you cannot purchase alcohol.");
} else
console.log("You cannot vote and you cannot purchase alcohol.");


}

Expand Down
31 changes: 30 additions & 1 deletion js/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
// Prevent us from attempting to use variables
// that are not declared
"use strict"
"use strict"
let healthPoints = 20;
let experiencePoints = 100;

if (healthPoints >= 10) { //Checks HP only if >10 then ok
console.log("Hero is healthy.");
} else if (healthPoints < 10 && healthPoints >= 5) { //5 <= hp < 10
console.log("Hero is slightly damaged.");
} else {
console.log("Hero is close to death."); //if hp <5 then this
}
if (healthPoints >= 20) {
console.log("Hero is leveling up!!!"); //hp >=20 Superhero
}
if (healthPoints == 0) {
console.log("You're hero has died, and you are next!!"); //HP = 0 then dead
}
if (experiencePoints > 100) { //XP allows hero to level up
console.log("Hero has a new Super Power!!");
}

if (experiencePoints >= 100) { //XP makes hero a SUPER
console.log("Hero is now a SUPERHERO!!");
} else if (experiencePoints < 100 && healthPoints >= 5) { //Hero is hungry!
console.log("Hero needs to recharge! Get him a sandwich!!");
} else if (experiencePoints <100 && healthPoints < 10){ //Hero is dying
console.log("Hero is close to death.");
} else {
console.log("Your Hero Has Died!!"); // Hero is dead
}