From 32bb1e73dc1bb67b115a12149b6c61cd0019f9f3 Mon Sep 17 00:00:00 2001 From: amanullahakhundzada Date: Fri, 12 Aug 2022 10:17:43 -0700 Subject: [PATCH] js --- README.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ app.js | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 20 +++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 README.md create mode 100644 app.js create mode 100644 index.html diff --git a/README.md b/README.md new file mode 100644 index 0000000..c9efa32 --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# JavaScript_Operators + +## Steps + +1. Fork this repository to start a new project in your repos folder => `git clone ` +2. cd JavaScript_Operators to navigate into your new repo directory +3. Type the command code . to open VSC with the JavaScript_Operators folder +4. Open the app.js file + +## Exercise 1 + +1. Declare 2 variables, `a` and `b`, and assign 20 to `a` and 4 to `b` +2. Declare a variable `add` that uses the `+` operator to store the result of adding the values stored in `a` and `b` +3. Declare a variable `minus` that uses the `-` operator to store the result of subtracting the values stored in `a` and `b` +4. Declare a variable `multiply` that uses the `*` operator to store the result of multiplying the values stored in `a` and `b` +5. Declare a variable `dividing` that uses the `/` operator to store the result of dividing the values stored in `a` and `b` + +You can print the value of the variables to the browser console (ex: `console.log(add)`) to check the result. + +## Exercise 2 + +1. Use the following code to answer the questions below: + +``` +let num = 11; +let str = "11"; +let str2 = "eleven"; +let isPresent = true; +let firstName = "Frodo"; +let lastName = "Baggins"; +``` + +- What is the value of: num + str? +- What is the value of: num + str2? +- What is the value of: num + isPresent? +- What is the value of: firstName + num? +- What is the value of: isPresent + str? +- What is the value of: firstName + lastName? + +Use the code above to test and print the results. + +## Exercise 3 + +1. Use the following code to answer the questions below: + +``` +let val = 5; +let str3 = "5"; +let str4 = "five"; +let isPresent = false; +``` + +- What is the value of: val == str3? +- What is the value of: val === str3? +- What is the value of: !isPresent? +- What is the value of: (“eleven” == str4 && val >= str3)? +- What is the value of: (!isPresent || isPresent)? +- What is the value of: 0 == false? +- What is the value of: 0 === false? +- What is the value of: 0 != false? +- What is the value of 0 !== false? + +Use the code above to test and print the results. diff --git a/app.js b/app.js new file mode 100644 index 0000000..b6dc847 --- /dev/null +++ b/app.js @@ -0,0 +1,59 @@ +console.log("Hello World!\n==========\n"); +console.log( + "Follow the steps in the README.md file to complete the exercises:\n==========\n" +); + +// Exercise 1 +console.log("EXERCISE 1:\n==========\n"); + +// YOUR CODE HERE +var a; +var b; +a=20; +b=4; +var add = a+b; +var minus= a-b; +var multipy=a*b; +var dividing=a/b; +console.log(add); +console.log(minus); +console.log(multipy); +console.log(dividing); + + +// Exercise 2 +console.log("EXERCISE 2:\n==========\n"); + + +// YOUR CODE HERE +let num =11; +let str ="11"; +let str2 ="eleven"; +let isPresent =true; +let firstName = "Fardo"; +let lastName = "Baggins"; +console.log( "What is the value of: num + str?",num+str); +console.log(" What is the value of: num + str2?" ,num+str2); +console.log( "What is the value of: num + isPresent? " ,num+isPresent); +console.log("What is the value of: firstName + num? " , firstName+num); +console.log(" What is the value of: isPresent + str?" , isPresent+str); +console.log( " What is the value of: firstName + lastName?" ,firstName+lastName); + + +// Exercise 3 +console.log("EXERCISE 3:\n==========\n"); + +// YOUR CODE HERE +let val = 5; +let str3 = "5"; +let str4 = "five"; +let isPresent2 = false; +// console.log("What is the value of: val == str3 ? ", val == str3); +// console.log(" What is the value of: !isPresent2 ?", !isPresent2 ); +// console.log("What is the value of: (“str2” == str4 && val >= str3)?", “str2” == str4 && val >= str3); +// console.log("What is the value of: (!isPresent2 || isPresent)? ", !isPresent2 || isPresent ); +// console.log(" What is the value of: 0 == false?", 0 == false ); +// console.log("What is the value of: 0 === false? ", 0 === false ); +// console.log(" What is the value of: 0 != false?", != false); +// console.log("What is the value of 0 !== false? ", !== false); +// console.log("What is the value of: val === str3? ", val === str3 ); \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..4f510b9 --- /dev/null +++ b/index.html @@ -0,0 +1,20 @@ + + + + + + JavaScript Operators + + +
+
+

Exercises: JavaScript Variables

+

+ Open the Browser Console to view your work (Right-Click => Inspect or + fn+F12) +

+
+
+ + +