Question:What will be output of the following javascript code:
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled Document</title>
<script>
var tax=.02
function addTax(item){
  var total=item+(item+tax);
  var newTotal=Math.floor(total);
  var fraction=Math.round(total*100)%100;
  if(fraction<10){
	fraction="0"+fraction
  }
  
  total=newTotal+"."+fraction
  alert("Your total is $"+total);
  	
}

</script>
</head>
<body>
<script>
 addTax(1.5);
</script>
</body>
</html>
 

A Your total is $3.02 

B Compile error 

C Your total is $1.5 

D Your total is $total 

+ Answer
+ Report
Total Preview: 797

Copyright © 2024. Powered by Intellect Software Ltd