Ultra small code using Functional Programming

Photo by Pankaj Patel on Unsplash

Introduction

545678 -> True45654  -> True12345  -> True13573  -> False12145  -> False

Step 1: Split digits

1. number.toString()2. String(number)3. number + ""
string.split('');
[...string]
1. parseInt()2. Number()3. Unary + operator
const str = '123';
const num = +str;
arr.map(e => +e)
arr.map(Number)
[...input+""].map(Number)
12345
[1, 2, 3, 4, 5]

Step 2: Core logic

Conclusion

Coder, content creator. Admin of @baby_wolf_codes

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store