Basic JavaScript - Passing Values to Functions with Arguments

Tell us what’s happening:
Not sure what is wrong

Your code so far

function functionWithArgs(){

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 11; TECNO KG5k) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Mobile Safari/537.36

Challenge: Basic JavaScript - Passing Values to Functions with Arguments

Link to the challenge:

And, this is the challenge:

  1. Create a function called functionWithArgs that accepts two arguments and outputs their sum to the dev console.
  2. Call the function with two numbers as arguments.

The following code is calling a function with two arguments, the values 3 and 16 - that is the second point in the challenge.

functionWithArgs(3, 16);

Discussion about point 1 :

An example function without arguments:

function functionWithoutArgs() {
    console.log("1 + 3 = ", 4);

When you run this function:


It prints on the console:

1 + 3 = 4

Here is an example function with one argument:

function exampleFunction(name)  {
    console.log("Hello", name);

Run this function:


The output on the console is, Hello World

Thats how arguments are defined in a function and are used in it.

function functionWithArgs(){

You should pass argument on top between parenthesis
and inside the function you should show output by using the value you passed at the top
for e.g.

function functionWithArgs(a,b){

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.