loading...

re: Daily Challenge #88 - Recursive Ninjas VIEW POST

FULL DISCUSSION
 

None recursive javascript solution

function chirp(numberOfSignals){
  let signal = ''
  for(let i = 0; i < numberOfSignals; i ++) {
    if(signal === '') {
      signal += 'chirp'
    } else {
      signal += '-chirp'
    }
  }
  return signal
}

console.log(chirp(4)) //chirp-chirp-chirp-chirp
console.log(chirp(5)) //chirp-chirp-chirp-chirp-chirp


`

code of conduct - report abuse