Using JavaScript
Using Jupyter JavaScript kernel
console.log("Fruits");
var msg = "I love fruits";
console.log(msg);
function Fruit(name , color) {
this.name = name;
this.color = color;
this.role = "";
}
Fruit.prototype.setRole = function(role) {
this.role = role;
}
Fruit.prototype.toJSON = function() {
const obj = {name: this.name, color: this.color};
const json = JSON.stringify(obj);
return json;
}
var x = new Fruit("Apple", "red");
logItType(x);
logItType(x.toJSON());
scrollX.setRole("x");
logItType(x);
logItType(x.toJSON());