Constructor Test 2

by Emily Humphrey

HTML

<div id="article-contain"></div>

JavaScript

var container = document.getElementById("article-contain");

Book.prototype = {
    forSale: function(){
        if(this.inStock === true && this.price > 0){
            return true;
        } else{
            return false;
        }
    }
};

function Book(author, date, pages, inStock, price){
    this.author = author;
    this.date = date;
    this.pages = pages;
    this.inStock = inStock;
    this.price = price;
}

var book1 = new Book("first", "1964", 364, false, 20);
var book2 = new Book("second", "1924", 61, true, 0);
var book3 = new Book("third", "2003", 1027, true, 20);
var book4 = new Book("fourth", "2011", 2099, true, 80);

alert(book4.forSale());