How can I export first character to 1 character after "."
I've got data from API
{POWER : 1343.45}
{POWER : 15623.34577}
{POWER : 123.434}
I need just 123.4
from 123.45
, 15623.3
from 15623.34577
etc.
What should I do?
How can I export first character to 1 character after "."
I've got data from API
{POWER : 1343.45}
{POWER : 15623.34577}
{POWER : 123.434}
I need just 123.4
from 123.45
, 15623.3
from 15623.34577
etc.
What should I do?
You can use regex and match() to solve this
const str = `{POWER : 1343.45}
{POWER : 15623.34577}
{POWER : 123.434}`
const reg = /\d+\.\d{1}/g
const result = str.match(reg) //["1343.4","15623.3","123.4"]
console.log(result)