Created
May 9, 2014 15:47
-
-
Save LESTADru/b37ef7429a5aecd777f0 to your computer and use it in GitHub Desktop.
Объект с тремя методами запрашивает два значения,
сохраняет их в свойства. Считает сумму и произведение этих чисел.
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
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title></title> | |
</head> | |
<body> | |
<script> | |
'Use Strict' | |
var calculator = { | |
readValues : function() { | |
this.value1 = +prompt("Enter first value", "0"); | |
this.value2 = +prompt("Enter second value", "0") | |
}, | |
sum : function() { | |
return this.value1 + this.value2; | |
}, | |
mul : function() { | |
return this.value1 * this.value2; | |
} | |
} | |
calculator.readValues(); | |
alert( calculator.sum() ); | |
alert( calculator.mul() ); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment