Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get length in js without using .length method

// Get The Length Of The String.
function strLength(x){
  var counter = 0;
  while(x[counter] !== undefined){
    counter++;
  }
  return counter;
}

var str = prompt("Write your string ...",''); // Get String From User.
var The_Length = strLength(str); // 
var lastChar = counter - 1; // The Index Of Last Letter.
console.log(`The Length Of Your String is ${counter}`);
console.log(`The Last Char In Your String Is ${str[lastChar]}`);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #length #js #method
ADD COMMENT
Topic
Name
1+2 =