0% found this document useful (0 votes)
42 views

Homework Introduction To Programming Basics

This document provides practice exercises on programming basics. It contains 4 questions - the first asks the learner to evaluate comparisons and return true or false, the second asks the learner to evaluate expressions, the third asks the learner to write a script adding two numbers, and the fourth asks the learner to write a script concatenating and displaying a full name. Hints are provided on folder structure for files.

Uploaded by

Abdurahim Amin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Homework Introduction To Programming Basics

This document provides practice exercises on programming basics. It contains 4 questions - the first asks the learner to evaluate comparisons and return true or false, the second asks the learner to evaluate expressions, the third asks the learner to write a script adding two numbers, and the fourth asks the learner to write a script concatenating and displaying a full name. Hints are provided on folder structure for files.

Uploaded by

Abdurahim Amin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Introduction to programming basics - Practice exercise

Question 1: Find out the answers for these by displaying it on the console. You will need to
compare the value on the left of the operator with the value on the right. Please note that
the answer for each question below should be either True or False.
A. 24 > 3
B. 2 < "12"
C. 0 == 2
D. 2.0 === 2
E. 2.0 == "2"
F. 2 < "John"
G. 2 > "John"
H. "2" < "2"
I. "2" > "12"
J. 1 == 1 || 3 == 2 || 3 == 7
K. 1 == 1 && 2 == 2 && 3 == 7
L. 1 == 1 || 2 == 2 && 3 == 7
M. 1 == true && 0 > true || "31" > "9" || 10 > 5 || !("2" == "two" || 1 == "1")

Note:
● To see the answers for each question, you will need to use the console. For example, for the
Question 1(A), write your code like this: console.log(4 > 3)
● When you meet in groups with your friends, please make sure to discuss the reason why the
answer for each question is either true or false.

Question 2: Answer the following questions. Make sure to think about each question and
try to solve it in your brain before you see the result on the console.
1. Which expression returns true?
A/ ‘1’ === 1
B/ 1 == 1
C/ 1 === 1
D/ B and C from above
2. What is the value of x in this statement?
let x = (1 == true);
A/ 1
B/ true
C/ false
D/ undefined
3. What is the value of y from the following statements?
let x = 10;
let y = (x > 5) && (x < 15)
A/ 10
B/ 5
C/ 15
D/ true
4. What is the value of x from the following statements?
let x = 5;
x += 3;
A/ 3
B/ 8
C/ 15
D/ 5
5. What is the value of y from the following statements?
let x = 10;
let y = x++;
A/ 10
B/ 11
C/ 12
D/ 13
6. What is the value of y in the following statements?
let x = 1;
let y = (x !== 2);
A/ 1
B/ 2
C/ false
D/ true
7. What is the output of (+”2”+2)?
8. What is the output of (7 % 3)?
9. What is the output of (2+true)?

Question 3:
● Write a simple script that adds 1 and 2 and displays the result on the console
● Use variables a, b & c
● Use "let" to declare the variables
● Use the formula c = a + b
● Display the value of c on console

Question 4:
● Create a variable to hold your first name
● Create another variable to hold your last name
● Create a third variable to hold your full name
● Assign the value of your first name and last name to the first two variable
● Use "+" to concatenate your first name and last name to assign the result to your last name's
variable
● Don't forget to include space between your first and last name
● Display the value of your full name on the console

Hint on how to organize your folders and files

● Create a folder called “Programming Basics” in your Evangadi folder


● Inside your “Programming Basics” folder, create an html file called “index.html”.
● Inside your “Programming Basics” folder, create a folder called “JS”. Inside of your
“JS” folder, create a file called “script.js”
● Link your “script.js” file in your HTML. We have learned that a JS file can be included
in your HTML either in your HTML’s <head> </head> tag or at the bottom in
<body></body>. Use one of the methods and include your JS file in your HTML.
● Before you start writing your code, always test if your JavaScript file is linked correctly
to your HTML. To test if your JS file is loaded correctly, type the following code and see
if you get this alert message on your browser;
○ alert("your JS file is connected!!");
● To check the result of each code you write in the console, you will need to open your
“index.html” file in browser, right click the page and select “inspect” and select
“console”
● Now start working on your assignment. Happy coding!

You might also like