-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfonctions.html
More file actions
44 lines (36 loc) · 950 Bytes
/
Copy pathfonctions.html
File metadata and controls
44 lines (36 loc) · 950 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
// on créer un nombre entre 0 & 10
// 3 essaie pour deviner le mot
// isRight(n)
//guess
function getRandomInt(max){
return Math.floor(Math.random() * (max + 1))
}
const solution = getRandomInt(10)
console.log(solution)
function isRight(n){
return solution === n
}
function guess(){
const number = prompt('Entrez un nombre: ') * 1
return isRight(number)
}
for (i = 0; i < 3; i++){
if (guess()){
console.log('Bravo')
break
}else if(i === 2){
console.log("Perdu")
}
}
</script>
</head>
<body>
</body>
</html>