Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Level 11 lesson 2 steps 5, 7 and 8

how do i do step 5 and step 7 and 8???
7. Use appropriate property on resultDiv element to add the message in it so that it is shown on the output screen.
8. In the message use array property to count the number of elements present in the array, which will be the word count of the content.
by

1 Answer

sam5epi0l
Hi, This is how steps are supposed to done:

5:

if(content.search(inputStr)>=0)
{
alert("String found");
}
else {
alert("String not found");
}

7&8:

function count() {
let content = document.getElementById("content").innerText;
// use string function to create array of its words
let arr = content.split(" ");

let resultDiv = document.getElementById("result");
// use array property to find number of array elements
resultDiv.innerText = "Number of words:" + arr.length;
}

Login / Signup to Answer the Question.