Skip to content

Instantly share code, notes, and snippets.

@arryanggaputra
Created November 26, 2019 01:32
Show Gist options
  • Save arryanggaputra/f02719284ef9f21277acba0dcfd20082 to your computer and use it in GitHub Desktop.
Save arryanggaputra/f02719284ef9f21277acba0dcfd20082 to your computer and use it in GitHub Desktop.
get leasePlan words
getLeasePlanWords(100)
// 1,Lease,3,Lease,Plan,Lease,7,Lease,9,LeasePlan,11,Lease,13,Lease,Plan,Lease,17,Lease,19,LeasePlan,21,Lease,23,Lease,Plan,Lease,27,Lease,29,LeasePlan,31,Lease,33,Lease,Plan,Lease,37,Lease,39,LeasePlan,41,Lease,43,Lease,Plan,Lease,47,Lease,49,LeasePlan,51,Lease,53,Lease,Plan,Lease,57,Lease,59,LeasePlan,61,Lease,63,Lease,Plan,Lease,67,Lease,69,LeasePlan,71,Lease,73,Lease,Plan,Lease,77,Lease,79,LeasePlan,81,Lease,83,Lease,Plan,Lease,87,Lease,89,LeasePlan,91,Lease,93,Lease,Plan,Lease,97,Lease,99,LeasePlan
function getLeasePlanWords(range) {
if (range < 1 || range > 100) {
throw 'Range only 1-100'
}
words = ''
for (let index = 1; index <= range; index++) {
let isModulus = false
if (index % 2 == 0) {
words += 'Lease'
isModulus = true
}
if (index % 5 == 0) {
words += 'Plan'
isModulus = true
}
if (!isModulus) {
words += index
}
words += ','
}
return words
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment