Question

Javascript: Implement a greet(name) function that returns a function that prints 'Hello, ' name when invoked....

Javascript: Implement a greet(name) function that returns a function that prints 'Hello, ' name when invoked. var greetBob = greet('Bob'); // returns function greetBob(); // Prints 'Hello, Bob!' to console

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

ode

function greetBob(x){
console.info("Hello, " + x + "!");
}

function greet(x){
return greetBob(x);
}

var greetBob = greet('Bob');

\color{red}\underline{Output:}

function greetBob (x) console.info(Hello, x); ぐundefined function greet(x)f return greetBob(x) undefined > var greetBob-gr

Add a comment
Know the answer?
Add Answer to:
Javascript: Implement a greet(name) function that returns a function that prints 'Hello, ' name when invoked....
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
  • IN PYTHON Implement a function printSeqs() that accepts a list of name lst and prints the...

    IN PYTHON Implement a function printSeqs() that accepts a list of name lst and prints the following sequences. The sequences are printed by the for loops found in the function. The information below shows how you would call the function printSeqs() and what it would display: Write a for loop that iterates through a list of names and print a greeting for each name in the list. Request from the user a positive integer n and prints all the positive...

  • write a static method named greet that takes a String that represents a name and prints...

    write a static method named greet that takes a String that represents a name and prints a personalized greeting to StdDraw. So far i have in the main method... 4 public class TakeHomeAssignment 5 { 6 public static void main(String[] args) 7 { 8 StdDraw.setScale(0,500); 9 //drawEye(250,250,50); 10 String greet(Aaron); 11 // drawStickFigure(250,250); and for the method; //public static String greet( name) 31 //{ 32 33 34 //StdDraw.text(250,250,"Hello" +name); 35 36 // } Im getting errors saying its an illegal...

  • Using JavaScript, I want to make a function that will open a new alert box that will say hello fi...

    Using JavaScript, I want to make a function that will open a new alert box that will say hello first name, last name after the person logs into the sign in form. This will happen aftrer the validation function is invoked. See code below. See the welcomefunction(). <!DOCTYPE html> <html> <head> <script> //validate the login form function validateForm() { var x = document.forms["LoginForm"]["fname"].value; //set x and y to first name and last name var y = document.forms["LoginForm"]["lname"].value; if (x ==...

  • 3.12 LAB: JavaScript Arrays Implement the function calcWordFrequencies() that uses a single prompt to read a...

    3.12 LAB: JavaScript Arrays Implement the function calcWordFrequencies() that uses a single prompt to read a list of words (separated by spaces). Then, the function outputs those words and their frequencies to the console. Ex: If the prompt input is: hey hi Mark hi mark the console output is: hey 1 hi 2 Mark 1 hi 2 mark 1 Note: To test the JavaScript locally, call the calcWordFrequencies() function from the JavaScript console in the browser.

  • Write a JavaScript program that changes the HTML code that prints "Hello World" to have it...

    Write a JavaScript program that changes the HTML code that prints "Hello World" to have it say "Good Night World" . Hint: innerHTML

  • c++ language 1) Create a function that prints a greeting when called with a name such...

    c++ language 1) Create a function that prints a greeting when called with a name such as greeting ("Elona") 2) Create a function that squares a double number and returns the result as a double. 3) Create a function that takes 5 int numbers and returns the average as a float 4) Create a single function that gives a greeting, calculates the average of 5 grades but does not return a value. Hint: Use return type void and a string...

  • JavaScript Please Write a function that logs hello world if there is no argument provided. Otherwise,...

    JavaScript Please Write a function that logs hello world if there is no argument provided. Otherwise, it should log the argument provided (string) ex. greeting('JavaScript') => hello JavaScript.

  • How can I this to jquery instead of it being javascript? function showMssg() { var message...

    How can I this to jquery instead of it being javascript? function showMssg() { var message = document.getElementsByTagName('pre')[0]; var console = document.getElementById('console'); if (message.style.display == 'block') { log += ' The log is now hidden. '; message.style.display = 'none'; console.innerHTML = 'Show Console Log'; } else { log += ' The log is now visible. '; message.innerHTML = log; message.style.display = 'block'; console.innerHTML = 'Hide Console Log'; } }

  • python Implement function get_contact(contacts, name) that returns a string. The contacts and the name parameter are...

    python Implement function get_contact(contacts, name) that returns a string. The contacts and the name parameter are both type string. This function checks for the name string in the contacts string and returns that person's contact information. If the person is not found, the function returns, "name not in contact". Assume input is always valid. Assume the same name is not repeated in contacts. [You may use split(), range(), len() ONLY and no other built-in function or method] Examples: contacts =...

  • (C PROGRAM PLEASE) Write a recursive function power( base, exponent ) that when invoked returns baseexponent...

    (C PROGRAM PLEASE) Write a recursive function power( base, exponent ) that when invoked returns baseexponent For example, power( 3, 4 ) = 3 * 3 * 3 * 3. Assume that exponent is an integer greater than or equal to 1. Hint: The recursion step would use the relationship baseexponent = base * base exponent–1 and the terminating condition occurs when exponent is equal to 1 because base1 = base.

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