Question

选择题

case1

以下这段代码的输出为

var res = [
  [0, 1],
  [2, 3],
].reduce(
  (acc, cur) => {
    return acc.concat(cur);
  },
  [1, 2]
);

console.log(res);
答案: [ 1, 2, 0, 1, 2, 3 ]
解析: [1,2]为初始值 一开始的acc就是[1,2]

case2

以下这段代码的输出为

case3

以下这段代码的输出为

case4

以下这段代码的输出为

case5

以下这段代码的输出为

case6

以下这段代码的输出为

case7

以下这段代码的输出为

case8

以下这段代码的输出为

case8

以下这段代码的输出为

case9

以下这段代码的输出为

case10

以下这段代码的输出为

手写题

Promise 实现红绿灯交替

红灯三秒亮一次,绿灯一秒亮一次,黄灯 2 秒亮一次;如何让三个灯不断交替重复亮灯?(用 Promise 实现)

最大公共子串

input : ['floor', 'flower', 'flow'] ===> output: flo

反转字符串

反转字符串 多个空格最后只显示一个 input : hello lucky chou! ===> chou! lucky hello

模板字符串

对正则不太熟悉 暂时想到了这种解法

Last updated

Was this helpful?