Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
46 lines (39 loc) · 1.73 KB
/
Copy pathscript.js
File metadata and controls
46 lines (39 loc) · 1.73 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
// Template literal
/* Do the following:
- Define a variable named `username` using `const` keyword and assign your name as a value.
- Define another variable named `bio` and assign a value `Learning to code`. Use `let` keyword to define the variable.
*/
const username = `Rockey`;
let bio = `Learning to code`;
let firstName = "Arya";
let lastName = "Stark";
/* Do the following using `+` operator
- Alert message saying `I am [username] and my bio is [bio]`. Replace square brackets with the value of variable.
- Alert the message `I'm Arya Stark of Winterfell` using the variable name firstName and lastName.
*/
alert("I am" + " " + username + " " + "and my bio is" + " " + bio);
alert ("I\'m" + " " + firstName + " " + lastName + " " + "of Winterfell");
/* Do the following using string template literal
- Alert message saying `I am [username] and my bio is [bio]`. Replace square brackets with the value of variable.
- Alert the message `I'm Arya Stark of Winterfell` using the variable name firstName and lastName.
*/
alert (`I am ${username} and my bio is ${bio}`);
alert (`I'm ${firstName} ${lastName} of Winterfell`);
let amount = 200;
const taxPercent = 10;
/* Use string template literal:
- Alert a message saying `The total amount is [amount]
the tax amount is [(amount * taxPercent) / 100]
`
- Above message should be in two lines
*/
alert(`The total amount is ${amount}
the tax amount is ${(amount * taxPercent) / 100}`);
/* Use double quote and escape character:
- Alert a message saying `The total amount is [amount]
the tax amount is [(amount * taxPercent) / 100]
`
- Above message should be in two lines
*/
alert ("The total amount is" + " " + amount +
"\nthe tax amount is" + " " + ((amount * taxPercent) / 100));