Home
Tracks
Reset
Help
Theebug — Learn JavaScript by Doing
Light
Explorer
···
▼
THEEBUG
lesson1.js
lesson2.js
lesson3.js
lesson4.js
lesson5.js
lesson6.js
lesson7.js
lesson8.js
lesson9.js
lesson10.js
lesson11.js
Completed
0/11
Score
0
JS
lesson11.js
×
THEEBUG
›
lesson11.js
1
function
parseNumber
(
str
)
{
2
try
{
3
return
JSON
.
parse
(
str
)
;
4
______
(
err
)
{
5
return
null
;
6
}
7
}
8
9
console
.
log
(
parseNumber
(
"42"
)
)
;
// 42
10
console
.
log
(
parseNumber
(
"invalid"
)
)
;
// null
TERMINAL
PROBLEMS
OUTPUT
DEBUG CONSOLE
⊕
⋮
$
[system] Theebug ready. Happy coding!
Code Blocks
Drag blocks into the drop zones above
4 blocks available
catch
except
error
finally
Game Panel
0:00
0 pts
Level 11 of 11
Error Handling
0/1 slots correct
Objective
Complete the try/catch so a parsing failure returns null instead of crashing
Expected Output
42
null
Debug says:
Code that might fail goes in try. Which keyword catches the error if it throws?
Debug the Worm