You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

scrabble.js 296B

12345678910111213141516
  1. 'use strict'
  2. function canSpell (word,tiles) {
  3. tiles = tiles.split('');
  4. for (let i = 0; i < word.length; i++) {
  5. let index = tiles.indexOf(word[i]);
  6. if (index < 0) {
  7. return false;
  8. }
  9. tiles[index] = null;
  10. console.log(tiles);
  11. }
  12. return true;
  13. }
  14. console.log(canSpell('jib','quijibo'));