LeetCode problem#2942
Find Words Containing Character
Solved in 1 languageJavaScript
Solution
16 lines
1/**
2 * @param {string[]} words
3 * @param {character} x
4 * @return {number[]}
5 */
6var findWordsContaining = function(words, x) {
7 const indices = [];
8
9 for (let i = 0; i < words.length; i++) {
10 if (words[i].includes(x)) {
11 indices.push(i);
12 }
13 }
14
15 return indices;
16};Want a walkthrough of this JavaScript solution?
Get a step-by-step explanation of the idea behind the code.
Problem statements belong to LeetCode and are on leetcode.com. We're not affiliated with LeetCode.