From 7cc674f26d062446587197eb7bbab55717b05820 Mon Sep 17 00:00:00 2001 From: tomzsus Date: Fri, 22 Sep 2023 21:49:32 +0300 Subject: [PATCH] task done --- arthimetic-operators.js | 38 +++++++++++++++++++++++++++++ index.html | 8 +++--- logical-comaprison-operators.js | 43 +++++++++++++++++++++------------ variables.js | 25 +++++++++++++++++++ 4 files changed, 96 insertions(+), 18 deletions(-) diff --git a/arthimetic-operators.js b/arthimetic-operators.js index 3ff7d54..0cee6c0 100644 --- a/arthimetic-operators.js +++ b/arthimetic-operators.js @@ -17,6 +17,13 @@ Task 1: 6. Set the value of variable e to the sum of variables a, b, c, and d. 7. Use console.log() to print the value of variable e to the console. (it should result 105.667) *******************************************************************************/ +let a,b,c,d,e ; +a=4+6; +b=10*5; +c=17%3; +d=b-a; +e=a+b+c+d; +console.log(e); // TODO: ADD YOUR CODE BELOW /******************************************************************************* @@ -28,3 +35,34 @@ Task 1: 5. Divide two numbers and round the result to the nearest integer before logging it to the console. *******************************************************************************/ // TODO: ADD YOUR CODE BELOW +const subtract = 1 - 3; console.log(subtract); + +const num1 = 1; +const num2 = num1 + 2; +const num3 = num2 + 2; +const num4 = num4 + 2; +const final = num1 * num2 * num3* num4; +console.log(final); + + +let length = 3; +let width = 5; +let height = 7; +let volume = length * width * height; +console.log(volume); + + + +let price = 9.99; + +let discount = 0.20; + +let finalPrice = price - (price * discount); + +console.log(finalPrice); + +console.log(Math.round(finalPrice)); + + + + diff --git a/index.html b/index.html index 9eb7d90..630dd21 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,9 @@ - - + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/logical-comaprison-operators.js b/logical-comaprison-operators.js index aea6930..256f462 100644 --- a/logical-comaprison-operators.js +++ b/logical-comaprison-operators.js @@ -6,35 +6,35 @@ TASK 1: // Have fun! // 😃 ********************************************************************************/ -const exp1 = 10 >= 10; // TODO: ADD YOUR EVALUATION HERE --> +const exp1 = 10 >= 10; // TODO: ADD YOUR EVALUATION HERE -->true -const exp2 = "dog" == "dog"; // TODO: ADD YOUR EVALUATION HERE --> +const exp2 = "dog" == "dog"; // TODO: ADD YOUR EVALUATION HERE -->true -const exp3 = true != false; // TODO: ADD YOUR EVALUATION HERE --> +const exp3 = true != false; // TODO: ADD YOUR EVALUATION HERE -->true -const exp4 = "10" === 10; // TODO: ADD YOUR EVALUATION HERE --> +const exp4 = "10" === 10; // TODO: ADD YOUR EVALUATION HERE -->false -const exp5 = 5 > 4; // TODO: ADD YOUR EVALUATION HERE --> +const exp5 = 5 > 4; // TODO: ADD YOUR EVALUATION HERE -->true -const exp6 = null == undefined; // TODO: ADD YOUR EVALUATION HERE --> +const exp6 = null == undefined; // TODO: ADD YOUR EVALUATION HERE -->true -const exp7 = "true" == true; // TODO: ADD YOUR EVALUATION HERE --> +const exp7 = "true" == true; // TODO: ADD YOUR EVALUATION HERE -->f -const exp8 = "false" == false; // TODO: ADD YOUR EVALUATION HERE --> +const exp8 = "false" == false; // TODO: ADD YOUR EVALUATION HERE -->f -const exp9 = NaN === NaN; // TODO: ADD YOUR EVALUATION HERE --> +const exp9 = NaN === NaN; // TODO: ADD YOUR EVALUATION HERE -->f -const exp10 = !false || false; // TODO: ADD YOUR EVALUATION HERE --> +const exp10 = !false || false; // TODO: ADD YOUR EVALUATION HERE -->true -const exp11 = false && !false; // TODO: ADD YOUR EVALUATION HERE --> +const exp11 = false && !false; // TODO: ADD YOUR EVALUATION HERE -->false -const exp12 = "apple" > "pineapple"; // TODO: ADD YOUR EVALUATION HERE --> +const exp12 = "apple" > "pineapple"; // TODO: ADD YOUR EVALUATION HERE -->false -const exp13 = "2" > "12"; // TODO: ADD YOUR EVALUATION HERE --> +const exp13 = "2" > "12"; // TODO: ADD YOUR EVALUATION HERE -->false -const exp14 = undefined == null; // TODO: ADD YOUR EVALUATION HERE --> +const exp14 = undefined == null; // TODO: ADD YOUR EVALUATION HERE -->true -const exp15 = undefined === null; // TODO: ADD YOUR EVALUATION HERE --> +const exp15 = undefined === null; // TODO: ADD YOUR EVALUATION HERE -->false /******************************************************************************* Task 2: @@ -47,33 +47,46 @@ const isHappy = false; // - Check if num is between 10 and 20 (inclusive) using the logical AND operator. Log the result to the console. // TODO: ADD YOUR CODE BELOW +console.log(num>=10 && num<=20); // - Check if num is either less than 5 or greater than 50 using the logical OR operator. Log the result to the console. // TODO: ADD YOUR CODE BELOW +console.log(num<5 || num>50) // - Check if str is either "apple" or "orange" using the logical OR operator. Log the result to the console. // TODO: ADD YOUR CODE BELOW +console.log( ste== apple||str==orange ) // - Check if isHappy value is true using the logical NOT operator. Log the result to the console. // TODO: ADD YOUR CODE BELOW +console.log(!ishappy); // - Check if num is even and greater than 10 using the logical AND operator. Log the result to the console. // TODO: ADD YOUR CODE BELOW +console.log( + num% 2==0 && num>10 +) // - Check if num is divisible by both 3 and 5 using the logical OR operator. Log the result to the console. // TODO: ADD YOUR CODE BELOW + // - Check if str contains the letter "e". Log the result to the console. // TODO: ADD YOUR CODE BELOW +console.log(str.includes("e")) // - Check if str starts with "Hakuna". Log the result to the console. // TODO: ADD YOUR CODE BELOW +console.log(str.startsWith("Hakuna")) // - Check if str ends with "a". Log the result to the console. // TODO: ADD YOUR CODE BELOW +console.log(str.endsWith("a")); // - Check if num is either negative or odd using the logical OR operator. Log the result to the console. // TODO: ADD YOUR CODE BELOW +console.log(num < 0 || num % 2 == 0); // - Check if the length of str is greater than num or equal to 40 using logical OR operator. Log the result to the console. // TODO: ADD YOUR CODE BELOW +console.log(str.length >= 40 || str.length == 40); diff --git a/variables.js b/variables.js index 2d8a281..5156bf5 100644 --- a/variables.js +++ b/variables.js @@ -15,6 +15,13 @@ 2. Use console.log() to output the value of each variable. ********************************************************************************/ // TODO: ADD YOUR CODE BELOW +let parseonName='Qassim'; +const age=22; +let ishappy = false ; + +console.log(parseonName+' '+ ishappy+age) + + /******************************************************************************* Task 2 (Reassigning variables): @@ -24,6 +31,8 @@ 2. Use console.log o output the value of 'nickName' *******************************************************************************/ // TODO: ADD YOUR CODE BELOW +let nickName = parseonName; +console.log(nickName) /******************************************************************************* Task 3 (Naming variables): @@ -33,6 +42,8 @@ 2. Declare a variable that stores the age of a user. What name would you choose for this variable? *******************************************************************************/ // TODO: ADD YOUR CODE BELOW +let monkieKid ; +let UserAge ; /******************************************************************************* Task 4 (String Concatenation): @@ -48,3 +59,17 @@ Steps: - Print the final message to the console, including the personName in uppercase in this format `Dear personName_VALUE, here's your message: finalMsg_VALUE.`. *******************************************************************************/ // TODO: ADD YOUR CODE BELOW + +let msg; +msg = prompt("Enter a message for the person:"); + +if (isHappy) { +let isHappy = true; + +msg += " And btw, why are you happy?"; +} +if (isHappy) { +msg += " And btw, why are you happy?"; +} else { +msg += " And btw, Good for you. There's nothing to be happy about."; +}