Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
151
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. function isWord(dictionary, word) {
  18.  
  19. }
  20.  
  21.      
  22.  
  23.  
  24. // Tests
  25. var words = {
  26.   A: true,
  27.   AB: false,
  28.   B: false,
  29.   BA: false,
  30.   BI: false,
  31.   BAR: true,
  32.   BARK: true,
  33.   BART: false,
  34.   CAT: false
  35. };
  36.  
  37. for (var word in words) {
  38.   console.log('Testing word ' + word);
  39.   if (isWord(dict, word) !== words[word]) {
  40.     console.log('Incorrect response about "' + word + '"');
  41.     return false;
  42.   }
  43. }
  44. console.log('> All tests pass');
  45.  
  46. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement