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

By using Javascript and HTML in need to Create a new “aircraft” object (via obje

ID: 3667868 • Letter: B

Question

By using Javascript and HTML in need to Create a new “aircraft” object (via object constructor) that includes (among others) a speed property. Include a changeSpeed() method that will increase or decrease the aircraft speed based on the argument sent in the function call. For instance, changeSpeed(5) will increase speed by 5mph and changeSpeed(-5) decreases speed by 5mph. User enters the number and clicks a button to call the method. Use the prototype property to add a new property (range) and a new method (addFuel) to the aircraft prototype. As always, display results.

Explanation / Answer

<!DOCTYPE html>

<html>

<body>

   <form>

       Enter the value:

                         <input type="number" name="speed" id="speed" />

                           <input type="button" value="click to change" />

       </form>

    <script>

         function change()

             {

                    var speed;

                      this.changedspeed=function(changespeed){

                                  this.speed=this.speed+changespeed;

                                    }

       }

       var aircraft =new change();

              aircraft.changespeed(document.getElementById('speed").value);

              aircraft.range=100;

             aircraft.addFuel=function(){

                              return this is method created using prototype;

                       }

</script>

</body>

</html>