Report the type of navigator.onLine.
Acceptance criteria
- 1.#out should show boolean.
JavaScript Tutorial · JavaScript Storage & BOM
These 10 tasks go with the JavaScript navigator 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: “navigator describes the browser and device running the page.” .
1.Check the online state typeexercise · easy · 10 min
Report the type of navigator.onLine.
Passes when: #out should show boolean.
2.Read the languageexercise · easy · 10 min · practice plan
Report the type of navigator.language.
Passes when: #out should show string.
3.Check for a featureexercise · easy · 10 min · practice plan
Write a function that checks for clipboard support.
Passes when: #out should show supported.
4.Check languages is a listexercise · easy · 10 min · practice plan
Report whether navigator.languages is an array.
Passes when: #out should show a list.
5.Check userAgent existsexercise · medium · 10 min · practice plan
Report the type of navigator.userAgent.
Passes when: #out should show string.
6.Fix the type check invertedbug fix · easy · 8 min
The check for a boolean was written backwards.
Passes when: #out should show a real boolean.
7.Fix the browser name checked instead of the featurebug fix · easy · 8 min · practice plan
Checking for the feature itself is more reliable than the browser name.
Passes when: #out should show found the feature.
8.Fix languages read as one stringbug fix · easy · 8 min · practice plan
navigator.languages is a list of preferences, not a single string.
Passes when: #out should show confirmed a list.
9.Fix clipboard called before checking for itbug fix · easy · 8 min · practice plan
Test for the feature before relying on it, in case it is missing.
Passes when: #out should show was checked.
10.Fix the wrong case used for onLinebug fix · easy · 8 min · practice plan
The property is spelled onLine with a capital L.
Passes when: #out should show boolean.
Between them these tasks cover navigator, Feature detection and onLine.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.