← Back to challenges

Nth Even Number

JavaScriptHardmathnumberslanguage_fundamentals

Instructions

Create a function that takes a number n and returns the nth even number beginning with 0 as the first.

Examples

nthEven(1) ➞ 0
// 0 is first even number

nthEven(2) ➞ 2
// 2 is second even number

nthEven(100) ➞ 198

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Nth Star Number