Think carefully about what the challenge is asking you to do. You get two strings passed in. You want to make sure that all of the letters in the second string are in the first string. So which string do you need to go through all of the letters one at a time and make sure they are in the other string? That will be the string you want to iterate through (with your for loop).
Okay that is one of the greatest challenges am facing with javascript i dont see my output … do you know anyway i can check as i code i mean run the program like other programming like C for example you can use codeblocks or python use can use Idle. for javascript i have tried installing node … but face some problems any other ways apart from browser console? thank you in advance i know i can google it just wanted your opinion.
Congrats on passing the test! And you learned a new Array method as well
Now take a good close look at what you have there and see if you can make it even simpler. I’ll give you a hint. You don’t need the check counter variable at all. You are doing the for loop correctly, so you don’t need to change that. It’s what’s inside the for loop that can be simplified.
I added spoiler tags around your code for those who have not done this challenge.
I’ve also edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
Well, I don’t want to just give you the answer. Remember, there are two values you can return: true or false. You are checking that each letter in word2 is also in word1 using the for loop. Right now you are incrementing the check counter if it is. But what if it isn’t in word1?