<b><p>You can't skip over an argument.</p>Open your console to see the output from this code!</b>
<p>Here we have a function that takes three arugments, and assigns them to three parameters. </p>
<p>While you don't have to pass in three arguments (you might have only one or two), the only way to get a value into the third parameter is to pass three arguments, even if some are undefined. </p>
JavaScript
/* When you do use parameters, you can't skip.
*/
function person(exNum, name, age, occupation){
console.log(exNum + ": My name is: "+name);
console.log(exNum + ": I am " +age + " years old");
console.log(exNum + ": I am a "+occupation);
}
person(1, "Bob", 45, "builder"); //OK
person(2, "Bob", 45); //OK
person(3, "Bob", "builder"); //not quite right
person(4, "Bob", undefined, "builder"); //OK
//the following one won't parse and breaks the code completely
//person("Bob", , "builder");
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.