I need to read the numeric value of one line in a text file
color=7
so var color will = 7
I need to read the numeric value of one line in a text file
color=7
so var color will = 7
Split the string by '='
, get the second value and turn it into an int:
let data = 'color=7';
let color = parseInt(data.split('=')[1]);
console.log(color);
Do note that if the value after the = isn't a number in this case, the code will throw an excpetion so you might wanna catch it.