SHARE
TWEET

Untitled

a guest Sep 17th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ORP: Optimal Recgonition Point
  2. function getORPIndex(word) {
  3.     var length = word.length;
  4.     var lastChar = word[word.length - 1];
  5.     if (lastChar == '\n') {
  6.         lastChar = word[word.length - 2];
  7.         length--;
  8.     }
  9.     if (',.?!:;"'.indexOf(lastChar) != -1) length--;
  10.     return length <= 1 ? 0 : (length == 2 ? 1 : (length == 3 ? 1 : Math.floor(length / 2) - 1));
  11. }
  12.  
  13. "you should do it again and again for as much time as you needs!".split(" ")
  14.     .map(t => [i=getORPIndex(t), t])
  15.     .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))
  16.     .map(t => console.log(t))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top