JSFiddle - React, Tailwind, and code Playground

by dhiren_kaunar

HTML

<div ng-app="stepByStepApp">
        <input type="text" ng-model="text" placeholder="Enter text" />
        <p>entered text is : {{ text | evenorodd }}</p>
    </div>

JavaScript

var stepByStepApp = angular.module("stepByStepApp", []);

        stepByStepApp.filter("evenorodd", function () {
            return function (input) {
                var result = "";
                input = input || "";
                //for (var i = 0; i < input.length; i++) {
                //    result = input.charAt(i) + result;
                //}
                if (input != "") {
                    if (input % 2 == 0)
                        result = "even";
                    else
                        result = "odd";
                }
                return result;
            }
        });