File tree 5 files changed +69
-0
lines changed
5 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Duck Duck Goose 🪿
2
+ // Codédex
3
+
4
+ let randomNumber = Math . floor ( Math . random ( ) * 10 ) ;
5
+
6
+ while ( randomNumber != 7 ) {
7
+ console . log ( "Duck 🦆" ) ;
8
+ randomNumber = Math . floor ( Math . random ( ) * 10 ) ;
9
+ }
10
+
11
+ console . log ( "Goose! 🪿" ) ;
Original file line number Diff line number Diff line change
1
+ // Lucky Number 🍀
2
+ // Codédex
3
+
4
+ const luckyNumber = Math . floor ( Math . random ( ) * 10 ) + 1 ;
5
+ let guess = Math . floor ( Math . random ( ) * 10 ) + 1 ;
6
+
7
+ while ( guess != luckyNumber ) {
8
+ console . log ( `${ guess } is not it.` )
9
+ let guess = Math . floor ( Math . random ( ) * 10 ) + 1 ;
10
+ }
11
+
12
+ console . log ( `You got it! The lucky number was ${ luckyNumber } ` ) ;
Original file line number Diff line number Diff line change
1
+ // I Solemnly Swear 🗺️
2
+ // Codédex
3
+
4
+ for ( let i = 0 ; i < 100 ; i ++ ) {
5
+ console . log ( "I Solemnly Swear That I Am Up To No Good" ) ;
6
+ }
7
+
8
+ console . log ( "We Are Proud To Present The World of Programming!" ) ;
Original file line number Diff line number Diff line change
1
+ // Even The Odds 2️⃣
2
+ // Codédex
3
+
4
+ for ( let i = 1 ; i <= 50 ; i ++ ) {
5
+ if ( i % 2 == 1 ) {
6
+ continue ;
7
+ } else if ( i == 42 ) {
8
+ console . log ( i ) ;
9
+ break ;
10
+ } else {
11
+ console . log ( i ) ;
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ // Based Numbers ⫴
2
+ // Codédex
3
+
4
+ const myNumber = 30 ;
5
+ let binary = "" ;
6
+
7
+ // With for loop
8
+ for ( let i = myNumber ; i >= 1 ; i = Math . floor ( i / 2 ) ) {
9
+ if ( i % 2 == 0 ) {
10
+ binary = "0" + binary
11
+ } else {
12
+ binary = "1" + binary ;
13
+ }
14
+ }
15
+
16
+ // With while loop
17
+ while ( myNumber >= 1 ) {
18
+ if ( i % 2 == 0 ) {
19
+ binary = "0" + binary ;
20
+ } else {
21
+ binary = "1" + binary ;
22
+ }
23
+
24
+ i = Math . floor ( i / 2 ) ;
25
+ }
You can’t perform that action at this time.
0 commit comments