or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
JavaScript Challenges
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →No.1: Write a function that can…
Return the string "I am a function"
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Hint: this function doesn't need to be passed any arguments!
Should return something like:
"I am a function"
No.2: Write a function that can…
Take a number as an argument, and return a new value that is 1 less than the argument.
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →For example, if I called your function like so
yourFunction(23);
it should return
22
No.3: Write a function that can…
Speak back to you!
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →So
argumentRepeater("Lemon");
should return
"Lemon"
No.4: Write a function that can…
Take two numbers as arguments, and return the sum of them
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →For example, if you call your function like this:
addTwoNumbers(12, 56);
should return
68
No.5: Write a function that can…
Say who it was written by!
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Your function should take a name as an argument, and return the string "This function was written by ____"
So
yourFunction("Charlie");
should return
"This function was written by Charlie"
Hint: the "+" key may come in handy…
No.6: Write a function that can…
Take 4 numbers as arguments. It should take the sum of the first two arguments, multiply it by the sum of the last two arguments, and return the result
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →So
yourFunction(2, 3, 6, 4);
should return
50
Hint: using multiple variables inside the statement of your function might make things easier…
No.7: Write a function that can…
Take a string as an argument, and return the length (how many characters) of that string.
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →So
yourFunction("How long is this string?");
should return
24
Hint: This freeCodeCamp challenge may help you if you're stuck, or try reading up in the MDN docs
No.8: Write a function that can …
Take a number as an argument and returns half that number
So
yourFunction(42)
should return
21
and
yourFunction(11)
should return
5.5
No.9: Write a function that can …
Take two numbers as arguments.
If both arguments are equal, return the string
"The first and second arguments are equal"
If the arguments are not equal, return the string
"The first argument ___ does not equal the second argument ___ "
.So
yourFunction(1, 1)
should return
"The first and second arguments are equal"
and
yourFunction(1, 2)
should return
"The first argument 1 does not equal the second argument 2"
Hint: You'll need to use an
if
statement…No.10: Write a function that can …
Take two numbers as an argument and returns the smallest one.
So
yourFunction(11, 2)
should return
2
and
yourFunction(1, -111)
should return
-111
No.11: Write a function that can …
Take three numbers and returns
true
if the numbers are ascending in size, and false otherwise.So
yourFunction(1, 4, 9)
should return
true
and
yourFunction(4, 1, 10)
should return
false
No.12: Write a function that can …
Concatenate two strings.
So
yourFunction('hi ', 'there')
should return
'hi there'
No.13 Write a function that can …
Take an array and a number and return the element of the array at that index. If the number is not a valid index, return
null
.So
yourFunction([7, 3, 5], 2)
should return
5
and
yourFunction([0, 5, 3], 9)
should return
null
Hint: you will need to find the length of the array first, remember zero indexing…
No.14 Write a function that can …
Take an object, a string, and another value.
If the object contains a key that matches the string, return the value corresponding to that key.
If the object does not contain a key that matches the string, return the third argument.
So
yourFunction({ name: 'felicia', age: 23 }, 'age', 0)
should return
23
and
yourFunction({ name: 'felicia', age: 23 }, 'nickname', 'none')
should return
'none'
No.15 Write a function that can …
Take an object whose values are all numbers, and return the sum of those numbers
So
yourFunction({ a: 12, b: -4, c: 0.4 })
should return
8.4