Explore BrainMass
Share

Explore BrainMass

    NASA Like pop-up counter javascript.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Can you please see below and review attachment. (adding parameters to functions & using function parameters)

    You made some modifications to your program, but you did not change the function to accept a parameter. You can either modify the function in your program to accept a parameter, or you can use the function I demonstrate below in your program by adding it to your source code file.

    To demonstrate I'm going to create a function that meets those requirements described below.
    I'm going to name the function display_alert, because that is what the function does.
    I'm going to name the parameter, message, because that's what the data contains.

    The function is defined as follows:

    function display_alert(message){
    window.alert(message);
    }

    It looks very similar to the function you defined below, except for the fact that it gets the data to be displayed in the alert message, from the input parameter.
    It uses the parameter variable as an argument to pass to the window.alert() function.

    Your program should call this function 13 times.
    Each time the function is called, the parameter variable will have a different value.

    Two examples of calling the above function with an argument:

    var mess1 = "Ten";
    display_alert("Ten"); // call the function with an string literal argument
    display_alert(mess1); // call the function with a variable argument
    // A variable must be declared before(above) using it.

    In both examples the value passed to the function is the string "Ten".
    Notice that the name of the variable used in the argument does not have to be the same as the name of the parameter variable in the function definition.

    © BrainMass Inc. brainmass.com October 10, 2019, 7:35 am ad1c9bdddf
    https://brainmass.com/computer-science/javascript/nasa-like-pop-up-counter-javascript-587367

    Attachments

    Solution Preview

    Dear student,

    Please find attached the solution.
    Let me know if you have any doubt/confusion about anything.

    Please do not forget to give a ...

    Solution Summary

    The solution contains a small javascript program that displays how to pass parameter values to the function. This function then displays the message received as the parameter as a browser window alert.

    $2.19