Link to home
Start Free TrialLog in
Avatar of john8217
john8217

asked on

Javascript function question

    At the end of this quesiton is  a snippet of code from a JavaScript book.
     Can someone please tell me what "donutString" is? What is its purpose here? What does it do?
     Why is it in parenthesis on lthat first line? I initially thought that meant it was some variable that had been created from outside the parseDonuts function and is thus being plugged into that function. But that is not the case. It was created from within that function and it does not appear anywhere outside of that function. So what's it doing inside the parenthesis? I thought values only go in there if there coming from outside the function?

      function parseDonuts(donutString) {
        numDonuts = parseInt(donutString);
        if (donutString.indexOf("dozen") != -1)
          numDonuts *= 12;
        return numDonuts;
      }
ASKER CERTIFIED SOLUTION
Avatar of Cluskitt
Cluskitt
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of john8217
john8217

ASKER

Great. Thank you.