This commit is contained in:
arussac
2025-02-12 10:50:28 +01:00
parent 522e5db91e
commit bd4b1ddd2e
5 changed files with 46 additions and 22 deletions

View File

@@ -1,9 +1,9 @@
function convertStringToArray(inputString) {
// Split the string by the delimiter '/'
const stringArray = inputString.split(",");
function convertStringToArray(string) {
console.log(string)
const numberStrings = string.replace(/[{}]/g, '').split(',');
// Convert each element to a number
const numberArray = stringArray.map(Number);
// Trim whitespace and convert the string numbers to integers
const numberArray = numberStrings.map(num => parseInt(num.trim(), 10));
return numberArray;
}