Discuss / JavaScript / 作业打卡

### 作业打卡

Topic source

#### ClaireAnais

#1 Created at ... [Delete] [Delete and Lock User]

``````    return arr.reduce((x,y)=>(x*y));
``````

``````    var arr=[];
for(var c of s){
arr.push(c);
}
return arr.map(c=>(c*1)).reduce((x,y)=>(x*10+y));
``````

``````    return arr.map(name=>name[0].toUpperCase()+name.substring(1).toLowerCase());
``````

``````r = arr.map(c=>parseInt(c));
``````

#### harper2564

#2 Created at ... [Delete] [Delete and Lock User]

#### harper2564

#3 Created at ... [Delete] [Delete and Lock User]

#### 迷迷的蛋

#4 Created at ... [Delete] [Delete and Lock User]

map方法的函数只要一个参数，但是map传递的参数有三个，分别是：数组元素、元素索引，数组本身，而paresInt是可以接受两个参数的，第一个是字符，第二个是进制。

``````['1', '2', '3'].map(paresInt)
``````

`['1', '2', '3'].map(paresInt(value, index))`

`第一个元素就是：paresInt('1', 0)  > 1`

`第二个元素就是：paresInt('2', 1)  >  NaN`

`第三个元素就是：paresInt('3', 2)  >  NaN`

#### 雾水清澈

#5 Created at ... [Delete] [Delete and Lock User]

2楼你用Number转换的话如果输入的数组是小数就无法转换成整数了

#### 玩转ACE

#6 Created at ... [Delete] [Delete and Lock User]

**parseInt(string, radix)  ** 解析一个字符串并返回指定基数的十进制整数， `radix` 是2-36之间的整数，表示被解析字符串的基数。