Question

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
function greeting(s) {
    if (s) {
        console.log('hello ' + s);
    } else {
        console.log('hello world');
    }
}

greeting();
greeting('JavaScript');

Add a comment
Know the answer?
Add Answer to:
JavaScript Please Write a function that logs hello world if there is no argument provided. Otherwise,...
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
  • Write a python function called gen_pattern that accepts a string as an argument. Your function should...

    Write a python function called gen_pattern that accepts a string as an argument. Your function should generate a string pattern based on argument provided: If the string provided is a number and that number is even generate a pattern of hash signs. ex. gen_pattern(‘4’): #### If the string provided is odd, generate pattern of stars. Ex: gen_pattern(3): *** If string is not a number just output “ Not a number”

  • 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

  • Write a program with a function that accepts a string as an argument and returns a...

    Write a program with a function that accepts a string as an argument and returns a copy of the string with the first character of each sentence capitalized. For instance, if the argument is “hello. my name is Joe. what is your name?” the function should return the string “Hello. My name is Joe. What is your name?” The program should let the user enter a string and then pass it to the function. The modified string should be displayed.

  • Write a function called smallestLetter that takes in a string argument and returns a char. The...

    Write a function called smallestLetter that takes in a string argument and returns a char. The char that is returned by this function is the character in the string with the lowest ASCII integer code. For example: smallestLetter("Hello") returns ‘H’ which is code 72, and smallestLetter("Hello World") returns ‘ ’ (The space character) which is code 32

  • In Javascript Define 2 functions in JSBin: - A function which receives an array of numbers...

    In Javascript Define 2 functions in JSBin: - A function which receives an array of numbers as an argument, and returns the product of all the numbers in that array.   For example, multiply([2,3,4]) should return 24. - A function which receives a string as an argument, and returns the reversal of that string.   For example, reverse('Hello there!') should return "!ereht olleH"

  • Hi, I need help with Javascript please. Question: Write a function named "tweets" that takes a...

    Hi, I need help with Javascript please. Question: Write a function named "tweets" that takes a string as a parameter and returns the number of tweets required to tweet the input to the world. Note: The maximum length for a single tweet is 280 characters. Thanks!

  • Please use proper ES6 JAVASCRIPT SYNTAX including using Let & const correctly Create a function called...

    Please use proper ES6 JAVASCRIPT SYNTAX including using Let & const correctly Create a function called switchLetters that takes a string and an array. *the switchLetters function should accept two arguments , a string and an array. *The function switches letters in the string with a "/" if they are included in the array for example const arr = ['x', 'a', 'h', 'l', 'd' ] replaceLetters('hello', arr) //output: /e//o please do this in javascript es6 syntax

  • Write a javascript function to match string starting with .AB or AB The string should either...

    Write a javascript function to match string starting with .AB or AB The string should either start with .AB or AB followed by any characters. i am getting confused how to form regular expression and tech and match using function . the string should match with the first two characters AB or first three characters .AB then only alert statement("string is correct") otherwise alert statement ("String is not correct") input1 : .AB2e234324 output: string is correct input2 : AB44r4r44r output:...

  • Introductory Python course. Please make answers simple, I'm really unsure of what to do here. Write...

    Introductory Python course. Please make answers simple, I'm really unsure of what to do here. Write a function that takes, as an argument, a list and a string, and returns a Boolean based whether or not all of the letters in the string appear somewhere in the list. Name your function findLetters(myList, myString). For example, >>> findLetters(["hello", "world"], "hold") should return True, and >>> findLetters(["hello", "world"], "down") should return False.

  • 1. Write a function called ordinal_sum that accepts a string argument and returns the sum of...

    1. Write a function called ordinal_sum that accepts a string argument and returns the sum of the ordinal values of each character in the string. The ordinal value of a character is its numeric Unicode code point in decimal. 2. Write code that creates a Python set containing each unique character in a string named my_string. For example, if the string is 'hello', the set would be {'h', 'e', 'l', 'o'} (in any order). Assign the set to a variable...

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