how to pass js variable as an argument in html function code example

Example 1: javascript function variable arguments

function foo() {
  for (var i = 0; i < arguments.length; i++) {
    console.log(arguments[i]);
  }
}

foo(1,2,3);
//1
//2
//3

Example 2: How to Pass Parameter in JavaScript Function From Html

<!DOCTYPE html>
<html>
<head>
	<title>function parameters javascript</title>
</head>
<body>
<button onclick="myfunctionName('rohan')">Click</button>

<script type="text/javascript">
	
	function myfunctionName(a){

		alert(a);
		
	}

</script>
</body>
</html>