Codington
0 of 8 problems solved • 0%
Use in a course

Exercise prompt

Reset a Local on Each Call

Each function call creates fresh local variables. A local counter begins again whenever the function runs.

Example

function getLabel() { let number = 0; number += 1; return number; } console.log(getLabel(), getLabel()); // 1 1

Your task

Complete createVisitLabel with a local visitCount that starts at zero, increases once, and returns Name visit 1. The two calls must display Mira visit 1 and Leo visit 1.