Skip to content
Foxipa
Code Completion 8 Challenges

JavaScript Global Object & Standard Global Functions — Code Completion

Practice the remaining standard global access and function APIs.

~12 min read

Challenge 1

Access the global object without assuming a browser global name.

javascript Your answer
const root = globalThis;

Press Ctrl⌘Enter to check your answer

Challenge 2

Check whether a value is globally finite.

javascript Your answer
const value = "42";
console.log(isFinite(value));

Press Ctrl⌘Enter to check your answer

Challenge 3

Check for NaN using the Number-specific predicate.

javascript Your answer
const value = NaN;
console.log(Number.isNaN(value));

Press Ctrl⌘Enter to check your answer

Challenge 4

Parse a binary integer explicitly.

javascript Your answer
const value = parseInt("101", 2);

Press Ctrl⌘Enter to check your answer

Challenge 5

Parse the leading decimal number from a string.

javascript Your answer
const value = parseFloat("12.5px");

Press Ctrl⌘Enter to check your answer

Challenge 6

Encode a complete URI.

javascript Your answer
const value = encodeURI("https://example.test/a path?q=hello world");

Press Ctrl⌘Enter to check your answer

Challenge 7

Encode one URI component.

javascript Your answer
const value = encodeURIComponent("hello world&next=yes");

Press Ctrl⌘Enter to check your answer

Challenge 8

Decode one URI component.

javascript Your answer
const value = decodeURIComponent("hello%20world%26next%3Dyes");

Press Ctrl⌘Enter to check your answer