← Back to challenges

Next Perfect Square

JavaScriptHardalgebramathnumbersinterview

Instructions

Mubashir needs your help to find next integral perfect square after the one passed as a parameter.

Create a function which takes a given number n and returns next integral perfect square number. Return null if the given number is not a perfect square.

Examples

nextSquare(121) ➞ 144

nextSquare(625) ➞ 676

nextSquare(114) ➞ null
// 114 is not a perfect square

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Buggy Code (Part 6)