Skip to content

Instantly share code, notes, and snippets.

@manila
Last active August 31, 2021 22:07
Show Gist options
  • Save manila/2f37c11ea8c3481be2ac946658c0bddc to your computer and use it in GitHub Desktop.
Save manila/2f37c11ea8c3481be2ac946658c0bddc to your computer and use it in GitHub Desktop.

Revisions

  1. manila revised this gist Aug 31, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cracklepop.js
    Original file line number Diff line number Diff line change
    @@ -21,4 +21,4 @@ const cracklePop = (start, end, step = 1) => {
    cracklePop(num + step, end, step)
    }

    cracklePop(1, 100)
    cracklePop(1, 100)
  2. manila created this gist Aug 31, 2021.
    24 changes: 24 additions & 0 deletions cracklepop.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    const cracklePop = (start, end, step = 1) => {

    let num = start

    if (num > end) {
    return false
    }

    let result = num

    if (num % 3 == 0 && num % 5 == 0) {
    result = 'CracklePop'
    } else if (num % 3 == 0) {
    result = 'Crackle'
    } else if (num % 5 == 0) {
    result = 'Pop'
    }

    console.log(result)

    cracklePop(num + step, end, step)
    }

    cracklePop(1, 100)