I have a function that accept two parameters string and index. How do I write a code that will return the character at that index without using javascript built in method ch
Something like this should work for you:
getIndex = (str, index) => str.split('')[index]; console.log(getIndex("foobar", 3));
This may also be of interest:
String.prototype.getIndex = function(idx) { return this.split('')[idx]; } console.log("foobar".getIndex(3));
Hope this helps,