HomeTracks
Explorer···
THEEBUG
Completed0/11
Score0
JSlesson11.js×
THEEBUGlesson11.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
$[system] Theebug ready. Happy coding!
Code BlocksDrag blocks into the drop zones above
4 blocks available
catch
except
error
finally
Game Panel
0:000 pts
Level 11 of 11Error 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