indexOf and lastIndexOf String Methods

Video

JavaScript Notes

JavaScript
    let word = "Excalibur";
    let sentence = "In the end, we decided to sell the children and go on vacation";
    let log = console.log;
    
    word.indexOf("a");	                        // returns a match, 3
    word.toLowerCase( ).indexOf("e");	        // returns a match, 0
    
    word.toLowerCase( ).lastIndexOf("e");	    // returns a match, 0
    
    sentence.toLowerCase( ).indexOf("e");	    // returns a match, 5
    sentence.toLowerCase( ).lastIndexOf("e");	// returns a match, 41
    
    sentence.indexOf("the");	                // returns a match, 3
    
    sentence.indexOf("e", 10);	                // returns a match, 13, starting search from position 10
    sentence.indexOf("the", sentence.indexOf("we ")+ 3); //looks for the first “the” after the word “we”