← Back to challenges

Next Happy Year

JavaScriptHardalgorithmsnumbersloopslogic

Instructions

Mubashir needs your help to find out the next happy year.

A Happy Year is the year with only distinct digits. Create a function that takes an integer year and returns the next happy year.

Examples

happyYear(2017) ➞ 2018
// 2018 has all distinct digits

happyYear(1990) ➞ 2013

happyYear(2021) ➞ 2031

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.