JSFiddle - React, Tailwind, and code Playground

by charlescarver

JavaScript

function pixelsToInches(x, y, p){
    var height = Math.round(Number(x/p)*100)/100;
    var width = Math.round(Number(y/p)*100)/100;
    return [height, width];
}

alert(pixelsToInches(20, 20, 96));