JSFiddle - React, Tailwind, and code Playground

by Emily Humphrey

JavaScript

class Size {
    constructor(width, height) {
        this.width = width;
        this.height = height;
    }
}

class Image {
    constructor(url, size) {
        this.url = `hackerrank.com/image/${url}`;
        this.size = size ? size : new Size(0,0);
    }
    getUrl(){
        return this.url;
    }
    setUrl(url){ 
        this.url = `hackerrank.com/image/${url}`;
    }
    getSize(){
        return this.size;
    }
    setSize(size){
        this.size = size;
    }
    cloneImage(){
			return new Image(this.url,this.size);
		}
}

const image1 = new Image(1, new Size(163,160));
const image2 = new Image(2, new Size(213,210));
const image3 = new Image(3, new Size(363,360));
const image4 = new Image(4, new Size(443,440));

var imageSize = image1.cloneImage();

console.log(image1.getSize().width);