-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathvariables.js
More file actions
67 lines (60 loc) · 3.16 KB
/
Copy pathvariables.js
File metadata and controls
67 lines (60 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*******************************************************************************
These tasks will provide you with an opportunity to practice creating and manipulating variables,
as well as using string concatenation and getting familiar with different datatypes.
// Have fun! //😃
********************************************************************************/
/*******************************************************************************
Task 1 (Variables):
Steps:
1. Create three variables named 'personName', 'age', and 'isHappy', where:
- 'personName' should hold a string value
- 'age' should hold a numeric value
- 'isHappy' should hold a boolean value.
2. Use console.log() to output the value of each variable.
********************************************************************************/
// TODO: ADD YOUR CODE BELOW
let personName = "mohammedhassan";
let age = 12;
let isHappy = false;
console.log(personName)
console.log(age)
console.log(isHappy)
/*******************************************************************************
Task 2 (Reassigning variables):
Steps:
1. Create a new variable named 'nickName' and assign the value of the 'personName' variable to the 'nickName' variable.
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):
Steps:
1. Create a variable with the title of your favorite movie. How would you name such a variable?
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 monkieKid ;
let UserAge ;
/*******************************************************************************
Task 4 (String Concatenation):
Build upon the previous task by completing the following steps:
Steps:
1. Declare a new variable called 'msg'.
2. Use the `prompt()` function to ask the user to enter a message for the person you just created. Then assign the value to the `msg` variable.
3. Use string concatenation to create a message
- If 'isHappy' is true, add the question "And btw, Why are you happy?" to the message.
- If 'isHappy' is false, add the response "And btw, Good for you. There's nothing to be happy about." to the message
- Assign the completed message to a variable called finalMsg
- 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 ();
let finalMsg
if(isHappy == true){
finalMsg = msg + " And btw, Why are you happy?"
} else if (isHappy == false){
finalMsg = msg + " And btw, Good for you. There's nothing to be happy about."
}
console.log(`Dear ${personName.toUpperCase()}, here's your message: ${finalMsg}`)