0
0
Javascriptprogramming~10 mins

Throwing errors in Javascript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to throw a new error with the message "Oops!".

Javascript
throw new [1]("Oops!");
Drag options to blanks, or click blank then click option'
AError
BException
CMessage
Dthrow
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using 'throw' as a type instead of a keyword.
Using 'Exception' which is not a built-in JavaScript error type.
Using 'Message' which is not an error type.
2fill in blank
medium

Complete the code to throw a TypeError with the message "Invalid type".

Javascript
throw new [1]("Invalid type");
Drag options to blanks, or click blank then click option'
AError
BSyntaxError
CTypeError
DReferenceError
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using SyntaxError which is for syntax issues.
Using ReferenceError which is for undefined variables.
Using generic Error instead of TypeError.
3fill in blank
hard

Fix the error in the code to correctly throw a RangeError with message "Out of range".

Javascript
throw [1]("Out of range");
Drag options to blanks, or click blank then click option'
ARangeError
Bnew RangeError
Cnew Error
DError
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Omitting the 'new' keyword causes a TypeError.
Using just the error type without 'new' is incorrect.
Using generic Error instead of RangeError.
4fill in blank
hard

Fill both blanks to throw a SyntaxError with message "Syntax is wrong".

Javascript
throw [1]([2]);
Drag options to blanks, or click blank then click option'
Anew SyntaxError
B"Syntax is wrong"
CSyntaxError
D'Syntax is wrong'
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Not using 'new' before the error type.
Passing the message without quotes.
Using the error type without 'new'.
5fill in blank
hard

Fill both blanks to throw a ReferenceError with message "Variable not found".

Javascript
throw [1]([2]);
Drag options to blanks, or click blank then click option'
AReferenceError
B"Variable not found"
Cnew ReferenceError
D'Variable not found'
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Omitting 'new' keyword.
Passing message without quotes.
Using wrong error type.