Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. 'use strict'
  2.  
  3. let words = ["NEUTRAL", "INDIFFERENT", "READABLE", "CLASSIC", "PLAIN", "DULL"];
  4.  
  5. function pickRandomChar(word) {
  6. let chars = word.split("")
  7. let randomIdx = Math.floor(Math.random() * chars.length)
  8. return chars[randomIdx]
  9. }
  10.  
  11. function removeCharacter(word) {
  12. let letter = pickRandomChar(word)
  13. console.log(letter)
  14. const newString = word.split(letter).join(" ")
  15. return newString
  16. }
  17.  
  18. words = words.map(removeCharacter)
  19.  
  20.  
  21. /* for(let i = 0; i < words.length; i++) {
  22. let newCharacter(words, "E");
  23. }*/
  24.  
  25. //word = removeCharacter(word, "A");
  26. console.log(words);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement