Files

570 B

title, localeTitle
title localeTitle
Remove Items from an Array with pop() and shift() 使用pop()和shift()从数组中删除项

使用pop()和shift()从数组中删除项

  • 必须使用popped和shifted变量调用和初始化.pop()方法和.shift()方法,以从函数返回正确的答案。

解:

function popShift(arr) { 
  let popped = arr.pop(); 
  let shifted = arr.shift(); 
  return [shifted, popped]; 
 } 
 
 // do not change code below this line 
 console.log(popShift(['challenge', 'is', 'not', 'complete']));