x2311

Untitled

Jun 21st, 2021
31
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function alphabetPosition(text) {
  2. let a = text
  3. let g = 0
  4. let b = []
  5. var c = ""
  6. let t = 1
  7.  
  8. for (let i = 0; i < a.length; i++) {
  9. b[i] = a[i]
  10. }
  11.  
  12.  
  13. for (let i = 0; i < a.length; i++) {
  14.  
  15. g = a[i].charCodeAt(0)
  16.  
  17.  
  18. if ((g >= 65 && g <= 90) || (g >= 97 && g <= 122) ) {
  19. if(t!=1) c += " "
  20. t++
  21. if (g >= 65 && g <= 90) {
  22. c += g - 64
  23.  
  24. }
  25. if (g >= 97 && g <= 122) {
  26. c += g - 96
  27.  
  28. }
  29.  
  30. }
  31. }
  32.  
  33. return c;
  34.  
  35. }
  36.  
  37. console.log(alphabetPosition("The sunset sets at twelve o' clock."))
RAW Paste Data