JSFiddle - React, Tailwind, and code Playground

by lavisha99

JavaScript

// -------------- lab 8  review

/*
Problem 1
Write a program for Bitcoulls, a fictitious book retailer, to simulate a book auction:

Initial set up using variables and appropriate data types:

Create an array of books (at least five books). Each up book must have a title. Make up the titles for each book. Set each book's price to $32.50.

Create two customers. Each customer must have a name and a collection of books (initially empty).
Business logic:

To simulate the auction, auction off each book by:
Determining for both customers three values: makeBid, bidIncrement, and bidIncrease.
makeBid: a randomly determined boolean representing whether or not the customer makes a bid.
bidIncrement: a random number between 1% and 10% of the book's price.
bidIncrease : a randomly determined boolean. If true, the customer's bid amount is their increment on top of the book's price; if false, the customer's bid amount is their increment below the book's price. For example, for bidIncrement = 10%, and bidUp = true, a customer's bid amount is $35.75 (32.5 + 3.25). 
The winner of the auction is the customer with the highest bid amount. Add the book to the winner's list of books.
Show the total each customer needs to pay Bitcoulls for the books they won.
Constraints:

You must use constructor functions to create the objects representing books and customers. */
/*

*/
let Books = [{
    Title: 'Flower',
    Price: 32.50
  },
  {
    Title: 'Beach',
    Price: 32.50
  },
  {
    Title: 'Food',
    Price: 32.50
  },
  {
    Title: 'employment',
    Price: 32.50
  },
  {
    Title: 'Family',
    Price: 32.50
  }
];
function customer(name, books) {
  this.name = name;
  this.books = books;
  this.makeBid = function bidtrue() {
    let checktrue = null
    let randno = Math.floor(Math.random() * 2 + 1);
    if (randno === 2) {
      checktrue = true
    } else {
      checktrue = false
    }
    console.log('customer made a bid: ' + checktrue);
    return checktrue

  }
 ...