Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to find length of string in javascript without using length method

function strLength(s) {
  var length = 0;
  while (s[length] !== undefined){
    length++;
  } 
  return length;
}

console.log(strLength("Hello")); // 5
console.log(strLength("")); // 0
Comment

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]}`);
Comment

PREVIOUS NEXT
Code Example
Javascript :: clear canvas 
Javascript :: workbox push notifications 
Javascript :: javascript remove first space in string 
Javascript :: hello world in jsp 
Javascript :: do not trigger useeffect on start 
Javascript :: Javascript prime number check 
Javascript :: get random letter js 
Javascript :: node js util promisify 
Javascript :: javascript create array of objects with map 
Javascript :: display am pm in javascript 
Javascript :: add color to console 
Javascript :: js absolute value 
Javascript :: json schema string or null 
Javascript :: longest word javascript 
Javascript :: javascript map 2 array of objects 
Javascript :: compress string javascript 
Javascript :: avascript sleep 1 second 
Javascript :: get middle of string js 
Javascript :: react native android run 
Javascript :: what is global execution context in javascript 
Javascript :: javascript round number to nearest 5 
Javascript :: get the value or text from select element using javaScript 
Javascript :: port 3000 is already in use nodemon app crashed 
Javascript :: seleccionar value select2 js 
Javascript :: inarray javascript 
Javascript :: iterate over map key value javascript 
Javascript :: check if a variable is a number in javascript 
Javascript :: how to return 5 records instead of 10 records in datatable in laravel 
Javascript :: toggle class javascript and jquery 
Javascript :: javascript remove last character in a string 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =