Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am a beginner at Javascript and don\'t know whats wrong with my code. I\'m sur

ID: 3536254 • Letter: I

Question

I am a beginner at Javascript and don't know whats wrong with my code. I'm sure its because of the function or the button because thats what doesn't work.


<!DOCTYPE html>

<html>

<head>

<title>Test File</title>

<style>

body {

border: 10px solid green;

}

</style>

</head>

<body>

<script>

function myFunction() {

var tax = 0.08;

var x = document.getElementById("cdonuts").value;

var y = document.getElementById("gdonuts").value;

var z = document.getElementById("name").value;

var a = document.getElementById("minutes").value;

alert(z + " ,your total cost will be: $ " + (x*.5 + y*.5)*tax + (x*.5 + y*.5) + "and you can pick up in" + minutes);

}

</script>

<div id="example"></div>

<h1>Duncan's Just-In-Time-Donuts</h1>

<img src="iRock.png"/><h2><i>All donuts 50 cents each, cake or glazed!</i></h2>

<br />

<br />

<br />

<div >

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

Name:<input id ="name" type ="text" /><br />

&nbsp;&nbsp;&nbsp;&nbsp;

# of cake donuts:<input id ="cdonuts" type ="number" max ="50" min ="0"/>

<br />

&nbsp;

# of glazed donuts:<input id ="gdonuts" type ="number" max ="50" min ="0"/>

<br />

Minutes 'till pickup:<input id =" minutes" type = "number" min ="0"/>

<br />

<br />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<input type ="button" value ="Calculate" />

</div>


</body>

</html>

Explanation / Answer

in this line you have made a mistake input id =" minutes" type = "number" min ="0" id is given as " minute" instead of "minute" a space lies in the id " minute" and replace id=" minute"m with id="minute" so the line goes like this input id ="minutes" type = "number" min ="0" Thank you !