diff --git a/arthimetic-operators.js b/arthimetic-operators.js index 927c518..c5dd6b1 100644 --- a/arthimetic-operators.js +++ b/arthimetic-operators.js @@ -18,7 +18,13 @@ 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,b,c,d,e; +a= 4 + 6 ; +b= 10 * 5 ; +c= 17 % 3 ; +d= b - a ; +e= a + b + c + d ; +console.log(e.toFixed(3)); /******************************************************************************* Task 2: 1. Subtract two numbers and log the result to the console. @@ -28,3 +34,15 @@ 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 +console.log(4-2); +console.log(3*5*1*7); +let h,w,l; +h=3; +w=5; +l=7; +let volumeOfRectangular=h*w*l; +console.log("Volume of rectangular is: " + volumeOfRectangular); +let price=9.99; +let discount=0.20; +console.log("the final price after discounte is: " + (price-discount)); +console.log("Div two num is : " + Math.round(7/3)); \ No newline at end of file diff --git a/index.html b/index.html index 10dc49b..655faa9 100644 --- a/index.html +++ b/index.html @@ -1,14 +1,17 @@ + Variables and Operators + - - + + - + + \ No newline at end of file diff --git a/logical-comaprison-operators.js b/logical-comaprison-operators.js index aea6930..26b64c6 100644 --- a/logical-comaprison-operators.js +++ b/logical-comaprison-operators.js @@ -6,36 +6,38 @@ TASK 1: // Have fun! // 😃 ********************************************************************************/ -const exp1 = 10 >= 10; // TODO: ADD YOUR EVALUATION HERE --> - +const exp1 = 10 >= 10; // TODO: ADD YOUR EVALUATION HERE --> +let x=10; +let y=10; +console.log(x >= y); const exp2 = "dog" == "dog"; // TODO: ADD YOUR EVALUATION HERE --> - +console.log("dog" == "dog"); const exp3 = true != false; // TODO: ADD YOUR EVALUATION HERE --> - +console.log(true != false); const exp4 = "10" === 10; // TODO: ADD YOUR EVALUATION HERE --> - +console.log("10" === 10); const exp5 = 5 > 4; // TODO: ADD YOUR EVALUATION HERE --> - +console.log(5 > 4); const exp6 = null == undefined; // TODO: ADD YOUR EVALUATION HERE --> - +console.log(null == undefined); const exp7 = "true" == true; // TODO: ADD YOUR EVALUATION HERE --> - +console.log("true" == true); const exp8 = "false" == false; // TODO: ADD YOUR EVALUATION HERE --> - +console.log("false" == false); const exp9 = NaN === NaN; // TODO: ADD YOUR EVALUATION HERE --> - +console.log(NaN === NaN); const exp10 = !false || false; // TODO: ADD YOUR EVALUATION HERE --> - +console.log(!false || false); const exp11 = false && !false; // TODO: ADD YOUR EVALUATION HERE --> - +console.log(false && !false); const exp12 = "apple" > "pineapple"; // TODO: ADD YOUR EVALUATION HERE --> - +console.log("apple" > "pineapple"); const exp13 = "2" > "12"; // TODO: ADD YOUR EVALUATION HERE --> - +console.log("2" > "12"); const exp14 = undefined == null; // TODO: ADD YOUR EVALUATION HERE --> - +console.log(undefined == null); const exp15 = undefined === null; // TODO: ADD YOUR EVALUATION HERE --> - +console.log(undefined === null); /******************************************************************************* Task 2: In the following tasks, you will practice using logical operators in JavaScript, in addition to some strings methods. @@ -47,33 +49,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(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 != false); // - 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 ==10 && 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 || num % 5 ); // - Check if str contains the letter "e". Log the result to the console. // TODO: ADD YOUR CODE BELOW - +console.log(num % 3 || num % 5 ); // - Check if str starts with "Hakuna". Log the result to the console. // TODO: ADD YOUR CODE BELOW - +console.log(str.includes("e")); // - 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 - +divBy2= num % 2; +console.log(num < 0 || divBy2 > 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); \ No newline at end of file diff --git a/variables.js b/variables.js index b970f30..25c25af 100644 --- a/variables.js +++ b/variables.js @@ -15,7 +15,10 @@ 2. Use console.log() to output the value of each variable. ********************************************************************************/ // TODO: ADD YOUR CODE BELOW - +let personName = "khadeeja"; +let age = 23; +let isHappy = true; +console.log(personName, age,isHappy ); /******************************************************************************* Task 2 (Reassigning variables): @@ -24,7 +27,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,7 +37,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 myFavMovie = "Howl's Moving Castel"; +let userAge ; /******************************************************************************* Task 4 (String Concatenation): Build upon the previous task by completing the following steps: @@ -49,3 +54,6 @@ Steps: 5. 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 to ${personName}, and btw, why are you happy ?`); +let finalMsg = msg; +console.log(`Dear ${personName.toUpperCase()}, here's your message:${finalMsg} `) \ No newline at end of file