12345678910111213141516 |
- 'use strict'
-
- function canSpell (word,tiles) {
- tiles = tiles.split('');
- for (let i = 0; i < word.length; i++) {
- let index = tiles.indexOf(word[i]);
- if (index < 0) {
- return false;
- }
- tiles[index] = null;
- console.log(tiles);
- }
- return true;
- }
-
- console.log(canSpell('jib','quijibo'));
|