Created
October 6, 2021 12:18
-
-
Save adarsh-chakraborty/963f706fc619f3345ce0fc3fa9d07db6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const states = [ | |
{ | |
from: 1, | |
to: 20, | |
stateName: 'Andhra Pradesh' | |
}, | |
{ | |
from: 21, | |
to: 40, | |
stateName: 'Arunachal Pradesh' | |
}, | |
{ | |
from: 41, | |
to: 60, | |
stateName: 'Assam' | |
}, | |
{ | |
from: 61, | |
to: 80, | |
stateName: 'Bihar' | |
}, | |
{ | |
from: 81, | |
to: 100, | |
stateName: 'Chhattisgarh' | |
}, | |
{ | |
from: 101, | |
to: 120, | |
stateName: 'Goa' | |
}, | |
{ | |
from: 121, | |
to: 140, | |
stateName: 'Gujarat' | |
}, | |
{ | |
from: 141, | |
to: 160, | |
stateName: 'Haryana' | |
}, | |
{ | |
from: 161, | |
to: 180, | |
stateName: 'Himachal Pradesh' | |
}, | |
{ | |
from: 181, | |
to: 200, | |
stateName: 'Jharkhand' | |
}, | |
{ | |
from: 201, | |
to: 220, | |
stateName: 'Karnataka' | |
}, | |
{ | |
from: 221, | |
to: 240, | |
stateName: 'Kerala' | |
}, | |
{ | |
from: 241, | |
to: 260, | |
stateName: 'Madhya Pradesh' | |
}, | |
{ | |
from: 261, | |
to: 280, | |
stateName: 'Maharashtra' | |
}, | |
{ | |
from: 281, | |
to: 300, | |
stateName: 'Manipur' | |
}, | |
{ | |
from: 301, | |
to: 320, | |
stateName: 'Meghalaya' | |
}, | |
{ | |
from: 321, | |
to: 340, | |
stateName: 'Mizoram' | |
}, | |
{ | |
from: 341, | |
to: 360, | |
stateName: 'Nagaland' | |
}, | |
{ | |
from: 361, | |
to: 380, | |
stateName: 'Odisha' | |
}, | |
{ | |
from: 381, | |
to: 400, | |
stateName: 'Punjab' | |
}, | |
{ | |
from: 401, | |
to: 420, | |
stateName: 'Rajasthan' | |
}, | |
{ | |
from: 421, | |
to: 440, | |
stateName: 'Sikkim' | |
}, | |
{ | |
from: 441, | |
to: 460, | |
stateName: 'Tamil Nadu' | |
}, | |
{ | |
from: 461, | |
to: 480, | |
stateName: 'Telangana' | |
}, | |
{ | |
from: 481, | |
to: 500, | |
stateName: 'Tripura' | |
}, | |
{ | |
from: 501, | |
to: 520, | |
stateName: 'Uttar Pradesh' | |
}, | |
{ | |
from: 521, | |
to: 540, | |
stateName: 'Uttarakhand' | |
}, | |
{ | |
from: 541, | |
to: 560, | |
stateName: 'West Bengal' | |
}, | |
{ | |
from: 561, | |
to: 580, | |
stateName: 'Andaman and Nicobar Islands' | |
}, | |
{ | |
from: 581, | |
to: 600, | |
stateName: 'Chandigarh' | |
}, | |
{ | |
from: 601, | |
to: 620, | |
stateName: 'Dadra & Nagar Haveli and Daman & Diu' | |
}, | |
{ | |
from: 621, | |
to: 640, | |
stateName: 'Delhi' | |
}, | |
{ | |
from: 641, | |
to: 660, | |
stateName: 'Jammu and Kashmir' | |
}, | |
{ | |
from: 661, | |
to: 680, | |
stateName: 'Lakshadweep' | |
}, | |
{ | |
from: 681, | |
to: 700, | |
stateName: 'Puducherry' | |
}, | |
{ | |
from: 701, | |
to: 720, | |
stateName: 'Ladakh' | |
} | |
]; | |
let userInput = 82; | |
let flag = null; | |
for (let currentState of states) { | |
if (userInput >= currentState.from && userInput <= currentState.to) { | |
flag = currentState.stateName; | |
break; | |
} | |
} | |
console.log(flag); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment