From 2c8e393de0e1676469bdd612ade1be2a6229d499 Mon Sep 17 00:00:00 2001 From: Diane Vail Date: Tue, 31 Dec 2024 11:10:34 -0500 Subject: [PATCH] webdev-js-intro-07 --- js/assignment.js | 28 ++++++++++++++++++++++++++++ js/index.js | 9 +++++++++ 2 files changed, 37 insertions(+) diff --git a/js/assignment.js b/js/assignment.js index 0b914d3..cd80e80 100644 --- a/js/assignment.js +++ b/js/assignment.js @@ -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(); +}); + diff --git a/js/index.js b/js/index.js index 60f6971..ce0feea 100644 --- a/js/index.js +++ b/js/index.js @@ -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 \ No newline at end of file