From 495cd66802672f388cb6b4231208fc81466db91c Mon Sep 17 00:00:00 2001 From: Mahdi209 Date: Wed, 7 Feb 2024 21:08:53 +0300 Subject: [PATCH 1/2] task is solved --- variables.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/variables.js b/variables.js index 2d8a281..60123f5 100644 --- a/variables.js +++ b/variables.js @@ -15,6 +15,10 @@ 2. Use console.log() to output the value of each variable. ********************************************************************************/ // TODO: ADD YOUR CODE BELOW + let personName = "Mohammed Mahdi"; + let age = 20; + let isHappy = true; + console.log("Name:"+personName+"\n"+"age:"+age+"\n"+"isHappy?:"+isHappy); /******************************************************************************* Task 2 (Reassigning variables): @@ -24,6 +28,8 @@ 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): @@ -33,6 +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 myFavoriteMovie = "Super Man"; +let user_age = 40; /******************************************************************************* Task 4 (String Concatenation): @@ -48,3 +56,6 @@ 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:") + let finalMsg = `${msg} And btw, Why are you happy?` + console.log(`Dear ${personName.toUpperCase()}, ${finalMsg}`); From 35613d2ba4ba9a0776209f3e431cffa85183c128 Mon Sep 17 00:00:00 2001 From: Mahdi209 Date: Thu, 8 Feb 2024 18:10:45 +0300 Subject: [PATCH 2/2] solveing arthmatic and logecal task --- arthimetic-operators.js | 48 ++++++++++++++++++++++++++++- index.html | 18 ++++++----- logical-comaprison-operators.js | 54 ++++++++++++++++++++++++--------- variables.js | 8 ++--- 4 files changed, 100 insertions(+), 28 deletions(-) diff --git a/arthimetic-operators.js b/arthimetic-operators.js index 927c518..1a0d8a1 100644 --- a/arthimetic-operators.js +++ b/arthimetic-operators.js @@ -18,7 +18,16 @@ 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("result of a: " + a); +// console.log("result of b: " + b); +// console.log("result of c: " + c); +// console.log("result of d: " + d); +console.log("result of e: " + e.toFixed(3)); /******************************************************************************* Task 2: 1. Subtract two numbers and log the result to the console. @@ -28,3 +37,40 @@ 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 +// 1 +let firstNum = 12; +let secondNum = 10; +let result = firstNum - secondNum; +console.log("result of 1: " + result); + +//2 + +let num1 = 1; +let num2 = 3; +let num3 = 5; +let num4 = 7; +result = num1 * num2 * num3 * num4; +console.log("result of 2: " +result); + + +//3 +let height = 3; +let width = 5; +let length = 7; +result = height * width * length; +console.log("result of 3" + result); + + +//4 +let price = 9.99; +let discount = 0.20; + price *= discount; +console.log("result of 4" + price); + + +//5 + +let x = 15; +let y = 6; +let division = x / y; +console.log(division.toFixed()); \ No newline at end of file diff --git a/index.html b/index.html index 10dc49b..3c7ec09 100644 --- a/index.html +++ b/index.html @@ -1,14 +1,16 @@ - - - - + + + + Variables and Operators - - - + + + + + - + diff --git a/logical-comaprison-operators.js b/logical-comaprison-operators.js index aea6930..1167470 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,57 @@ 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(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); + // - 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("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 % 2 == 0 || num % 3 == 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 > num || str.length === 40); diff --git a/variables.js b/variables.js index 60123f5..183cef1 100644 --- a/variables.js +++ b/variables.js @@ -29,7 +29,7 @@ *******************************************************************************/ // TODO: ADD YOUR CODE BELOW let nickName = personName; - console.log(nickName); + console.log(nickName); /******************************************************************************* Task 3 (Naming variables): @@ -56,6 +56,6 @@ 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:") - let finalMsg = `${msg} And btw, Why are you happy?` - console.log(`Dear ${personName.toUpperCase()}, ${finalMsg}`); + let msg=prompt("enter a message:") + let finalMsg = `${msg} And btw, Why are you happy?` + console.log(`Dear ${personName.toUpperCase()}, ${finalMsg}`);