JavaScript- How do I return the character at that index without using charAt method

前端 未结 4 1438
忘掉有多难
忘掉有多难 2021-01-16 17:57

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

4条回答
  •  粉色の甜心
    2021-01-16 18:58

    Create the function as below:

    function getIndex(input, i) {
        return input.substring(i, i+1);
    }
    
    getIndex("great", 1)
    

    I hope that helps!

提交回复
热议问题