current work
This commit is contained in:
		
							
								
								
									
										13
									
								
								4/cointoss.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								4/cointoss.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| <html><body><script> | ||||
|  | ||||
|     let coin = 0 | ||||
|     coin = Math.random() | ||||
|     console.log(coin) | ||||
|     if (coin >= .5){  | ||||
|         console.log("tails") | ||||
|     } | ||||
|     if (coin < .5){ | ||||
|         console.log("heads") | ||||
|     } | ||||
|  | ||||
| </script></body></html> | ||||
							
								
								
									
										7
									
								
								4/forarray.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								4/forarray.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| <html><body><script> let colors = ["Red", "Green", "Blue"]; for (let [index, item] of colors.entries()) { | ||||
|  | ||||
|     console.log(`${index}: ${item} is a color.`); | ||||
|      | ||||
|     } | ||||
|      | ||||
|     </script></body></html> | ||||
							
								
								
									
										9
									
								
								4/forof.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								4/forof.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| <html><body><script> | ||||
|  | ||||
|     let colors = ["Red", "Green", "Blue"]; for (let color of colors) { | ||||
|      | ||||
|     console.log(`${color} is a color.`); | ||||
|      | ||||
|     } | ||||
|      | ||||
| </script></body></html> | ||||
							
								
								
									
										12
									
								
								4/if.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								4/if.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| <html> | ||||
|     <body> | ||||
|     <script> let speed = 30; | ||||
|  | ||||
|     console.log(`Your current speed is ${speed} mph.`); | ||||
|      | ||||
|     if (speed > 25) { | ||||
|      | ||||
|     console.log("Slow down!"); | ||||
|      | ||||
|     } | ||||
| </script></body></html> | ||||
							
								
								
									
										17
									
								
								4/ifelse.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								4/ifelse.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| <html><body><script> | ||||
|  | ||||
|     let speed = 20; | ||||
|      | ||||
|     console.log(`Your current speed is ${speed} mph.`); | ||||
|      | ||||
|     if (speed > 25) { | ||||
|      | ||||
|     console.log("Slow down!"); | ||||
|      | ||||
|     } else { | ||||
|      | ||||
|     console.log("You're obeying the speed limit."); | ||||
|      | ||||
|     } | ||||
|      | ||||
|     </script></body></html> | ||||
							
								
								
									
										8
									
								
								4/jonarrayforof.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								4/jonarrayforof.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <html> | ||||
| <body> | ||||
| <script> | ||||
| let name = "jonathan" | ||||
| for (let [a, letter] of name.split("").entries()){ | ||||
|     console.log(`${a} ${letter}`) | ||||
| } | ||||
| </script></body></html> | ||||
							
								
								
									
										8
									
								
								4/jonathanarrayfor.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								4/jonathanarrayfor.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <html> | ||||
| <body> | ||||
| <script> | ||||
| let name = "Branan" | ||||
| for  (let [i, letter] of name.split("").entries()){ | ||||
|     console.log(`${i} ${letter}`) | ||||
| } | ||||
| </script></body></html> | ||||
							
								
								
									
										11
									
								
								4/sayhello.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								4/sayhello.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| <html><body><script> | ||||
| function sayHello(name){ | ||||
|     return `Hello ${name}, it is good to see you.` | ||||
| } | ||||
| let a = sayHello("jon".toLocaleUpperCase()) | ||||
|  | ||||
| console.log(a) | ||||
| // sayHello("meli") | ||||
| // sayHello("sammie") | ||||
| // sayHello("lucy") | ||||
| </script></body></html> | ||||
							
								
								
									
										11
									
								
								4/while.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								4/while.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| <html> | ||||
| <body> | ||||
| <script> | ||||
| let speed = 50; | ||||
| while (speed > 25) { | ||||
| console.log(`Your current speed is ${speed} mph.`); | ||||
| speed--; | ||||
| } | ||||
| console.log(`Now your speed is ${speed} mph.`); | ||||
|  | ||||
| </script></body></html> | ||||
							
								
								
									
										6
									
								
								5/function.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								5/function.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| <html><body><script> | ||||
| function sayHi() { | ||||
|  console.log("Hi!"); | ||||
| } | ||||
| setTimeout(sayHi, 2000); | ||||
| </script></body></html> | ||||
							
								
								
									
										19
									
								
								5/functioncalledcallback.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								5/functioncalledcallback.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| A function with no parameters that prints how many times it’s | ||||
| been called. Hint: define a variable outside of the function to | ||||
| keep track of the number of calls, like we did in the “Side | ||||
| Effects” section on page 77. | ||||
| <html><body><script> | ||||
| let a = 0 | ||||
| let b = 0 | ||||
| let c = 0 | ||||
|  | ||||
| function calledcallback (){a++;console.log(`calledcallback calls: ${a}`)} | ||||
|  | ||||
| callback = function () {b++;console.log(`callback calls: ${b}`)} | ||||
|  | ||||
| cb = () => {c++;console.log(`cb calls: ${c}`)} | ||||
|  | ||||
| calledcallback() | ||||
| callback() | ||||
| cb() | ||||
| </script></body></html> | ||||
							
								
								
									
										11
									
								
								5/functiondate.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								5/functiondate.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| A function that prints the current date and time. Hint: you can | ||||
| get the current date and time with new Date(). | ||||
| <html><body><script> | ||||
| function datetime (){let t = Date();console.log(t)} | ||||
| date = function () {let t = Date();console.log(t)} | ||||
| d = () => {let t = Date();console.log(t)} | ||||
|  | ||||
| datetime() | ||||
| date() | ||||
| d() | ||||
| </script></body></html> | ||||
							
								
								
									
										51
									
								
								5/functionnumberdic.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								5/functionnumberdic.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| A function that takes a number from 0 to 5 and returns the | ||||
| English word for that number. For example, 1 should return "one". | ||||
| Hint: use an array to define the mapping from numbers to | ||||
| strings. | ||||
| <html><body><script> | ||||
| function numdict (numb) { | ||||
|     dict = { | ||||
|         0 : "Zero", | ||||
|         1 : "One", | ||||
|         2 : "Two", | ||||
|         3 : "Three", | ||||
|         4 : "Four", | ||||
|         5 : "Five" | ||||
|     } | ||||
|     word = dict[numb] | ||||
|     console.log(word) | ||||
|     return word | ||||
| } | ||||
|  | ||||
| let numberdictionary = function (numb) { | ||||
|     dict = { | ||||
|         0 : "Zero", | ||||
|         1 : "One", | ||||
|         2 : "Two", | ||||
|         3 : "Three", | ||||
|         4 : "Four", | ||||
|         5 : "Five" | ||||
|     } | ||||
|     word = dict[numb] | ||||
|     console.log(word) | ||||
|     return word | ||||
| } | ||||
|  | ||||
| let nd = (numb) => { | ||||
|     dict = { | ||||
|         0 : "Zero", | ||||
|         1 : "One", | ||||
|         2 : "Two", | ||||
|         3 : "Three", | ||||
|         4 : "Four", | ||||
|         5 : "Five" | ||||
|     } | ||||
|     word = dict[numb] | ||||
|     console.log(word) | ||||
|     return word | ||||
| } | ||||
|  | ||||
| numdict(1) | ||||
| numberdictionary(2) | ||||
| nd(3) | ||||
| </script></body></html> | ||||
		Reference in New Issue
	
	Block a user