-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathciber.html
More file actions
124 lines (92 loc) · 2.98 KB
/
Copy pathciber.html
File metadata and controls
124 lines (92 loc) · 2.98 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exercici JavaScript Bàsics</title>
</head>
<body>
<!-- HTML para Exercici 8 -->
<label>Please enter number:</label>
<br>
<input type="number" id="input1">
<br><br>
<label>Please enter on of the following operators (+ , - , * , / ):</label>
<br>
<input type="text" id="operator">
<br><br>
<label>Please enter number:</label>
<br>
<input type="number" id="input2">
<br>
<br>
<p id="output"></p>
<button onclick="calc()">Click</button>
<script>
///////////////////////////////////////////////////////// Exercici 1:
console.log('Hola mundo');
///////////////////////////////////////////////////////// Exercici 2:
// alert('¡Me llamo Sam!');
///////////////////////////////////////////////////////// Exercici 3:
let firstName = 'Sam';
let lastName = 'Saedy'
console.log(`${firstName} ${lastName}`);
///////////////////////////////////////////////////////// Exercici 4:
let num1 = 34;
let num2 = 56;
let sum = num1 + num2;
console.log(`La suma entre ${num1} i ${num2} es ${sum}`);
///////////////////////////////////////////////////////// Exercici 5:
let nota_examen = 4;
if (nota_examen < 5) {
alert('Lo siento, no apto!', nota_examen);
} else if (nota_examen >= 5 && nota_examen <= 7) {
alert('Apto!', nota_examen);
} else if (nota_examen >= 8 && nota_examen <= 10) {
alert('Enhorabuena!', nota_examen);
} else {
alert('nota invalida!');
}
///////////////////////////////////////////////////////// Exercici 6:
let color = 'culur';
let verde = 'blau';
console.log(`Tinc un cotxe de ${color} ${verde}`);
///////////////////////////////////////////////////////// Exercici 7:
let arr = ['taula', 'cadira', 'ordinador', 'libreta'];
for (let i = 0; i < arr.length; i++) {
console.log('L\' objecte', arr[i], 'esta a la posicio', i, '.');
}
///////////////////////////////////////////////////////// Exercici 8:
function calc() {
let input1 = parseInt(document.getElementById('input1').value);
let input2 = parseInt(document.getElementById('input2').value);
let operator = document.getElementById('operator').value;
let message;
if (operator === "+") {
sum();
} else if (operator === "-") {
min();
} else if (operator === "*") {
multiply();
} else if (operator === "/") {
divide();
} else {
message = 'Please enter a valid operator!';
}
function sum() {
message = input1 + input2;
}
function min() {
message = input1 - input2;
}
function multiply() {
message = input1 * input2;
}
function divide() {
message = input1 / input2;
}
document.getElementById('output').innerHTML = message;
}
</script>
</body>
</html>