JSFiddle - React, Tailwind, and code Playground

by jhadesdev

HTML

<div ng-app="Calculator"  ng-controller='CalculatorCtrl' class='center'>
    <h1>Interactive Calculator</h1>
    <input  type="text" ng-model="model.left"> * 
    <input type="text" ng-model="model.right"> = 
        <span>{{mult()}}</span>
</div>

CSS

.center {
    text-align:center;
    margin-top: 100px;
}

JavaScript

function isNumber(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}

angular.module('Calculator', [])
 .controller('CalculatorCtrl', function($scope) {
$scope.model = {
left: 10,
right: 10
};

$scope.mult = function() {
var result = $scope.model.left * $scope.model.right;
    return isNumber(result) ? result : 'Error!';
}
});