From 249acd9f34e5da0b14ce4d881f28f6172b3c5d2e Mon Sep 17 00:00:00 2001 From: LSvekis Date: Thu, 1 Jul 2021 16:45:13 -0400 Subject: [PATCH] Create math fun --- Chapter 11/math fun | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Chapter 11/math fun diff --git a/Chapter 11/math fun b/Chapter 11/math fun new file mode 100644 index 0000000..75a9735 --- /dev/null +++ b/Chapter 11/math fun @@ -0,0 +1,14 @@ +console.log(Math.PI); +console.log(Math.ceil(5.7)); +console.log(Math.floor(5.7)); +console.log(Math.round(5.7)); +console.log(Math.random()); +console.log(Math.floor(Math.random()*11)); // 0-10 +console.log(Math.floor(Math.random()*10)+1); // 1-10; +console.log(Math.floor(Math.random()*100)+1); // 1-100; +for (let x = 0; x < 100; x++) { + console.log(ranNum(1, 100)); +} +function ranNum(min, max) { + return Math.floor(Math.random() * (max - min + 1)) + min; +}