Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ORP: Optimal Recgonition Point
- function getORPIndex(word) {
- var length = word.length;
- var lastChar = word[word.length - 1];
- if (lastChar == '\n') {
- lastChar = word[word.length - 2];
- length--;
- }
- if (',.?!:;"'.indexOf(lastChar) != -1) length--;
- return length <= 1 ? 0 : (length == 2 ? 1 : (length == 3 ? 1 : Math.floor(length / 2) - 1));
- }
- "you should do it again and again for as much time as you needs!".split(" ")
- .map(t => [i=getORPIndex(t), t])
- .map(i => "\033[30m ".slice(0,-(i[0]+1)) + i[1].slice(0, i[0]) + "\033[31m" + i[1][i[0]] + "\033[30m" + i[1].slice(i[0]+1))
- .map(t => console.log(t))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement