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

Diff for: README.md

+20
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)