Skip to content

Commit

Permalink
section 7 : functions exercices
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeeppy committed Apr 15, 2023
1 parent 03cf587 commit 8c69ce1
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
12 changes: 12 additions & 0 deletions session7/exercice1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exercice 1</title>
</head>
<body>
<script src="exercice1.js"></script>
</body>
</html>
13 changes: 13 additions & 0 deletions session7/exercice1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function abracadabra() {
let first_name = prompt("First name ?");
let last_name = prompt("Last name ? ");
let age = prompt("Age ?");

alert("Sapristi ! On ne m'avait pas prévenu que c'était vous, "
+ first_name
+ " ! Euh... Je veux dire... Monsieur le grand magicien "
+ last_name
+ " ! Cela fait déjà ${age} ans que vous faites rayonner notre contrée !.")
}

abracadabra();
12 changes: 12 additions & 0 deletions session7/exercice2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exercice 2</title>
</head>
<body>
<script src="exercice2.js"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions session7/exercice2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function bodyMassIndex(mass, height) {
// Height in meters
metersHeight = Number(height) / 100;
let bmi = mass / Math.pow(Number(height) / 100, 2);
return bmi
}

let mass = prompt("Mass (kg)?");
let height = prompt("Height (cm)?")

alert(bodyMassIndex(mass, height));

0 comments on commit 8c69ce1

Please sign in to comment.