gpt4 book ai didi

javascript - 字符串数字 - 从 123,456 转换为 123456

转载 作者:行者123 更新时间:2023-11-30 18:22:16 25 4
gpt4 key购买 nike

我有一个字符串数组,如下所示:"123,556","552,255,242","2,601","242","2","4"我想将它们转换为 int 数字,但带有“,”的数字我想先从“123,556”转换为“123556”。我该怎么做?

最佳答案

var numbersArray = ["153,32","32,453,23","45,21"];
for (var i = 0; i < numbersArray.length; i++) {
numbersArray[i] = parseInt(numbersArray[i].replace(',',''));
}

关于javascript - 字符串数字 - 从 123,456 转换为 123456,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11774362/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com