New on JS.
I'm following a tutorial.
I've a function that ask for your name and prints:
"Hi ("name"), today is: "actual date"".
My function works great if just put in the js file.
But going beyond the tutorial, when experimenting with "onclick" on a button, the functions is not lunched.
So far:
1.- The functions is well structurated.
2.- HTML onclick lunches any "alert();" message, but the one calling my function. Just a prompt asking for your name is lunched.
I've searched Google and here.
Javascript function will not activate onClick1 (but this is not my case, since my function do work).
JSFIDDLE:
Here is my code:
HTML:
<section>
<button onclick="alert(messageParts.join(''));">Click to enter your name!</button>
</section>
JS:
function getMonthName(index) {
var months = ["January", "February", "March",
"April", "May", "June", "July", "August",
"September", "October", "November", "December"];
return months[index];
}
function abbrName(text) {
return text.substr(0,3);
}
var date = new Date();
var messageParts = [
"Hello, ",
prompt("Please, enter your name","Please, enter your name"),
". Today is ",
date.getDate(),
" ",
abbrName(getMonthName(date.getMonth())),
" ",
", ",
date.getFullYear()
];
UPDATE 1:
1.- I think i have to use 'comillas simples' when calling a functions with "" in the outside. Now my function works, but not 100% as wished:
1.1.- The prompt is launched when page loads, when it should be launched when clicking the button.
1.2.-You have to enter a name when the prompt is launched, because it's not launched anymore.

", you cant use"once more inside - you need to change it to'example: you cant use"Hi ("name")", you should use"Hi ('name')"