From d78b9d7f925c7dd4d8617c93f772b3373ad7599e Mon Sep 17 00:00:00 2001 From: zainabyahya Date: Wed, 7 Feb 2024 19:51:32 +0300 Subject: [PATCH 1/3] solved tasks in variables.js --- .vscode/settings.json | 3 +++ logical-comaprison-operators.js | 22 +++++++++++----------- variables.js | 20 ++++++++++++++++++-- 3 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6b665aa --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} diff --git a/logical-comaprison-operators.js b/logical-comaprison-operators.js index aea6930..3478446 100644 --- a/logical-comaprison-operators.js +++ b/logical-comaprison-operators.js @@ -8,29 +8,29 @@ TASK 1: const exp1 = 10 >= 10; // TODO: ADD YOUR EVALUATION HERE --> -const exp2 = "dog" == "dog"; // TODO: ADD YOUR EVALUATION HERE --> +const exp2 = "dog" == "dog"; // TODO: ADD YOUR EVALUATION HERE --> -const exp3 = true != false; // TODO: ADD YOUR EVALUATION HERE --> +const exp3 = true != false; // TODO: ADD YOUR EVALUATION HERE --> -const exp4 = "10" === 10; // TODO: ADD YOUR EVALUATION HERE --> +const exp4 = "10" === 10; // TODO: ADD YOUR EVALUATION HERE --> -const exp5 = 5 > 4; // TODO: ADD YOUR EVALUATION HERE --> +const exp5 = 5 > 4; // TODO: ADD YOUR EVALUATION HERE --> const exp6 = null == undefined; // TODO: ADD YOUR EVALUATION HERE --> -const exp7 = "true" == true; // TODO: ADD YOUR EVALUATION HERE --> +const exp7 = "true" == true; // TODO: ADD YOUR EVALUATION HERE --> -const exp8 = "false" == false; // TODO: ADD YOUR EVALUATION HERE --> +const exp8 = "false" == false; // TODO: ADD YOUR EVALUATION HERE --> -const exp9 = NaN === NaN; // TODO: ADD YOUR EVALUATION HERE --> +const exp9 = NaN === NaN; // TODO: ADD YOUR EVALUATION HERE --> -const exp10 = !false || false; // TODO: ADD YOUR EVALUATION HERE --> +const exp10 = !false || false; // TODO: ADD YOUR EVALUATION HERE --> -const exp11 = false && !false; // TODO: ADD YOUR EVALUATION HERE --> +const exp11 = false && !false; // TODO: ADD YOUR EVALUATION HERE --> -const exp12 = "apple" > "pineapple"; // TODO: ADD YOUR EVALUATION HERE --> +const exp12 = "apple" > "pineapple"; // TODO: ADD YOUR EVALUATION HERE --> -const exp13 = "2" > "12"; // TODO: ADD YOUR EVALUATION HERE --> +const exp13 = "2" > "12"; // TODO: ADD YOUR EVALUATION HERE --> const exp14 = undefined == null; // TODO: ADD YOUR EVALUATION HERE --> diff --git a/variables.js b/variables.js index 2d8a281..a285406 100644 --- a/variables.js +++ b/variables.js @@ -16,24 +16,36 @@ ********************************************************************************/ // TODO: ADD YOUR CODE BELOW +let personName = "Zainab"; +let age = 23; +let isHappy = false; +console.log(personName, age, "Happy: " + isHappy); + + /******************************************************************************* Task 2 (Reassigning variables): - + Steps: 1. Create a new variable named 'nickName' and assign the value of the 'personName' variable to the 'nickName' variable. 2. Use console.log o output the value of 'nickName' *******************************************************************************/ // TODO: ADD YOUR CODE BELOW +let nickName = personName; +console.log(nickName); + /******************************************************************************* Task 3 (Naming variables): - + Steps: 1. Create a variable with the title of your favorite movie. How would you name such a variable? 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 favoriteMovie = "The Invisible Guest"; +let ageUser = 23; + /******************************************************************************* Task 4 (String Concatenation): Build upon the previous task by completing the following steps: @@ -48,3 +60,7 @@ 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 = prompt("Enter a message:"); +finalMsg = `${msg}. And btw, Good for you. There's nothing to be happy about.`; +console.log(`Dear ${personName}, here's your message: ${finalMsg}`); \ No newline at end of file From c1968650c35027dc148af9f9973fdd914e44c7f8 Mon Sep 17 00:00:00 2001 From: zainabyahya Date: Wed, 7 Feb 2024 19:59:23 +0300 Subject: [PATCH 2/3] fixed some mistakes --- variables.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.js b/variables.js index a285406..1215a05 100644 --- a/variables.js +++ b/variables.js @@ -62,5 +62,5 @@ Steps: // TODO: ADD YOUR CODE BELOW let msg = prompt("Enter a message:"); -finalMsg = `${msg}. And btw, Good for you. There's nothing to be happy about.`; +let finalMsg = msg.concat(". And btw, Good for you. There's nothing to be happy about."); console.log(`Dear ${personName}, here's your message: ${finalMsg}`); \ No newline at end of file From 539d87bd2ea0e2c9560dc913ef6c2b44399b3704 Mon Sep 17 00:00:00 2001 From: zainabyahya Date: Thu, 8 Feb 2024 17:30:40 +0300 Subject: [PATCH 3/3] solved the other 2 files --- arthimetic-operators.js | 19 ++++++++++-- index.html | 20 ++++++------- logical-comaprison-operators.js | 53 +++++++++++++++++++++++---------- 3 files changed, 64 insertions(+), 28 deletions(-) diff --git a/arthimetic-operators.js b/arthimetic-operators.js index 927c518..e545639 100644 --- a/arthimetic-operators.js +++ b/arthimetic-operators.js @@ -18,13 +18,28 @@ Task 1: 7. Use console.log() to print the value of variable e to the console. (it should result 102.000) *******************************************************************************/ // TODO: ADD YOUR CODE BELOW - +let a = 4 + 6; +let b = 10 * 5; +let c = 17 % 3; +let d = b - a; +let e = a + b + c + d; +console.log(e); /******************************************************************************* Task 2: - 1. Subtract two numbers and log the result to the console. + 1. Subtract two numbers and log the result to the console. 2. Multiply together the values of four odd numbers that come one after the other, and then output the final result to the console. 3. Calculate the volume of a rectangular prism with dimensions 3x5x7 and log the result to the console (Volume of rectangular is h x w x l). 4. Declare a variable price and assign it the value 9.99. Declare another variable discount and assign it the value 0.20. Calculate the discounted price and log the result to the console. 5. Divide two numbers and round the result to the nearest integer before logging it to the console. *******************************************************************************/ // TODO: ADD YOUR CODE BELOW + +console.log("Subtraction of 2 numbers: " + (4 - 3)); +console.log("Multiplication of 4 odd numbers: " + (1 * 3 * 5 * 7)); +console.log("Volume of a rectangle:" + (3 * 5 * 7)); +let price = 9.99; +let discount = 0.20; +let discountedPrice = 9.99 * (1 - discount); +console.log("Discounted Price:" + discountedPrice); +let x = Math.round(100 / 60); +console.log(x); \ No newline at end of file diff --git a/index.html b/index.html index 10dc49b..abbe85f 100644 --- a/index.html +++ b/index.html @@ -1,14 +1,14 @@ - - - - + + + + Variables and Operators - - - - - - + + + + + + diff --git a/logical-comaprison-operators.js b/logical-comaprison-operators.js index 3478446..bc6e6e5 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 --> true -const exp8 = "false" == false; // TODO: ADD YOUR EVALUATION HERE --> +const exp8 = "false" == false; // TODO: ADD YOUR EVALUATION HERE --> true -const exp9 = NaN === NaN; // TODO: ADD YOUR EVALUATION HERE --> +const exp9 = NaN === NaN; // TODO: ADD YOUR EVALUATION HERE --> false -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 --> true -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,54 @@ 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 - +let a = num > 10 && num < 20; +console.log(a); // - 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 +let b = num <= 5 || num > + 50; +console.log(b); // - Check if str is either "apple" or "orange" using the logical OR operator. Log the result to the console. // TODO: ADD YOUR CODE BELOW +let c = str === "apple" || str === "orange"; +console.log(c); // - Check if isHappy value is true using the logical NOT operator. Log the result to the console. // TODO: ADD YOUR CODE BELOW +let d = isHappy === !false; +console.log(d); // - 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 +let e = (num % 2) === 0 && num > 10; +console.log(e); // - 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 +let f = (num % 3) === 0 || (num % 5) === 5; +console.log(f); // - Check if str contains the letter "e". Log the result to the console. // TODO: ADD YOUR CODE BELOW +let g = str.includes("e"); +console.log(g); // - Check if str starts with "Hakuna". Log the result to the console. // TODO: ADD YOUR CODE BELOW +let h = str.startsWith("Hakuna"); +console.log(h); // - Check if str ends with "a". Log the result to the console. // TODO: ADD YOUR CODE BELOW +let i = str.endsWith("a"); +console.log(i); // - Check if num is either negative or odd using the logical OR operator. Log the result to the console. // TODO: ADD YOUR CODE BELOW +let j = num < 0 || (num % 2) === 1; +console.log(j); // - 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 +let k = str.length > num || str.length >= 40; +console.log(k);