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

446
Views
Hello how to remove brackets from API response with vue JS

im trying to remove brackets and 2 letters from an API response that i got with axios, i show the data with vue js but they are showing like this :

["188 cm"]

What will be the best way to only show 188 by removing Brackets and cm [" cm"] ?

Thank you

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

0

"Removing the brackets" is the straightforward part. What you have is simply an array with one element, so you can access the first element in that array. (Assuming of course there's always at least one element, if it's possible for the array to be empty then you will want to put in some range checking before trying to access the element.)

The second part, "removing the ' cm' part", can be done in a couple of different ways. You can split the string on the space character and take the first part of the result, you can simply replace " cm" with "", or if what you want is the actual number and the string always starts with that number then parseInt will ignore everything after that number by default.

For example:

let theArray = ["188 cm"];
let theString = theArray[0];
let theNumber = parseInt(theString);
console.log(theNumber);

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!