-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclassroom.js
53 lines (42 loc) · 1020 Bytes
/
classroom.js
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
// javasript to check if a number is positive or negative
var num = prompt();
if ( num == 0 ){
console.log('then it is zero')
}
else if ( num > 0 ){
console.log('then it is positive')
}
else {
console.log('it is negative')
}
// javasript to alert biggest number among three numbers
var num = prompt() ;
var num2 = prompt() ;
var num3 = prompt() ;
if (num > num2){
console.log(alert(num))
}
else if (num2 > num3){
console.log(alert(num2));
}
else {
console.log(alert(num3));
}
// javascript to tell if a number is even or odd
var num = prompt();
if (num % 2 == 0 ){
console.log('The number is even')
}
else if ( num % 2 != 0 ){
console.log('The number is odd')
}
// the length of an array
var cars = ['volvo' , 'Benz' , 'Camry'];
console.log(cars.length);
// or
var cars = ['volvo' , 'Benz' , 'Camry'];
document.write(cars.length);
// replacing a string using an array property
var name = 'Hello my name is Daniel';
var nam = name.replace('Daniel', 'Baptist');
console.log(nam)