Created
December 20, 2018 21:37
-
-
Save kshitij-srv/e2a0d7b130658cb9c67ebf4cfd1dca86 to your computer and use it in GitHub Desktop.
// source https://jsbin.com/gaborig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>Animal's name: <input type="text" id="f" size="10"></p> | |
<p>Animals sound: <input type="text" id="s" size="10"></p> | |
<button id="b" class="myButton">Introduce Animal</button> | |
<span id="write"></span> | |
<script id="jsbin-javascript"> | |
var theButton = document.getElementById("b"); | |
theButton.onclick = onButtonClick; | |
function Animal(name, sound) { | |
this.name = name ? name : this.name; | |
this.sound = sound ? sound : this.sound; | |
} | |
Animal.prototype.introduce = function() { | |
return this.sound + "! I am a " + this.name; | |
} | |
Animal.prototype.name = "Pikachu"; | |
Animal.prototype.sound = "Pika-pika"; | |
function introduceAnimal( first, second ) { | |
var animal = new Animal(first, second); | |
return animal.introduce(); | |
} | |
function onButtonClick() { | |
var box1 = document.getElementById("f").value; | |
var box2 = document.getElementById("s").value; | |
var result = introduceAnimal( box1, box2 ); | |
var place = document.getElementById("write"); | |
place.innerHTML = result; | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var theButton = document.getElementById("b"); | |
theButton.onclick = onButtonClick; | |
function Animal(name, sound) { | |
this.name = name ? name : this.name; | |
this.sound = sound ? sound : this.sound; | |
} | |
Animal.prototype.introduce = function() { | |
return this.sound + "! I am a " + this.name; | |
} | |
Animal.prototype.name = "Pikachu"; | |
Animal.prototype.sound = "Pika-pika"; | |
function introduceAnimal( first, second ) { | |
var animal = new Animal(first, second); | |
return animal.introduce(); | |
} | |
function onButtonClick() { | |
var box1 = document.getElementById("f").value; | |
var box2 = document.getElementById("s").value; | |
var result = introduceAnimal( box1, box2 ); | |
var place = document.getElementById("write"); | |
place.innerHTML = result; | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var theButton = document.getElementById("b"); | |
theButton.onclick = onButtonClick; | |
function Animal(name, sound) { | |
this.name = name ? name : this.name; | |
this.sound = sound ? sound : this.sound; | |
} | |
Animal.prototype.introduce = function() { | |
return this.sound + "! I am a " + this.name; | |
} | |
Animal.prototype.name = "Pikachu"; | |
Animal.prototype.sound = "Pika-pika"; | |
function introduceAnimal( first, second ) { | |
var animal = new Animal(first, second); | |
return animal.introduce(); | |
} | |
function onButtonClick() { | |
var box1 = document.getElementById("f").value; | |
var box2 = document.getElementById("s").value; | |
var result = introduceAnimal( box1, box2 ); | |
var place = document.getElementById("write"); | |
place.innerHTML = result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment