Report the type of the window object.
Acceptance criteria
- 1.#out should show object.
JavaScript Tutorial · JavaScript Storage & BOM
These 10 tasks go with the JavaScript window Object chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “window represents the browser tab and is the top of the global scope.” .
1.Check the window typeexercise · easy · 10 min
Report the type of the window object.
Passes when: #out should show object.
2.Show a var attaches to windowexercise · easy · 10 min · practice plan
Declare a global var and read it from window.
Passes when: #out should show 5.
3.Show let does not attachexercise · easy · 10 min · practice plan
Declare a let and show window does not have it.
Passes when: #out should show not on window.
4.Read the viewport widthexercise · easy · 10 min · practice plan
Report whether the window has a positive width.
Passes when: #out should show positive.
5.Check for alertexercise · medium · 10 min · practice plan
Report the type of window.alert.
Passes when: #out should show function.
6.Fix var expected to stay off windowbug fix · easy · 8 min
var does attach to window, unlike let.
Passes when: #out should show on window.
7.Fix the wrong case used for a global functionbug fix · easy · 8 min · practice plan
JavaScript names are case sensitive, and setTimeout is not the same as setTimeOut.
Passes when: #out should show function.
8.Fix the var read before it existsbug fix · easy · 8 min · practice plan
The variable is read on the line above where it is declared.
Passes when: #out should show 5.
9.Fix the width compared to a non-numeric stringbug fix · easy · 8 min · practice plan
Comparing a number against text that is not numeric coerces to NaN, and any comparison with NaN is false.
Passes when: #out should show positive.
10.Fix document compared to the wrong windowbug fix · easy · 8 min · practice plan
document belongs to this window, not to a freshly built object.
Passes when: #out should show same document.
Between them these tasks cover window, Global scope and var vs let.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.