JavaScript window Object — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript window Object lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Check the window type
easy10 minReport the type of the window object.
- 2
Show a var attaches to window
easy10 minDeclare a global var and read it from window.
- 3
Show let does not attach
easy10 minDeclare a let and show window does not have it.
- 4
Read the viewport width
easy10 minReport whether the window has a positive width.
- 5
Check for alert
medium10 minReport the type of window.alert.
Find the bug(5)
- 1
Fix var expected to stay off window
easy8 minvar does attach to window, unlike let.
- 2
Fix the wrong case used for a global function
easy8 minJavaScript names are case sensitive, and setTimeout is not the same as setTimeOut.
- 3
Fix the var read before it exists
easy8 minThe variable is read on the line above where it is declared.
- 4
Fix the width compared to a non-numeric string
easy8 minComparing a number against text that is not numeric coerces to NaN, and any comparison with NaN is false.
- 5
Fix document compared to the wrong window
easy8 mindocument belongs to this window, not to a freshly built object.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace