furthered work

This commit is contained in:
2024-10-03 11:29:13 -05:00
parent fa7ac2949b
commit 1e756f4f72
15 changed files with 301 additions and 93 deletions

View File

@ -1,6 +1,7 @@
<html><body><script>
function sayHi() {
console.log("Hi!");
}
setTimeout(sayHi, 2000);
<html><pre id="log"></pre><body><script>
!function(){var n=document.getElementById("log");console.log=function(){for(var i=0;i<arguments.length;i++)"object"==typeof arguments[i]?n.innerHTML+=(JSON&&JSON.stringify?JSON.stringify(arguments[i],void 0,2):arguments[i])+"<br />":n.innerHTML+=arguments[i]+"<br />"}}();
function sayHi() {
console.log("Hi!");
}
setTimeout(sayHi, 2000);
</script></body></html>

View File

@ -1,19 +1,19 @@
A function with no parameters that prints how many times its
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()
A function with no parameters that prints how many times its
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>

View File

@ -1,11 +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()
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>

View File

@ -1,51 +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)
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>

12
5/wrapper.html Normal file
View File

@ -0,0 +1,12 @@
<html><body><script>
function makeWrapper (prefix, suffix) {
return function (string){
console.log(prefix + string + suffix)
return prefix + string + suffix
}
}
let itsawrap = makeWrapper("[","]")
itsawrap("let me out")
</script></body></html>