After running this code, which result is displayed on the console?

Refer to the code below:

Const searchTest = ‘Yay! Salesforce is amazing!” ;

Let result1 = searchText.search(/sales/i);

Let result 21 = searchText.search(/sales/i);

console.log(result1);

console.log(result2);

After running this code, which result is displayed on the console?
A . > true > false
B . > 5 >undefined
C . > 5 > -1
D . > 5 > 0

Answer: B

Subscribe
Notify of
guest
1 Comment
Inline Feedbacks
View all comments
Igor Malički
Igor Malički
3 years ago

This whole question is wrong and full of coding errors. /i means it is not case sensitive.
If this is supposed to be the question:
const searchText = ‘Yay! Salesforce is amazing!’ ;
let result1 = searchText.search(/sales/i);
let result2 = searchText.search(/sales/);
console.log(result1);
console.log(result2);
Then the Answer is C