Question

This question relates to Javascript. I know that a function can return 1 value or no...

This question relates to Javascript.

I know that a function can return 1 value or no values.

What are some examples of Javascript functions returning no values? Why is this useful? If the function does not return any value then why and how is it useful?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In Javascript there may be cases where function is not returning values. Actually this happens when we want that only the function will execute or from the main block we will redirect to the function block, and from the function the program will end. In other words we can say the function is acting like a procedure. In javascript we sometimes face this type of situation, like

<script>
function myCube(n)
{
c= n*n*n;
document.write(c);
}
myCube(3);
</script>

------Output is

27

Here we just call the function , and from the function the output is executed, this makes the program execution faster and also the program is simpler.

Add a comment
Know the answer?
Add Answer to:
This question relates to Javascript. I know that a function can return 1 value or no...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Which of the following functionality can NOT be developed using JavaScript only? Question 1 options: A...

    Which of the following functionality can NOT be developed using JavaScript only? Question 1 options: A monthly calendar Adding some numbers A live clock showing date and time A synchronous chat room with multiple people from different places Showing different text based on time of the day. Question 2 (0.5 points) Saved In the following JavaScript statement, what is the value of course[3]? var course = new Array(4203, 89, 95, 77, 5443); Question 2 options: 4203 77 95 null 5443...

  • Does anybody know how to create a score of increase and decrease using javascript ? I...

    Does anybody know how to create a score of increase and decrease using javascript ? I will like to create a score system where If the user decides to not guess any number and just get what ever number that is given to them then there points is just what ever number comes up. For example: if the user just clicks on the no random button they just get what ever number comes up If the user wants to guess...

  • Can some help me solve these? I am confused on where to start. I know in...

    Can some help me solve these? I am confused on where to start. I know in some cases, since there are no arguments, I can use *. Function 3: In this function you must both return a value and modify in-place the input parameter (when needed). The only functions you are allowed to use are range(), len(), append(), insert(), remove(), pop() and the del keyword. • Examples: return value argument value after return ◦ func3([4,-3,7,-5,1]) → [-3,-5] [4,7,1] ◦ func3([4,-3,7,-5,1],...

  • In JavaScript the inner function can access the variables from the outer scope even after the...

    In JavaScript the inner function can access the variables from the outer scope even after the outer function has returned. This is because the variables are still bound in the inner function and not dependent on the outer function. This is called closure. True False 3 points    QUESTION 2 Which of the following statements is true about JSON? a. JSON stands for JavaScript Object Notation. b. JSON is a syntax for storing and exchanging data. c. JSON is text,...

  • This question relates to Javascript. Could you please show me why my code is not working?...

    This question relates to Javascript. Could you please show me why my code is not working? I want to create 2 text boxes and have the user enter something into both of them. If the text entered into both boxes is identical the a green message is made visible. If the boxes are different a red message is made visable. Please keep it simple because I am new to javascript. <html> <head>               <title></title>        <script>...

  • JavaScript Upon invoking/calling the Bill function, what parameter value do we need to pass to this...

    JavaScript Upon invoking/calling the Bill function, what parameter value do we need to pass to this function, in order to console.log("Got Ya!)" Explain what happen to the values for it to get to the console.log var bill = function(amount){ if(amount > 10 && amount <100){ return amount + tax(amount, 1); } else if(amount >= 100){ return amount + tax(amount, 2); } else { return amount; } } var tax = function(price, bracket){ if(bracket === 1){ return price * 0.1; }...

  • Can someone please help me with this javascript - Javascript - do at least 10 of...

    Can someone please help me with this javascript - Javascript - do at least 10 of the following questions below ----------------------------------------------------------------------------------- Create an HTML file that takes in input and carries out of the following functions and manipulates the DOM to show the outcome. Please put the question itself as a comment above each answer. Use either JavaScript, jQuery, or both (but know the difference!). ----------------------------------------------------------------------------------- 1. Fibonacci Define function: fib(n) Return the nth number in the fibonacci sequence. 2....

  • How to find sum of the first and last 3 numbers? #Javascript Function P2<yourname>. When button...

    How to find sum of the first and last 3 numbers? #Javascript Function P2<yourname>. When button "problem 2" is clicked, a JavaScript function equivalent to the following flowchart should execute. In other words, your task here is to translate the following flowchart to JavaScript code in P2<yourname>: start sum1 0 sum2 0 P i0 i< 3 iei+1 num sum1 sum1 + num F i <3 ii+1 sum1 sum2 "no" num "yes" sum2 sum2 + num end Hint: for input, use...

  • IN PYTHON CODE Question #1 Write a function capital that has one argument: strlist that is...

    IN PYTHON CODE Question #1 Write a function capital that has one argument: strlist that is a list of non-empty strings. If each string in the list starts with a capital letter, then the function should return the value True. If some string in the list does not start with a capital letter, then the function should return the value False You may use any of the string functions that are available in Python in your solution, so you might...

  • Question 5: A) Consider: int i=1; int fun(int x) { for(int i=0; i<4; i++) { x...

    Question 5: A) Consider: int i=1; int fun(int x) { for(int i=0; i<4; i++) { x += i; return x; What value is returned by a function call fun(1)? B In C, static variables can only be initialized by literals, not functions. For example, this is allowed: static int x = 5; But this is not allowed: static int x = compute_initial(); Why would this be the case? A Because you can never initialize a variable using a function, even...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT