Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.  
  3.  
  4. var dict = {
  5.   children: {
  6.     A : { is_word: true, children: {} },
  7.     B : { children: {
  8.       A: { children: {
  9.         R: { is_word: true, children: {
  10.           K: { is_word: true, children: {} }
  11.         }}
  12.       }}  
  13.     }}
  14.   }
  15. };
  16.  
  17.  
  18. function isWord(dictionary, letters) {  
  19. }
  20.  
  21.  
  22.  
  23. // Tests
  24. var words = {
  25.   A: true,
  26.   AB: false,
  27.   B: false,
  28.   BA: false,
  29.   BI: false,
  30.   BAR: true,
  31.   BARK: true,
  32.   BART: false,
  33.   CAT: false
  34. };
  35.  
  36. for (var word in words) {
  37.   console.log('Testing word ' + word);
  38.   if (isWord(dict, word.split("")) !== words[word]) {
  39.     console.log('Incorrect response about "' + word + '"');
  40.     return false;
  41.   }
  42. }
  43. console.log('> All tests pass');
  44.  
  45. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement