Search the string

Report a typo

The function searchFruit searches the substrings fruitOne and fruitTwo in a text string. Write the missing code in the function to search for fruitOne in the whole text and to search for fruitTwo after position 50 in the text. Log the output inside the function. Also, call the function at the end.

Sample Input 1:

Sample Output 1:

true
false
Write a program in JavaScript
function searchFruit(fruitOne, fruitTwo) {
let text = `My favorite fruit is grapes. Because with grapes, you always
get another chance. 'Cause, you know, if you have a crappy apple or a peach,
you're stuck with that crappy piece of fruit.
But if you have a crappy grape, no problem - just move on to the next.
'Grapes: The Fruit of Hope.'`;
}

let fruitOne = "apple";
let fruitTwo = "grapes";
// Call the function here with the arguments
___

Create a free account to access the full topic