Answers for "find position of character in string javascript"

4

get string after character javascript

const str = '01-01-2020';

// get everything after first dash
const slug = str.substring(str.indexOf('-') + 1); // 01-2020

// get everything after last dash 
const slug = str.split('-').pop(); // 2020
Posted by: Guest on July-06-2020
49

javascript indexof

//indexOf getting index of array element, returns -1 if not found
var colors=["red","green","blue"];
var pos=colors.indexOf("blue");//2

//indexOf getting index of sub string, returns -1 if not found
var str = "We got a poop cleanup on isle 4.";
var strPos = str.indexOf("poop");//9
Posted by: Guest on June-27-2019
2

.index of javascript

let monTableau = ['un', 'deux','trois', 'quatre'] ;
console.log(monTableau.indexOf('trois')) ;
Posted by: Guest on March-12-2020
0

javascript string return character

var str = "HELLO WORLD";
var res = str.charAt(0);
Posted by: Guest on November-11-2019

Code answers related to "find position of character in string javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language