M
M
Mari Kozak2020-12-15 16:36:56
Arrays
Mari Kozak, 2020-12-15 16:36:56

How to find specified words in an array?

hello everyone, I have a question about the task.
There are two inputs.
In the first input, the user enters a string, let's say "tacked tacked but didn't catch".
In the second input, the user enters "la".
Using the button should display words that contain "la", that is, "tacked tacked tacked"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuriy Vorobyov, 2020-12-15
@vmlzn

Pseudocode:

input1 = "лавировали лавировали да не вылавировали"
input2 = "ла"

array = input1.split(" ")

result =""

for (i = 0; i < array.length; i++) {
   if (array[i].includes(input2)) {
        result += array[i]
   } 
}

return result

M
Mors Clamor, 2020-12-15
@66demon666

Split a string into words and check for a substring in each

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question