Answers for "javascript string indexing"

2

js get first letter of string

var x = 'some string';
alert(x.charAt(0)); // alerts 's'
Posted by: Guest on July-19-2020
3

js indexof string

const paragraph = 'The quick brown fox';

console.log(paragraph.indexOf('T'));
>> 0

console.log(paragraph.indexOf('h'));
>> 1

console.log(paragraph.indexOf('Th'));
>> 0

console.log(paragraph.indexOf('he'));
>> 1

console.log(paragraph.indexOf('x'));
>> 18
Posted by: Guest on October-22-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language