Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
how to get first character of second string in javascript?

how to get first 2 character of string in javascript like this "Hello world " => get this "wo"? another example "Osama Mohamed" => M.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

you can use string.split(' '), this function will split you string into an array, for example:

let s = "Hello World";
console.log(s.split(" ")) // will log ["Hello", "World"]

then you can get the second word using array[index] when index the index of your desired word in said array.

now using string charAt we can get the first letter of the word.

now to put everything together:

let s = "Hello World"
let s_splited = s.split(" ") // ["Hello", "World"]
let second_word = s_splited[1]
console.log(second_word.charAt(0))

about 4 years ago · Juan Pablo Isaza Report

0

string = "Hello world";
split_string = string.split(" ");
second_word = split_string[1]
first_char = second_word[0]
console.log(first_char)

OR

string = "Hello world";
console.log(string.split(" ")[1][0])
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!