5-8 编程练习 代码提交

来源:5-8 编程练习

MiMicccc

2021-08-28 21:09:47

<!DOCTYPE html>
<html lang="en">

<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;
}
};
}
};
}

console.log(insert(2).into([1, 3]).after(1));

// 补充代码
let insert1 = value => {
return {
into: array => {
return {
after: afterValue => {
array.splice(array.indexOf(afterValue) + 1, 0, value);
return array;
}
};
}
};
}
console.log(insert1(2).into([1, 3]).after(1));

</script>
</body>

</html>


写回答

1回答

好帮手慕慕子

2021-08-29

同学你好,代码实现是对的,继续加油,祝学习愉快~

0

0 学习 · 10739 问题

查看课程