-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculatrice.js
60 lines (46 loc) · 1.34 KB
/
calculatrice.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
54
55
56
57
const nombre1 = document.getElementById("nombre1")
const nombre2 = document.getElementById("nombre2")
const resultat = document.getElementById("resultat")
function doAddition (a, b){
return a+b
}
function doSoustraction (a, b){
return a-b
}
function doMultiplication(a, b){
return a*b
}
function doDivision (a, b){
return a/b
}
function convertStringToNumber(string) {
return Number(string)
}
function effacer() {
nombre1.value = ""
nombre2.value = ""
}
const addition = function() {
resultat.innerHTML = "";
resultat.innerHTML = `Resultat: nombre1 + nombre2 = ${
doAddition(convertStringToNumber(nombre1.value), convertStringToNumber(nombre2.value))
}`;
}
const soustraction = function() {
resultat.innerHTML = "";
resultat.innerHTML = `Resultat: nombre1 + nombre2 = ${
doSoustraction(convertStringToNumber(nombre1.value), convertStringToNumber(nombre2.value))
}`;
}
const multiplication = function(event) {
resultat.innerHTML = "";
resultat.innerHTML = `Resultat: nombre1 + nombre2 = ${
doMultiplication(convertStringToNumber(nombre1.value), convertStringToNumber(nombre2.value))
}`;
}
const division = function(event) {
resultat.innerHTML = "";
resultat.innerHTML = `Resultat: nombre1 + nombre2 = ${
doDivision(convertStringToNumber(nombre1.value), convertStringToNumber(nombre2.value))
}`;
}