Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


JavaScript Programming

JavaScript > Code Examples

Accepting Either One or No Arguments

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Accepting Either One or No Arguments <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>