<<<<<<< HEAD Code Wars - Brett Crafton

Hello, Name or World!

Question

Define a method hello that returns "Hello, Name!" to a given name, or says Hello, World! if name is not given (or passed as an empty String). Assuming that name is a String and it checks for user typos to return a name with a first capital letter (Xxxx). Examples:

* With `name` = "john" => return "Hello, John!" * With `name` = "aliCE" => return "Hello, Alice!" * With `name` not given or `name` = "" => return "Hello, World!"

Solution by -

My Solution


	function hello(name) {
		return name == "" || !name ? "Hello, World!" : "Hello, " + name.charAt(0).toUpperCase() + name.toLowerCase().substring(1) + "!";
		}
				

Try it yourself - CodeWars

======= Code Wars - Brett Crafton

Hello, Name or World!

Question

Define a method hello that returns "Hello, Name!" to a given name, or says Hello, World! if name is not given (or passed as an empty String). Assuming that name is a String and it checks for user typos to return a name with a first capital letter (Xxxx). Examples:

* With `name` = "john" => return "Hello, John!" * With `name` = "aliCE" => return "Hello, Alice!" * With `name` not given or `name` = "" => return "Hello, World!"

Solution by -

My Solution


	function hello(name) {
		return name == "" || !name ? "Hello, World!" : "Hello, " + name.charAt(0).toUpperCase() + name.toLowerCase().substring(1) + "!";
		}
				

Try it yourself - CodeWars

>>>>>>> 0e614172debaa009c8d31330edbeb3b765b59c39