Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert string array to integer array

People also ask

How do I turn an array into a number?

Try this: int i, k = 0; for (i = 0; i < n; i++) k = 10 * k + a[i];

Can we convert string to array in C?

The c_str() and strcpy() function in C++C++ c_str() function along with C++ String strcpy() function can be used to convert a string to char array easily. The c_str() method represents the sequence of characters in an array of string followed by a null character ('\0').


var arrayOfNumbers = arrayOfStrings.map(Number);

Strings in the console are symbolized by wrapping them in quotes. By that fact, we can assume that i is a string. Convert it to an integer and it will no longer be a string and no longer have those quotes.

endFlowArray.push(+i);

Your "numbers" in flowEnd and dateFlow are actually strings, not numbers.


To convert entire array's data type we can use map():

let numberArray = stringArray.map(Number)

try this:

let numberArray = stringArray.map(el=>parseInt(el))