website/src/helpers.js

26 lines
561 B
JavaScript
Raw Normal View History

2020-03-01 20:40:51 +01:00
export const haveSelectedGas = (station, gas) => {
if (!station.prices || station.prices.length === 0 ) {
return false;
}
for (let i = 0 ; i < station.prices.length ; i +=1 ){
if (station.prices[i].gasType === gas ) {
2020-03-01 20:40:51 +01:00
return true;
}
}
return false;
}
2020-03-04 18:45:01 +01:00
export const lowerCaseString = (string) => {
if ( !string){
return '';
}
return string.toLowerCase();
}
2020-03-01 21:17:51 +01:00
export const capitalizeFirstLetter = (string) => {
if ( !string){
return '';
}
2020-03-04 18:45:01 +01:00
return string.charAt(0).toUpperCase() + lowerCaseString(string.slice(1));
2020-03-01 21:17:51 +01:00
}