• in
InterCourses
CoursesBlogs
0
← Introduction to JavaScript
○What is JavaScript?○Your First JavaScript Code○Data Types○Type Checking○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
●Conditionals○Demo: Combined Conditions Before FizzBuzz○Challenge: FizzBuzz Announcer○Switch Statement○Demo: Switch a Venue Sign○Challenge: Power Loadout○For Loops○While Loop○Break and Continue○Demo: Stop a Ticket Scan○Challenge: Number Guess Referee○Demo: Rainfall Routing Walkthrough○Exercise: Score Batch Report✦Module Quiz
○Defining Functions○Arrow Functions○Scope○Closures○Project - Calculator○Function Expressions○Demo: Ticket Pricing Walkthrough○Exercise: Shipping Labels with Defaults○Demo: Seat Ledger Closure Walkthrough○Exercise: Private Budget Ledger✦Module Quiz
○Arrays○Demo: 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○Demo: Charging Rack Restock Report○Exercise: Pantry Restock Plan✦Module Quiz
○Object Key-Value Pairs○Student Course Record○Object Methods and Destructuring○Map and Set Collections○Playlist Lookup○Number and BigInt Boundaries○Ticket Ledger○JSON○Math and Date○Date Basics○Demo: Supply Bin Audit○Exercise: Volunteer Shift Audit○Demo: Workshop Attendance Feed○Exercise: Parcel Scan Feed✦Module Quiz
○String Methods○Template Literals○Regular Expressions○Demo: Build a Reminder with Template Literals○Exercise: Format Pantry Pickup Messages○Demo: Validate a Time Slot with Regex○Exercise: Validate Storage Shelf Labels✦Module Quiz
○Higher-Order Functions○Callbacks○map, filter, and reduce○Demo: Student Register with map○Challenge: Student Register○Recursion○Project - Data Transform Pipeline○Demo: Handle an Error-First Callback○Exercise: Report Seat Reservation Results○Demo: Summarize Completed Bike Rides○Exercise: Summarize Delivered Parcels✦Module Quiz
○Demo: A notebook object○OOP Introduction○Demo: Independent workshop passes○Classes○Demo: An inherited notice○Inheritance○Demo: A private seat counter○Encapsulation○Demo: Equipment desk checkout○Project: Library Checkout✦Module Quiz
○Demo: Callback Timing○Exercise: Asynchronous JavaScript○Demo: Promise Rehearsal○Exercise: Promises and Async Await○Demo: Offline API Coordination○Exercise: Async API Simulation○Demo: Partial Results Bulletin○Project: Resilient Awards Feed○Demo: Retry a Local Delivery○Project: Reliable Score Delivery✦Module Quiz

Conditionals

Mission: Decision Desk

This section teaches a script to choose between outcomes. Keep the work in script.js and check results in the Console.

Conditional statements let your program make decisions. score >= 90 asks whether a number is at least 90 and yields true or false. JavaScript tests branches from top to bottom; only the first matching branch runs. Put the highest threshold first so 95 does not get classified by a lower one.

Syntax

javascript
if (condition) {
    // runs when condition is true
} else if (anotherCondition) {
    // runs when first was false but this is true
} else {
    // runs when none of the above matched
}

A named calculation

The task asks for a function even though the dedicated Functions module comes next. For now, read function name(input) { ... } as a reusable calculation: the input takes a different value on each call, and return sends back its result. This separate example uses a different rule:

javascript
function accessLevel(age) {
  if (age >= 18) return "adult";
  return "minor";
}
console.log(accessLevel(20)); // adult

Use the same function shape to classify scores, but use else if for the intermediate grade thresholds. The shorthand ? : appears later; you do not need it here.

Your Task

  1. Implement getGrade(score) to return A, B, C, D, or F for the 90/80/70/60 cutoffs (otherwise F). The provided Grade 95 probe should print Grade 95: A.
  2. Log Grade set: A,B,C,D,F by calling getGrade for 95, 85, 75, 65, and 50.
  3. Log Grade boundaries: A,B,D by calling getGrade for 90, 80, and 60.
  4. Log Grade: B by calling getGrade(85).
Hint 1
1 / 3
HINT 1

Use if (score >= 90) to check for grade A.

HINT 2

Chain else if for each grade boundary.

HINT 3

The final else covers any score below 60.

Loading editor…
Press Run to execute your code.
READY
intercourses
javascript