Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get lastchar in string in js

//Gettimg the last character of an unknown string;
//using function Expression;
const gettingLastChar = function(userInput){
     return userInput.substring(userInput.length -1);
  //for Debugging;
  let letsDebug = `${userInput.substring(userInput.length -1)}`;
  console.log(letsDebug);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #lastchar #string #js
ADD COMMENT
Topic
Name
3+7 =