CodeHS JavaScript Level 1 Exam Prep
Free practice questions

Free CHS-JS1 Practice Questions

10 exam-style questions with answers and explanations, straight from our 1,033-question bank. Tap an answer to check yourself. When you're ready, take the scored version in the free practice test.

Start the free practice test → ★★★★★4.9/5 from 2,400+ candidates · No signup

The CHS-JS1 exam has 45 questions and runs 1 hours 30 minutes.

These 10 free CHS-JS1 questions are organized by exam domain, so you can see how each part of the CodeHS JavaScript Level 1 blueprint is tested. Reveal the answer and explanation under each question.

Domain 1: Data Types and Operators

Question 1

A ticket counter receives adult and child quantities as text. It needs their numeric sum, without changing either original string, before comparing the total with a numeric capacity using ===. ```javascript let adultText = "12"; let childText = "3"; let total = /* expression */; ``` Select the expression that meets this requirement for any two text quantities representing integers from 0 through 999.

Show answer & explanation

Correct answer: C - Number(adultText) + Number(childText)

Question 2

A temperature display must report "LOW" only when a reading is numerically below its limit. Both arrive as valid numeric text. The code reports "LOW" for a reading of 12 and a limit of 9. ```javascript let reading = "12"; let limit = "9"; let label = "OK"; if (reading < limit) { label = "LOW"; } ``` The display must also work when the valid numeric strings change. What correction addresses the cause?

Show answer & explanation

Correct answer: D - Compare Number(reading) < Number(limit).

Question 3

A screen chooses between a supplied display name and a name returned by lookupName. The lookup records whether it was used. ```javascript let lookupUsed = false; function lookupName() { lookupUsed = true; return "Guest"; } let suppliedName = "Mira"; let displayName = suppliedName || lookupName(); ``` At the end, which displayName and lookupUsed combination is present?

Show answer & explanation

Correct answer: B - displayName is "Mira"; lookupUsed is false.

Domain 2: Conditionals

Question 4

In a robotics training simulator, an active emergency stop must produce "STOP", regardless of the other inputs. Otherwise, a closed guard and a start request together permit "RUN"; all remaining cases require "WAIT". The three parameters are Booleans. ```javascript function command(emergencyStop, guardClosed, startRequested) { if (guardClosed && startRequested) { return "RUN"; } else if (emergencyStop) { return "STOP"; } return "WAIT"; } ``` Which test call exposes a violation of the emergency-stop requirement?

Show answer & explanation

Correct answer: A - command(true, true, true)

Domain 3: Loops

Question 5

A sampling exercise uses this loop. The body changes only samples; there is no early exit. ```javascript let samples = 0; for (let position = 2; position < 11; position += 3) { samples++; } ``` A trace must account for both completed samples and evaluations of position < 11, including the check that ends the loop. Which trace is accurate?

Show answer & explanation

Correct answer: B - 3 samples; 4 condition evaluations

Question 6

A connection routine may make up to three attempts. attempts starts at 0 and counts completed attempts; connected starts as false and is updated after each attempt. Before starting another attempt, the loop must check that fewer than three have completed and that no connection has succeeded. One failed attempt must not end the routine, but one successful attempt must. Which while condition enforces that stopping rule for every possible sequence of successes and failures?

Show answer & explanation

Correct answer: D - while (attempts < 3 && !connected)

Domain 4: Program Structure

Question 7

A prepaid account uses this function to calculate the balance remaining after a purchase. The calculation is correct, but the calling code discards its result. ```javascript function remainingBalance(balance, price) { return balance - price; } let balance = 40; let price = 6; remainingBalance(balance, price); ``` Replace only the final statement so the account retains the returned balance and deducts the purchase price exactly once.

Show answer & explanation

Correct answer: D - balance = remainingBalance(balance, price);

Question 8

A developer is making a formatting-only edit to this function and must preserve the value assigned to banner. ```javascript function makeBanner() { // Use one space between the words. return "Ready now"; } let banner = makeBanner(); ``` Which single edit leaves that value unchanged?

Show answer & explanation

Correct answer: C - Indent the return statement by two additional spaces.

Domain 5: Error Handling

Question 9

A profile is allowed to omit its optional nickname. During review, a developer predicts that this script will stop because the object has no nickname property. ```javascript let profile = { name: "Lena" }; let alias = profile.nickname; let status = "loaded"; ``` What actually happens when the script runs?

Show answer & explanation

Correct answer: A - alias is undefined; status becomes "loaded".

Domain 6: Objects

Question 10

A dashboard stores two readings in an object. The channel variable can contain either "inlet" or "outlet", and the displayed value must follow that selection. ```javascript let readings = { inlet: 18, outlet: 27 }; let channel = "outlet"; ``` Choose the expression that reads the selected property for either permitted channel value, rather than merely succeeding for the value shown.

Show answer & explanation

Correct answer: B - readings[channel]

That's 10 of 1,033

The full bank has 1,023 more CHS-JS1 questions with explanations.

Continue in the free practice test →

View plans