Revision c7b51d0f-d935-445b-9e02-77dd7984f2e3 - Code Review Stack Exchange

## Initial Comments
[@MarkRohloff](https://codereview.stackexchange.com/users/130137/marc-rohloff)'s [comment](https://codereview.stackexchange.com/questions/204467/validate-email-as-user-is-typing-javascript#comment394357_204467) is good:

>My recommendation would be to set the `<input>` elements type to `email` and let the browser worry about the validation.

Furthermore, while you stated "_A valid email is defined as follows: `^[a-z0-9]*[@][a-z]*[.][a-z]{1,3}$`_", I am reminded of [this SO answer for a regex for validating email addresses](https://stackoverflow.com/a/611784/1575353), which also reminds me of [the great answer about parsing HTML with regular expressions](https://stackoverflow.com/a/1732454/1575353).


## Code Review
Let's look at the function `valideEmail()`. This function has a lot of coupling - with the view (i.e. input elements, output elements). If something needs to be updated in the HTML, then this function may need to be updated as well. A less-coupled approach might be to accept a single value and return a boolean value. That way the controlling code can pass the value (e.g. from the HTML view, or test code could pass test values) and then use the result accordingly (e.g. display a message in the view, or for test code it might compare the result with expected results).

Also, [`String.prototype.includes()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) (used in ` value.includes('.')` in some of those conditional statements) appears to be a feature of EcmaScript-2015 A.K.A. es-6. Thus you could use other es-6 features, like [`String.prototype.endsWith()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith) instead of `value[value.length - 1]`, as well as arrow functions.

Additionally, DOM lookups (e.g. `$('#emailInput')`, `$('#emailDisplay')`) are not cheap, so it is wise to store those in a variable (and use `const` since you are using es-6 code), and utilize the variables whenever needed later.

AltStyle によって変換されたページ (->オリジナル) /