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 :: javascript camelcase regex 
Javascript :: socket io get user rooms 
Javascript :: sum an array of objects 
Javascript :: discord.js give role command 
Javascript :: double bang js 
Javascript :: html get color gradient percentage 
Javascript :: react validate 
Javascript :: javascript get last element in array 
Javascript :: Bracket Notation Example 
Javascript :: eliminar duplicados javascript 
Javascript :: fastify query 
Javascript :: useeffect loading state 
Javascript :: how to read if a person has send a message on discord.js 
Javascript :: client.login discord.js 
Javascript :: got back to start of for loop js 
Javascript :: node js package nodemon error 
Javascript :: javascript console log current directory 
Javascript :: uploading json data to s3 bucket in node js 
Javascript :: array for numbers 
Javascript :: next greater element javascript using stack 
Javascript :: luxurious 
Python :: no module psycopg2 
Python :: pygame boilerplate 
Python :: sort dataframe by column 
Python :: python read json file 
Python :: how to print time python 3 
Python :: dataframe column to string 
Python :: pandas groupby agg count unique 
Python :: python format seconds to hh mm ss 
Python :: how to print hostname in python 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =