-
-
Save lynn/f57bdb8f4e53fe36b914377bb7ba1dc8 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
var code = document.getElementById('code'); code.addEventListener('keyup', e => { | |
const v = code.value | |
const d = document.getElementById('debug') | |
if (v.length >= 2) { | |
for (var i = 0; i < v.length - 2; i++) { | |
if (! ((v[i]<v[i+1]&&v[i+1]>v[i+2]) || (v[i]>v[i+1]&&v[i+1]<v[i+2]))) { | |
d.value = 'Not bumpy! ' + v[i] + v[i+1] + v[i+2] | |
return | |
} | |
} | |
const ascii = new Array(95).fill(0).map((x,i)=>String.fromCharCode(i+32)) | |
if (v[v.length-2] < v[v.length-1]) { | |
d.value = 'Next: ' + ascii.filter(c => v[v.length-1] > c).join`` | |
} else { | |
d.value = 'Next: ' + ascii.filter(c => v[v.length-1] < c).join`` | |
} | |
} else { d.value = '' } | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment