Pass string value to a function in JavaScript

Description

The following code shows how to pass string value to a function.

Example


<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
<!--   ww  w  . j  a  v a 2  s.c o  m-->
yourMessage('hi ');
yourMessage('java2s.com');

function yourMessage(quote)
{
document.writeln(quote);
}
</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Pass string value to a function in JavaScript