Skip to content

Commit ac8ef3b

Browse files
authored
Create Reamde.md
0 parents  commit ac8ef3b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# JavaScript-snippets
2+
JavaScript Snippets
3+
4+
```javascript
5+
// Returns a random number between min (inclusive) and max (exclusive)
6+
7+
const getRandomNumber = (min, max) => Math.random() * (max - min) + min;
8+
9+
getRandomNumber(2, 10)
10+
11+
// Returns a random number between min (inclusive) and max (inclusive)
12+
13+
const getRandomNumberInclusive =(min, max)=> {
14+
min = Math.ceil(min);
15+
max = Math.floor(max);
16+
return Math.floor(Math.random() * (max - min + 1)) + min;
17+
}
18+
19+
getRandomNumberInclusive(2, 10);
20+
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy