programming-examples/js/Others/Accepting Either One or No Arguments.js
2019-11-15 12:59:38 +01:00

27 lines
690 B
JavaScript

<html>
<head>
<title>JavaScript Unleashed - Happy Codings :-) C++, C#, HTML, Java, JavaScript Code Examples</title>
<script type="text/javascript">
<!--
function welcomeMessage(userName) {
if (userName != null) {
document.writeln("Hello, " + userName);
}else{
document.write("variable \"userName\" would show : ");
document.writeln(userName);
}
}
// -->
</script>
</head>
<body>
<script type="text/javascript">
<!--
document.writeln("First call to welcomeMessage(),\n");
welcomeMessage("Mr.");
document.writeln("<HR>\nSecond call to welcomeMessage(),\n");
welcomeMessage();
// -->
</script>
</body>
</html>