JSFiddle - React, Tailwind, and code Playground

by Diya_Khan

JavaScript

function Apple (type) {
    this.type = type;
    this.color = "red";
    this.getInfo = getAppleInfo;
}

// anti-pattern! keep reading...
function getAppleInfo() {
    return 'color:' + this.color + ', type: ' + this.type + ', apple';
}

var apple = new Apple('macintosh');
//apple.color = "reddish";
alert(apple.getInfo());