Answers for "last digit of string javascript"

7

javascript get last n characters of string

'abc'.slice(-1); // c
Posted by: Guest on February-03-2020
0

find the length and the last character of string in js

// 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]}`);
Posted by: Guest on March-20-2022

Code answers related to "last digit of string javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language