JSFiddle - React, Tailwind, and code Playground

by devangkantharia

JavaScript

// Answer 3

function factorial(int) {
    if (int === 0) {
        return 1;
    } else if (int < 0) {
        return console.log("Oops");
    } else {
        return int * factorial(int - 1);
    }
}

console.log(factorial(5));