repl.it
@Tyledelphia/

getIndexOf

JavaScript

No description

fork
loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*function getIndexOf(char, str) {
  for (let i = 0; i < str.length; i++){
    if (str[i] === char){
      return str
    }
    else {
      return -1;
    }
  }
  
}
*/
var string = "the quick brown fox"
function stringIndex(str){
  return str[4];
  
}

stringIndex(string);  
Native Browser JavaScript