From 956a363ece5a161e62952742c6cc772205ce6ca3 Mon Sep 17 00:00:00 2001 From: husseinshaheed Date: Tue, 11 Jul 2023 16:04:25 +0300 Subject: [PATCH 1/4] sol the variables task by HusseinShaheed --- variables.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/variables.js b/variables.js index 2d8a281..d88b45f 100644 --- a/variables.js +++ b/variables.js @@ -15,7 +15,12 @@ 2. Use console.log() to output the value of each variable. ********************************************************************************/ // TODO: ADD YOUR CODE BELOW - +let personName = "Hussein"; +let age = 24; +let isHappy = true; +console.log(personName); +console.log(age); +console.log(isHappy); /******************************************************************************* Task 2 (Reassigning variables): @@ -24,7 +29,8 @@ 2. Use console.log o output the value of 'nickName' *******************************************************************************/ // TODO: ADD YOUR CODE BELOW - +let nickName = personName; +console.log(personName); /******************************************************************************* Task 3 (Naming variables): @@ -33,7 +39,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 favoriteMovie = "IT"; +let ageUser = 30; /******************************************************************************* Task 4 (String Concatenation): Build upon the previous task by completing the following steps: @@ -48,3 +55,15 @@ 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; +let whyHappy; +msg = prompt("Enter a message "); + +if (isHappy == true) { + whyHappy = prompt("And btw, Why are you happy?"); + console.log(whyHappy); +} +let finalMsg = `${msg}${" "}${whyHappy}`; +console.log( + `Dear ${personName.toLocaleUpperCase()}, here's your message: ${finalMsg} , and why iam happy ${whyHappy} ` +); From a5a26a00073892e9193f3735df151593f94d129e Mon Sep 17 00:00:00 2001 From: husseinshaheed Date: Wed, 12 Jul 2023 22:06:17 +0300 Subject: [PATCH 2/4] sol the arthimetic task --- arthimetic-operators.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arthimetic-operators.js b/arthimetic-operators.js index 3ff7d54..269ec6f 100644 --- a/arthimetic-operators.js +++ b/arthimetic-operators.js @@ -18,6 +18,21 @@ Task 1: 7. Use console.log() to print the value of variable e to the console. (it should result 105.667) *******************************************************************************/ // TODO: ADD YOUR CODE BELOW +let a; +let b; +let c; +let d; +let e; +a = 4 + 6; +b = 10 * 5; +c = 17 % 3; +console.log(a); +console.log(b); +console.log(c); +d = b - a; +console.log(d); +e = a + b + c + d; +console.log(e); /******************************************************************************* Task 2: @@ -28,3 +43,14 @@ 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 +let x = 10 - 5; +console.log(x); +let y = 1 * 3 * 5 * 7; +console.log(y); +let rectangular = 3 * 5 * 7; +console.log(rectangular); +let price = 9.99; +let discount = 0.2; +console.log(price * (price - discount)); +let z = 7 / 3; +console.log(Math.ceil(z)); From 5d8b04fefea691f19fd7d6ef09c192cb37f61624 Mon Sep 17 00:00:00 2001 From: husseinshaheed Date: Wed, 12 Jul 2023 22:06:41 +0300 Subject: [PATCH 3/4] sol the logical task --- logical-comaprison-operators.js | 83 +++++++++++++++++---------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/logical-comaprison-operators.js b/logical-comaprison-operators.js index aea6930..4fffbe0 100644 --- a/logical-comaprison-operators.js +++ b/logical-comaprison-operators.js @@ -6,36 +6,37 @@ TASK 1: // Have fun! // 😃 ********************************************************************************/ -const exp1 = 10 >= 10; // TODO: ADD YOUR EVALUATION HERE --> - -const exp2 = "dog" == "dog"; // TODO: ADD YOUR EVALUATION HERE --> - -const exp3 = true != false; // TODO: ADD YOUR EVALUATION HERE --> - -const exp4 = "10" === 10; // 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 exp8 = "false" == false; // TODO: ADD YOUR EVALUATION HERE --> - -const exp9 = NaN === NaN; // TODO: ADD YOUR EVALUATION HERE --> - -const exp10 = !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 exp13 = "2" > "12"; // TODO: ADD YOUR EVALUATION HERE --> - -const exp14 = undefined == null; // TODO: ADD YOUR EVALUATION HERE --> - -const exp15 = undefined === null; // TODO: ADD YOUR EVALUATION HERE --> - +const exp1 = 10 >= 10; // TODO: ADD YOUR EVALUATION HERE --> TRUE +console.log(exp1 + "1"); + +const exp2 = "dog" == "dog"; // TODO: ADD YOUR EVALUATION HERE --> TRUE +console.log(exp2 + "2"); +const exp3 = true != false; // TODO: ADD YOUR EVALUATION HERE --> TRUE +console.log(exp3 + "3"); +const exp4 = "10" === 10; // TODO: ADD YOUR EVALUATION HERE --> FALSE +console.log(exp4 + "4"); +const exp5 = 5 > 4; // TODO: ADD YOUR EVALUATION HERE --> TRUE +console.log(exp5 + "5"); +const exp6 = null == undefined; // TODO: ADD YOUR EVALUATION HERE --> TRUE +console.log(exp6 + "6"); +const exp7 = "true" == true; // TODO: ADD YOUR EVALUATION HERE --> FALSE +console.log(exp7 + "7"); +const exp8 = "false" == false; // TODO: ADD YOUR EVALUATION HERE --> FALSE +console.log(exp8 + "8"); +const exp9 = NaN === NaN; // TODO: ADD YOUR EVALUATION HERE --> FALSE +console.log(exp9 + "9"); +const exp10 = !false || false; // TODO: ADD YOUR EVALUATION HERE --> TRUE +console.log(exp10 + "10"); +const exp11 = false && !false; // TODO: ADD YOUR EVALUATION HERE --> FALSE +console.log(exp11 + "11"); +const exp12 = "apple" > "pineapple"; // TODO: ADD YOUR EVALUATION HERE --> FALSE +console.log(exp12 + "12"); +const exp13 = "2" > "12"; // TODO: ADD YOUR EVALUATION HERE --> TRUE +console.log(exp13 + "13"); +const exp14 = undefined == null; // TODO: ADD YOUR EVALUATION HERE --> TRUE +console.log(exp14 + "14"); +const exp15 = undefined === null; // TODO: ADD YOUR EVALUATION HERE -->FALSE +console.log(exp15 + "15"); /******************************************************************************* Task 2: In the following tasks, you will practice using logical operators in JavaScript, in addition to some strings methods. @@ -47,33 +48,35 @@ 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(10 < num && 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(str == "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 != true); // - 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 - +console.log(num % 3 == 0 || num % 5 == 0); // - Check if str contains the letter "e". Log the result to the console. // TODO: ADD YOUR CODE BELOW - +console.log(str.includes("r")); // - 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 +let lengthStr = str.length; +console.log(lengthStr > 40 || lengthStr === 40); From c37f9a81c0e294d9ab918ae70fc705ffc8778d5a Mon Sep 17 00:00:00 2001 From: husseinshaheed Date: Wed, 12 Jul 2023 22:07:31 +0300 Subject: [PATCH 4/4] sol all task section --- .vscode/settings.json | 3 +++ index.html | 4 ++-- 2 files changed, 5 insertions(+), 2 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/index.html b/index.html index 9eb7d90..b2f82da 100644 --- a/index.html +++ b/index.html @@ -7,8 +7,8 @@ Variables and Operators - + - + \ No newline at end of file