JavaScript Last Character of String Challenge

🚀 Day 4 of my Coding Challenge Today's problem was simple but a great reminder of string fundamentals in JavaScript. Problem Statement Given a string s, return the last character of the string. Example Input: "learncoding" Output: "g" Any language Approach Use string indexing with length - 1 to access the last character. function getLastCharacter(s) { return s[s.length - 1]; } console.log(getLastCharacter("learncoding")); // g Key Learning:- Strings are index-based length - 1 always points to the last character Small problems help strengthen core programming logic Consistency matters more than complexity. One problem every day 📚 #CodingChallenge #Day4CodingChallenge #JavaScriptDeveloper #DSA #DataStructures #Algorithms #ProblemSolving #CodingJourney #CodeDaily #LearnToCode #DevelopersLife #SoftwareDeveloper #FrontendDeveloper #FullStackDeveloper #TechCommunity #ProgrammingLife #CodeNewbie #CodingPractice #DeveloperJourney #CodingSkills #TechLearning #JavaScriptCoding #WebDeveloper #ProgrammingChallenge #DailyCoding #CodeMotivation #CareerInTech #DeveloperMindset #CodingGrind #TechGrowth

In Python a = "Harsh Dhaduk" a[-1:] Output k

Like
Reply

To view or add a comment, sign in

Explore content categories