File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 17
17
| Problem - 13 | Write a function to check if an object is empty or not in javaScript? |
18
18
| Problem - 14 | Write a function to remove array element based on object property? |
19
19
| Problem - 15 | Get the Middle Character |
20
- <!-- | Problem - 15 | | -->
20
+ | Problem - 16 | Generate random boolean in JavaScript |
21
+ <!-- | Problem - 16 | | -->
Original file line number Diff line number Diff line change
1
+ // get random boolean (true/ false)
2
+
3
+ console . log ( Math . random ( ) >= 0.5 ) ;
4
+ console . log ( Math . random ( ) < 0.1 ) ; //10% probability of getting true
5
+ console . log ( Math . random ( ) < 0.4 ) ; //40% probability of getting true
6
+ console . log ( Math . random ( ) < 0.5 ) ; //50% probability of getting true
7
+ console . log ( Math . random ( ) < 0.8 ) ; //80% probability of getting true
8
+ console . log ( Math . random ( ) < 0.9 ) ; //90% probability of getting true
You can’t perform that action at this time.
0 commit comments