Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
function Hamburg(size, filling, extended) {
    
    this.cost = 0;
    this.calories = 0;
    
    this.size = size;
    this.filling = filling;
    this.extended = extended;
    
    this.setProperties = function() {
        if (this.size == 'small') {
            this.cost += 50;
            this.calories += 20;
        } else if (this.size == 'big'){
            this.cost += 100;
            this.calories += 40;
        }
        
        if (this.filling == 'cheese') {
            this.cost += 10;
            this.calories += 20;
        } else if (this.filling == 'salad') {
            this.cost += 20;
            this.calories += 5;
        } else if (this.filling == 'potato'){
            this.cost += 15;
            this.calories += 10;
        }
        
        if (this.extended == 'seasoning') {
            this.cost += 15;
        } else if (this.extended == 'sauce'){
            this.cost += 20;
            this.calories += 5;
        }
    };
    
    this.getResult = function() {
        
        this.setProperties();
        
        console.log('Цена: ' + this.cost + ' тугриков', 'Калорий: ' + this.calories);
    };
}
var ham = new Hamburg('small', 'cheese');
ham.getResult();
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
fxslokerpro
0viewers