-
Notifications
You must be signed in to change notification settings - Fork 1
SOC implemented #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
SPACE, | ||
TEMPERATURE_INPUT, | ||
CONVERT_TEMPERATURE_CONTAINER, | ||
MESSAGE_ERROR_NOT_INTEGER, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this file, only the TEMPERATURE_INPUT
is being used. You can remove the others.
SPACE, | |
TEMPERATURE_INPUT, | |
CONVERT_TEMPERATURE_CONTAINER, | |
MESSAGE_ERROR_NOT_INTEGER, | |
TEMPERATURE_INPUT, |
|
||
export const convertedTemperature = (fahrenheitTextList) => { | ||
if (!/^[0-9\s]*$/.test(fahrenheitTextList)) { | ||
window.alert(MESSAGE_ERROR_NOT_INTEGER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You defined MESSAGE_ERROR_NOT_INTEGER
constant as The '%S' contains values different of integer numbers
.
So, in the window.alert
you must replace the %S
by fahrenheitTextList
content. For example:
window.alert(MESSAGE_ERROR_NOT_INTEGER.replace('%S', fahrenheitTextList));
|
||
// Validate it | ||
if (fahrenheitTextList) { | ||
var convertedTempTextList = convertedTemperature(fahrenheitTextList); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use var
. It is not recommeded anymore. Use let
or const
.
var convertedTempTextList = convertedTemperature(fahrenheitTextList); | |
const convertedTempTextList = convertedTemperature(fahrenheitTextList); |
var convertedTemperatures = ''; | ||
fahrenheitList.forEach((fahrenheit) => { | ||
// Do the math | ||
const celsius = ((fahrenheit - 32) * 5) / 9; | ||
|
||
convertedTemperatures = convertedTemperatures + ' ' + celsius.toFixed(2); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use var. It is not recommeded anymore. Use let or const.
Tip: use map
and join
functions. This will avoid the empty space at the beginning of the returned convertedTemperatures.
var convertedTemperatures = ''; | |
fahrenheitList.forEach((fahrenheit) => { | |
// Do the math | |
const celsius = ((fahrenheit - 32) * 5) / 9; | |
convertedTemperatures = convertedTemperatures + ' ' + celsius.toFixed(2); | |
}); | |
const convertedTemperatures = fahrenheitList.map((fahrenheit) => { | |
const celsius = ((fahrenheit - 32) * 5) / 9; | |
return celsius.toFixed(2); | |
}).join(' '); |
No description provided.