From a58ceff7165a9b36eecd6fa4cd022db3f3b28a4a Mon Sep 17 00:00:00 2001 From: ElenaBarker <113217019+ElenaBarker@users.noreply.github.com> Date: Fri, 3 Mar 2023 23:01:19 +0000 Subject: [PATCH 1/4] Update 1-fix-functions.js task done --- mandatory/1-fix-functions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mandatory/1-fix-functions.js b/mandatory/1-fix-functions.js index 6323604f..afb6a261 100644 --- a/mandatory/1-fix-functions.js +++ b/mandatory/1-fix-functions.js @@ -10,8 +10,8 @@ */ -function getMood() { - let isHappy = true; +function getMood(isHappy) { + //let isHappy = true; if (isHappy) { return "I am happy"; @@ -21,7 +21,7 @@ function getMood() { } function greaterThan10(num) { - let isBigEnough; + let isBigEnough = num > 10; if (isBigEnough) { return "num is greater than 10"; From edf1eb9b0144c3c100aeb8538d135c99e5756488 Mon Sep 17 00:00:00 2001 From: ElenaBarker <113217019+ElenaBarker@users.noreply.github.com> Date: Sat, 4 Mar 2023 00:52:21 +0000 Subject: [PATCH 2/4] Update 2-function-creation.js first task done --- mandatory/2-function-creation.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mandatory/2-function-creation.js b/mandatory/2-function-creation.js index d4590920..33003606 100644 --- a/mandatory/2-function-creation.js +++ b/mandatory/2-function-creation.js @@ -4,7 +4,13 @@ 1. the user should be 18 or older 2. the user must be logged in */ -function isAcceptableUser(userAge, isLoggedIn) {} +function isAcceptableUser(userAge, isLoggedIn) { + + if (userAge >= 18 && isLoggedIn === true) { + return true + } + else {return false} +} /* Complete the function to apply discount percent based on how much is totalPrice in user cart. @@ -15,7 +21,9 @@ function isAcceptableUser(userAge, isLoggedIn) {} is applieds and 142.5 should be returned) */ -function applyDiscount(totalPrice) {} +function applyDiscount(totalPrice) { + +} /* Complete the function to print to the console the odd numbers between 1 and limit (use a while loop): From eae7da904755f5f586712db3d2204ab14ea69059 Mon Sep 17 00:00:00 2001 From: ElenaBarker <113217019+ElenaBarker@users.noreply.github.com> Date: Thu, 16 Mar 2023 21:50:14 +0000 Subject: [PATCH 3/4] Update 2-function-creation.js Mandatory tasks done --- mandatory/2-function-creation.js | 39 ++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/mandatory/2-function-creation.js b/mandatory/2-function-creation.js index 33003606..16dcd23f 100644 --- a/mandatory/2-function-creation.js +++ b/mandatory/2-function-creation.js @@ -22,19 +22,35 @@ function isAcceptableUser(userAge, isLoggedIn) { */ function applyDiscount(totalPrice) { - + if (totalPrice > 200) { + return (totalPrice - (totalPrice/100) * 10) + } + else {return (totalPrice - (totalPrice/100) * 5)} + } /* Complete the function to print to the console the odd numbers between 1 and limit (use a while loop): */ -function printOddNumbers(limit) {} +function printOddNumbers(limit) { + let number = 0; + while (true) { + if (number%2 === 0) continue; + console.log(number); + } +} /* Complete the buyTwoGetTheCheapestFree function: if user buys two items, the cheapest item will be free! The function should return the price to be paid once the discount is applied. */ -function buyTwoGetTheCheapestFree(price1, price2) {} +function buyTwoGetTheCheapestFree(price1, price2) { +if (price1 > price2){ +return price1;} +else { + return price2; +} +} /* Complete the function to determine if it is suitable for a person to register based on their age! @@ -42,7 +58,15 @@ function buyTwoGetTheCheapestFree(price1, price2) {} - if the person is older than 12 and younger than 90 it should return "You Can Register" - if the person is 90 or older it should return "You Don't Need To Register" */ -function canRegister(age) {} +function canRegister(age) { + if (age <= 12) { + return "You Are Too Young To Register"; + } + if (age > 12 && age < 90){ + return "You Can Register"; + } + else {return "You Don't Need To Register"} +} /* Complete the function so that it prints out to the console numbers in reverse order starting at @@ -53,7 +77,12 @@ function canRegister(age) {} ) */ -function countReverse(number) {} +function countReverse(number) { + while (number > 0){ + console.log (number); + number = number - 1; + } +} /* ======= TESTS - DO NOT MODIFY ===== */ From 8101971d57f8a318a58bfbe0478d4b470ff0514b Mon Sep 17 00:00:00 2001 From: ElenaBarker <113217019+ElenaBarker@users.noreply.github.com> Date: Wed, 22 Mar 2023 23:42:17 +0000 Subject: [PATCH 4/4] Update 2-function-creation.js printOddNumbers updated --- mandatory/2-function-creation.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mandatory/2-function-creation.js b/mandatory/2-function-creation.js index 16dcd23f..397454ef 100644 --- a/mandatory/2-function-creation.js +++ b/mandatory/2-function-creation.js @@ -34,7 +34,8 @@ function applyDiscount(totalPrice) { */ function printOddNumbers(limit) { let number = 0; - while (true) { + while (number < limit) { + number = number + 1; if (number%2 === 0) continue; console.log(number); }