Guest User

Untitled

a guest
Dec 14th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. //number is a string
  2. function vanity(number, dictionary){
  3. let dial = {
  4. 1: "",
  5. 2: ['a','b','c'],
  6. 3: ['d','e','f'],
  7. 4: ['g','h','i'],
  8. 5: ['j','k','l'],
  9. 6: ['m','n','o'],
  10. 7: ['p','q','r','s'],
  11. 8: ['t','u','v'],
  12. 9: ['w','x','y','z'],
  13. 0: ""
  14. }
  15. let numArr = [];
  16. for (let i = 0; i<number.length; i++){
  17. if (Number(number[i])){
  18. numArr.push(number[i]);
  19. }
  20. }
  21. console.log(numArr);
  22. //turn dictionary into array of strings
  23. //take only words from dictionary where word.length === numArr.length
  24. //do this by having dictionary words in an array and filter out those that match the above condition
  25. // let someWords = dictionary.filter(word => word.length === numArr.length)
  26.  
  27. let result = [];
  28. for (let i = 0; i<numArr.length; i++){
  29. for (let j = 0; j< dial[numArr[i]].length; j++){
  30. //iterate through letters of a given word from someWords and check to see if
  31. // dial[numArr[i]].includes that letter
  32. //if all letters check then push into result
  33. }
  34. }
  35.  
  36. result.forEach(function(word) {
  37. return word;
  38. });
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. //at a single digit see if dictionary includes first letter
  46. //if true then go to next digit
  47. //when all digits have been checked then push into an array
  48.  
  49.  
  50. //put all the dictonary words in an object so I can access the words
  51. //key would be an index and value would be word
  52. //take the number and put it in an array
  53. //
  54. //output an array that includes all the dictionary words that match
  55. }
Add Comment
Please, Sign In to add comment