Click the below button to generate JavaScript Tips.


Click the above button to generate JavaScript Tips.





Here is the Java Script code explanation

// Clicking this button will call function getJavascriptTips() 
<button name="button" onclick="getJavascriptTips()" >Generate the next JavaScript Tip!!!</button>

// The function getJavascriptTips() will display the JavaScript tip here in this para
<p id="tips">Click the above button to generate JavaScript Tips.</p>

<script>
// Array of 10 tips
var tipsArray = [
"JavaScript took just 10 days to develop.",
"JavaScript was probably named after Java.",
"GitHub says JavaScript is the Most Popular language in the world.",
"JavaScript is responsible for Web2.",
"JavaScript has many implementations.",
"JavaScript was initially created as a browser-only language.",
"JavaScript is the Programming Language Of The Web.",
"JavaScript is single threaded. ",
"Along with HTML an CSS, JavaScript is one of the three main things of the www (World Wide Web).",
"In JavaScript semi colon can be used at the beginning of a statement.",
];
								       
// this function is called upon button click
function getJavascriptTips() {
	var time = new Date().getMilliseconds(); //get current time
	var arrayIndex = time % 10; // get the arrray index value < 10
	document.getElementById("tips").innerHTML = tipsArray[arrayIndex]; // replace the p element tips 
}
</script>