Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- var dict = {
- children: {
- A : { is_word: true, children: {} },
- B : { children: {
- A: { children: {
- R: { is_word: true, children: {
- K: { is_word: true, children: {} }
- }}
- }}
- }}
- }
- };
- function isWord(dictionary, letters) {
- }
- // Tests
- var words = {
- A: true,
- AB: false,
- B: false,
- BA: false,
- BI: false,
- BAR: true,
- BARK: true,
- BART: false,
- CAT: false
- };
- for (var word in words) {
- console.log('Testing word ' + word);
- if (isWord(dict, word.split("")) !== words[word]) {
- console.log('Incorrect response about "' + word + '"');
- return false;
- }
- }
- console.log('> All tests pass');
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement