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.
String searching
Search the string
Report a typo
Sample Input 1:
Sample Output 1:
true
falseWrite 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
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.