列表

详情


FED68. 正确的使用parseInt

描述

修改 js 代码中 parseInt 的调用方式,使之通过全部测试用例

示例1

输入:

'12'

输出:

12

示例2

输入:

'12px'

输出:

12

示例3

输入:

'0x12'

输出:

0

原站题解

HTML/CSS/JavaScript 解法, 执行用时: 857ms, 内存消耗: 77796KB, 提交时间: 2020-12-04

{"css":"","js":"function parse2Int(num) {\n    return parseInt(num,10);\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 858ms, 内存消耗: 77844KB, 提交时间: 2020-12-20

{"css":"","js":"function parse2Int(num) {\n    return parseInt(num,10);\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 860ms, 内存消耗: 77776KB, 提交时间: 2020-12-28

{"css":"","js":"function parse2Int(num) {\n    //按10进制去处理字符串,碰到非数字字符,会将后面的全部无视\n    return parseInt(num,10);\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 860ms, 内存消耗: 77888KB, 提交时间: 2020-12-27

{"css":"","js":"function parse2Int(num) {\n    return parseInt(num,10);\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 861ms, 内存消耗: 77772KB, 提交时间: 2020-11-22

{"css":"","js":"function parse2Int(num) {\n    return parseInt(num,10);\n}","html":"","libs":[]}

上一题