Search Header Logo

[AP CSP] JavaScript Programming Quiz

Authored by Tommy Nguyen

Computers

9th - 12th Grade

Used 25+ times

[AP CSP] JavaScript Programming Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

14 questions

Show all answers

1.

OPEN ENDED QUESTION

10 mins • 2 pts

Media Image

👈 Given the File Directory Shown...

Type the Line of Code that links🔗

the JavaScript Code to HTML Script.

Evaluate responses using AI:

OFF

2.

OPEN ENDED QUESTION

10 mins • 2 pts

Media Image

👈 Given the Webpage and HTML code...

Type the JavaScript Code inside the parkview( ) function that will change the text displayed in the paragraph tag to "Go Panthers"?

Evaluate responses using AI:

OFF

3.

OPEN ENDED QUESTION

3 mins • 2 pts

Media Image

👈 Given the Webpage and HTML code...

Type the JavaScript Code inside the teacher( ) function that will change the bear.png image to MrHW.png image

when the button is clicked?

Evaluate responses using AI:

OFF

4.

MULTIPLE CHOICE QUESTION

10 mins • 1 pt

Media Image

Read the following code carefully.

Then, select the prompt that best describes what this program does.

Counts how many total pairs of double letters appear across all words.

Counts how many words contain at least one pair of consecutive identical letters.

Counts the total letters in all words that appear twice in a row.

Counts how many words have exactly two letters total.

Counts how many letters repeat twice in total.

Answer explanation

💡 Brief Explanation

  • The code checks each word for any two consecutive identical letters (word[i] == word[i + 1]).

  • If such a pair exists, it increases count by 1 and breaks, ensuring each word only contributes once.

  • For ["apple", "tree", "banana", "grape", "book"], the words with double letters are "apple", "tree", and "book".

  • Output: 3

  • Therefore, the function counts how many words contain at least one pair of consecutive identical letters.

5.

MULTIPLE CHOICE QUESTION

10 mins • 1 pt

Media Image

Read the following code carefully.

Then, select the prompt that best describes what this program does.

Returns the sum of all positive even numbers in the list.

Returns the sum of all negative numbers in the list.

Returns the sum of the absolute values of all negative even numbers.

Returns how many even numbers appear in the list.

Returns absolute value of all negative even numbers.

Answer explanation

💡 Brief Explanation

  • The function loops through each number n in the list.

  • It checks two conditions: n % 2 == 0 (even) and n < 0 (negative).

  • If both are true, it adds the absolute value of that number (abs(n)) to total.

  • For [4, -3, -6, 7, -8, 2, -9], the negative even numbers are -6 and -8.

  • Their absolute values are 6 + 8 = 14. The function returns 14.

  • So it correctly returns the sum of the absolute values of all negative even numbers.

6.

OPEN ENDED QUESTION

3 mins • 1 pt

Media Image

What is the output of this code?

Evaluate responses using AI:

OFF

Answer explanation

💡 Brief Explanation

  • The program starts with total = 0 and loops through nums.

  • It skips negative numbers (-3) and stops when it hits the first zero (0).

  • It adds only the positive numbers before the zero → 2 + 5 + 4 = 11.

  • The loop then breaks at zero, so the remaining numbers (6) are never added.

7.

OPEN ENDED QUESTION

3 mins • 1 pt

Media Image

What is the output of this code?

Evaluate responses using AI:

OFF

Answer explanation

💡 Brief Explanation

  • The program loops through each word in word_list.

  • For every word, it counts occurrences of "a".

  • When it reaches a word containing "z", it breaks completely (stops checking any remaining words).

Code Trace:

  • "apple" → 1 "a" → total = 1

  • "banana" → 3 "a"s → total = 4

  • "grape" → 1 "a" → total = 5

  • "zebra" → 1 "a", but "z" triggers break after this word → total = 6

  • "avocado" → not checked (loop already broken)

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?