Skip to content

webdev-js-intro-07 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
28 changes: 28 additions & 0 deletions js/assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,31 @@ const checkIfEvenElement = document.getElementById("check-if-even");
const lostNumbersElement = document.getElementById("lost-numbers");

const lostNumbers = [4, 8, 15, 16, 23, 42];

let x = 5 % 4; //I created a variable here so that these values could change depending on user input

function returnTheRemainder(){ //Step 1
remainderElement.innerText = x; // This works if it is x or 5 % 4
}

let y = 47; //This loop works regardless of input
//let y = 52 This would return "true"
function checkIfEven(){
if( y % 2 != 0 ){
checkIfEvenElement.innerText = "false" ;
} else checkIfEvenElement.innerText = "true" ;
}

function getTheFourthElement(){ //Step 3
lostNumbersElement.innerText = lostNumbers[3]; //returns 16
}

function render() {
returnTheRemainder();
checkIfEven();
getTheFourthElement();
}
submissionBtn.addEventListener("click", function () {
render();
});

9 changes: 9 additions & 0 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@
// that are not declared
"use strict"

function greet(name = 'Guest') { //copied given to get started
console.log('Hello, ' + name + '!');
}

greet(); // Output: "Hello, Guest!"
greet("Diane"); // Output: "Hello, Diane!"

//Thnak you for these assignments, the practice is so helpful and much better than watching videos
//I feel like the previous exercises have given me plenty of experience with functions