Is This Date a Weekend?
Updated
Problem statement
Given a valid calendar date date in exact YYYY-MM-DD form, return true if it falls on Saturday or Sunday. Return false if it falls on Monday through Friday.
Interpret the date with the proleptic Gregorian calendar. The result depends only on the calendar date, not on a time zone or locale.
Function
isWeekend(date: String) → booleanExamples
Example 1
date = "2024-06-15"return = trueJune 15, 2024 is a Saturday, so the result is true.
Example 2
date = "2024-06-17"return = falseJune 17, 2024 is a Monday, so the result is false.
Example 3
date = "2000-01-02"return = trueJanuary 2, 2000 is a Sunday, so the result is true.
Constraints
datehas exactly ten characters inYYYY-MM-DDform.- The year is between
0001and9999, inclusive. dateis valid under the proleptic Gregorian calendar.
More Salesforce Online Assessment questions
- Count Subarrays With Product Equal to KOA · Seen Nov 2026
- Get Minimum TimeOA · Seen Nov 2026
- Minimum No-Repeat Segments After One Character RemovalOA · Seen Nov 2026
- Get Message StatusOA · Seen Nov 2026
- Minimum Unique-Character Segments After DeletionOA · Seen Sep 2026
- Run-Length String CompressionOA · Seen Sep 2026
- Maximum Requests in WindowOA · Seen Sep 2026
- Final Pod Counts After LogsOA · Seen Aug 2026
- Minimum Removals to Balance ArrayOA · Seen Aug 2026
- Maximum Barbell WeightOA · Seen Jul 2026
Similar questions at other companies
- Polynomial CoefficientsShopify · OAShopify interview questions
- Balance a Chemical EquationMicrosoft · OAMicrosoft interview questions
- Simplify a Quadratic ExpressionOpenAI · OAOpenAI interview questions
- Smallest Value for a Linear Expression ModuloIntel · OA
- Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
- Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
- Most Cost-Effective MachineCapital One · ONSITE INTERVIEWCapital One interview questions
- Evaluate an Arithmetic Expression Written in WordsBrex · PHONE SCREEN
- Calculate a Token-List ExpressionCollege Vine · ONSITE INTERVIEW
- Parse, Normalize, and Combine PolynomialsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions