-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
54 lines (40 loc) · 1020 Bytes
/
script.js
File metadata and controls
54 lines (40 loc) · 1020 Bytes
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
//defining variables with let and const
let age = 15;
let year = 2020;
const pi = 22/7
console.log(age, year);
console.log(pi)
age = 10;
year = 2023;
console.log(age, year);
//concatenation
//using the "+" to concatenate
let text = "totally";
console.log("I " + text + " would use this")
//using the template strings
console.log(`This is ${text} better trust me!`)
//math operators and methods
const num = 10;
console.log(num <= 10)
console.log(num + 10)
console.log(num ** 2)
console.log(num/5)
console.log(num % 4)
//string methods
const test = "Jessica"
console.log(test.length);
console.log(test[2])
console.log(test.concat("hi"))
console.log(test.toUpperCase())
console.log(test.toLocaleLowerCase())
console.log(test.includes("i"))
console.log(test.indexOf(2))
//array methods
const arr = [1,2,3,4,5]
console.log(arr.join([7, 9]))
console.log(arr.length)
console.log(arr.push(10))
console.log(arr.pop())
console.log(arr.slice(0,3))
console.log(arr.splice(1,5))
console.log(arr.indexOf(2))