Files
2018-10-16 21:32:40 +05:30

570 B
Raw Blame History

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

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

  • 必须使用poppedshifted变量调用和初始化.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']));