Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 289 Bytes

File metadata and controls

17 lines (15 loc) · 289 Bytes
function isValid(arr) {
  for(var i=0; i<arr.length; i++) {
    if (arr[i] <= 0) return 'invalid'
  }
  for(var i=2; i<arr.length; i++) {
    if (arr[i] !== arr[i-1] + arr[i-2]) return 'invalid'
  }
  return 'valid'
}

isValid([3, 5, 8, 13, 22, 35])

執行流程

  1. ..
  2. ..