JSFiddle - React, Tailwind, and code Playground

by Pratik Galoria

JavaScript

const getClass = (weight) => {
	if (weight < 60) {
  	return 'small';
  } else if (weight > 60 && weight < 80) {
  	return 'medium';
  } else {
  	return 'large';
  }
};

const getWeight = () => {
	let weight = 0;
  while (weight === 0) {
   weight = Number(window.prompt('Enter the weight'));
  }
  
  return weight;
};

const weight = getWeight();
alert(getClass(weight));