topskill.dev
CoursesTracks
0
All courses/Introduction to JavaScriptScore Batch Report
Control Flow
16 / 17
← Introduction to JavaScript
○What is JavaScript?○Your First JavaScript Code○Data Types○Type Checking○Missing values and deliberate emptiness○Inspect Values in the Console○Inspect the Queue Report○Trace a Faulty Calculation○Repair the Score Calculation✦Module Quiz
○Declaring Variables○let and const in Practice○Operators○Type Conversion○Group and Convert Expense Inputs○Calculate the Event Expense Total○Track a Changing Points Tally○Adjust a Ticket Price✦Module Quiz
○Comparisons and strict equality○Truthiness and combined conditions○Function inputs and results○Conditionals○Combined Conditions Before FizzBuzz○Challenge: FizzBuzz Announcer○Switch Statement○Switch a Venue Sign○Challenge: Power Loadout○For Loops○While Loop○Break and Continue○Stop a Ticket Scan○Challenge: Number Guess Referee○Rainfall Routing Walkthrough●Score Batch Report✦Module Quiz
○Defining Functions○Arrow Functions○Scope○Closures○Project - Calculator○Function Expressions○Ticket Pricing Walkthrough○Shipping Labels with Defaults○Seat Ledger Closure Walkthrough○Private Budget Ledger✦Module Quiz
○Arrays○Student Scoreboard○Challenge: Student Course Scoreboard○Array Mutation Methods○Array Slice and Concat○Array Iteration Methods○Multidimensional Arrays○Destructuring○Array Reverse and Sort○Array Fill○Array Find and Includes○Array Flat and FlatMap○Array Reduce, Some, and Every○Charging Rack Restock Report○Pantry Restock Plan✦Module Quiz
○Object Key-Value Pairs○Student Course Record○Object Methods and Destructuring○Object copies and optional properties○Map and Set Collections○Playlist Lookup○Number and BigInt Boundaries○Ticket Ledger○JSON○Throwing and catching errors○Math and Date○Date Basics○Supply Bin Audit○Volunteer Shift Audit○Workshop Attendance Feed○Parcel Scan Feed✦Module Quiz
○String Methods○Template Literals○Regular Expressions○Build a Reminder with Template Literals○Format Pantry Pickup Messages○Validate a Time Slot with Regex○Validate Storage Shelf Labels✦Module Quiz
○Higher-Order Functions○Callbacks○map, filter, and reduce○Student Register with map○Challenge: Student Register○Recursion○Project - Data Transform Pipeline○Extend the inventory report○Handle an Error-First Callback○Report Seat Reservation Results○Summarize Completed Bike Rides○Summarize Delivered Parcels✦Module Quiz
○A notebook object○OOP Introduction○Independent workshop passes○Classes○An inherited notice○Inheritance○A private seat counter○Encapsulation○Equipment desk checkout○Project: Library Checkout✦Module Quiz
○Callback Timing○Asynchronous JavaScript○Promise Rehearsal○Promises and Async Await○Offline API Coordination○Async API Simulation○Partial Results Bulletin○Project: Resilient Awards Feed○Retry a Local Delivery○Project: Reliable Score Delivery✦Module Quiz

Score Batch Report

Turn the rain-routing loop from the demo into a score report for an after-school workshop. A score of 60 or more passes; a score of 90 or more also earns honors. Visit every score to count both categories, then return one summary string. Work only in script.js; Run shows your checkpoints in the Console.

A different example

A separate loop over library returns shows the same visit-and-decide rhythm without giving away the score report:

javascript
const daysLate = [0, 3, 1];
let overdue = 0;
for (const days of daysLate) {
  if (days > 0) overdue += 1;
}
console.log(`Overdue books: ${overdue}`);

The starter separates the two counts so you can finish and check one outcome at a time. Each helper takes the score list, starts a counter at 0, visits every entry, and returns the counter after the loop. summarizeScores then formats the two returned counts. Calling a helper from another function uses the same parentheses as calling it in console.log.

Honors scores also count as passes. The categories overlap; do not remove a score from one count because it belongs to the other. These helpers each scan the list once. You could combine the two checks in a single loop later, but keeping them separate here lets you test them independently.

A score exactly at a cutoff qualifies. An empty list should return a count of 0 because the loop has no entries to visit. Keep the report formatting in summarizeScores, rather than having the counting helpers print it.

Edit script.js, Run to inspect the supplied probes, and Submit to check the tasks.

Your Task

  1. Implement countPassed(scores) with a loop that counts scores at least 60. The supplied Passed counts line should show 3,0,2.
  2. Implement countHonors(scores) with a loop that counts scores at least 90. The supplied Honors counts line should show 1,0,2.
  3. Implement summarizeScores(scores) to return Passed: N | Honors: N using both helpers. The supplied report probes cover the workshop, an empty batch, and the thresholds.

Section complete

You can now classify individual values and scan a batch without stopping at its first entry. The next section explains function inputs, results, and scope in more detail.

Hint 1
1 / 1
HINT 1

Start each counter at zero inside its helper, and return after the loop.

Take the Quiz →
Files
  • ⋄script.js
Loading editor…
Press Run to execute your code.