JSFiddle - React, Tailwind, and code Playground

by velmurugansp

JavaScript

// Convert INR to USD
// 1 USD = 80 INR
// 1 INR = 1/80 USD

function dollarToInr(usd){
	usd = parseInt(usd);
  let inr = usd * 80;
  console.log("$: " + usd + " = Rs " + inr)
}

function inrToDollar(inr){
  inr = parseInt(inr);
  let usd = inr / 80;
  console.log("Rs: " + inr + " = $ " + usd);
}

function showWarning(){
	console.log("Enter correct conversion type.");
}


let value = prompt("Enter a number"),
		conversionType = prompt("Enter D2I or I2D");

if(conversionType == 'D2I'){
	dollarToInr(value);
}else if(conversionType == 'I2D'){
	inrToDollar(value);
}else{
	showWarning();
}