JSFiddle - React, Tailwind, and code Playground

by Josh Pullen

JavaScript

console.log(m`sin(x) + cos(x)`({ x: m`${5}deg` }));

function m(strings, ...values) {
	if (values.length > 0) {
  	return values[0] * Math.PI / 180;
  }
  
  return ({ x }) => Math.sin(x) + Math.cos(x);
}