SoftwareSeni interview question

Solving test cases in JavaScript