Task:
I need to check, if from given string(characters) document can be made(document) if at least 1 character is missing in characters then it is not possible to create document
Occuring problem:
When comparing ‘a’ and ‘A’ with [].includes method, it returns ‘false’ in the function.
Code:
function generateDocument(characters, document) {
document = Array.from(new Set(document));
characters = Array.from(new Set(characters));
for(let i = 0; i < document.length; i++) {
if(characters.includes(characters[i]) == false)
return false;
}
return true;
}
console.log(generateDocument("A","a"));
Expected result: To return false, because ‘a’ and ‘A’ are not equal