QUESTION IMAGE
Question
find the index of the string near and assign substringindex with the index. then, update wiseproverb replacing near with close.
note: your code will be tested with more values for wiseproverb.
1 let wiseproverb = \keep your friends near and your enemies closer.\;
2 let substringindex = 0;
3
4 / your solution goes here /
5
Step1: Find the index of "near"
Use the indexOf method. substringIndex = wiseProverb.indexOf("near");
Step2: Replace "near" with "close"
Use the replace method. wiseProverb = wiseProverb.replace("near", "close");
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
let wiseProverb = "Keep your friends near and your enemies closer.";
let substringIndex = 0;
substringIndex = wiseProverb.indexOf("near");
wiseProverb = wiseProverb.replace("near", "close");