-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindexTwo.html
More file actions
45 lines (36 loc) · 1.04 KB
/
Copy pathindexTwo.html
File metadata and controls
45 lines (36 loc) · 1.04 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Foundations 3 </title>
</head>
<body>
<p>JS code Q1 - 4</p>
<script>
//JS code adds 7 to any number
function add7(num){
console.log(num + 7);
};
add7(10);
//JS code multiplies to given numbers
function multiply(a, b){
console.log(a * b);
};
multiply(4, 5);
//JS code capitalizes the first letter of any word
function capitalized(a){
let wholeWord = a[0].toUpperCase();
let remainingLetters = a.slice(1).toLowerCase();
console.log(wholeWord + remainingLetters);
};
capitalized("DaRkVoid");
//JS code takes a string and returns the very last letter
function lastLetter(a){
let word = a.slice(-1);
console.log(word);
};
lastLetter("Spongebob");
</script>
</body>
</html>