Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Static Method

Object-Oriented Programmingmedium

Course · Section 14: Object-Oriented Programming (OOP) With JavaScript · Lecture 228: Static Methods

Using a class with a static `range(n)` method, implement `staticRange(n)` returning `[0, 1, ..., n-1]`.

Sample tests

Input: staticRange(3)
Output: [0,1,2]
Input: staticRange(0)
Output: []

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Calling a static method on an instance fails.
Approach & explanation (try first)

A static method is a class-level utility invoked without an instance.

Loading...
⌘/Ctrl + Enter

Run your code to see results.