current work
This commit is contained in:
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