老师代码还有什么需要改进的吗?
来源:5-8 编程练习
原来是晓琪_
2020-01-15 17:06:42
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
// function insert(value) {
// return {
// into: function(array) {
// return {
// after: function(afterValue) {
// array.splice(array.indexOf(afterValue) + 1, 0, value);
// return array; // [1,2,3]
// }
// };
// }
// };
// }
// insert(2).into([1, 3]).after(1);
// 补充代码
function insert(value) {
return array => {
return afterValue => {
array.splice(array.indexOf(afterValue) + 1, 0, value);
return array;
}
}
}
document.write(insert(2)([1, 3])(1));
</script>
</body>
</html>
1回答
好帮手慕糖
2020-01-16
同学你好,代码是正确的,继续加油。祝学习愉快~
相似问题
回答 2
回答 1
回答 1
回答 1
回答 1