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

前端 未结 4 1539
忘掉有多难
忘掉有多难 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:37

    Can you please check this:

    $('#show').click(function(){
      var string = $('#string').html();
      var position = $('#position').val() - 1;
      var result = string[position];
      $('#result').html(result);
    });
    
    ABCDEFGHIJKLMNOPQRSTUVWXYZ
    =

提交回复
热议问题