Home > Enterprise >  JS code to flowchart containing functions
JS code to flowchart containing functions

Time:10-10

I need to construct the flowchart of this JS code. I can't understand how I should include functions in flowchart, any ideas?

    function someYear(year) {
    return(year%4 == 0);
}
function someMonth(month, year) {
    if (month == 1) {
        return "January";
    }
    else if (month == 3) {
        return "March";
    }
    else if (month == 2 && someYear(year)) {
        return "February"   y;
    }
    else if (month == 2 && someYear(year) == false) {
        return "February";
    }
    else {
        return "The month is not in list";
    }
}
console.log(someMonth(2, 2007));

CodePudding user response:

I think this image will give you the idea.

CodePudding user response:

Either you can use the functional representation that is used in the comment of @seymurium, or you can represent the logic that lies under the target function directly instead of the function body.

In your case someMonth() function needs to be replaced with 5 conditional statements.

  • Related