Длительность прогулки


#1

var temperature = 20;
var itsRaining = false;

var idealnaTemperature = 20;
var n;
var minutes;

if(itsRaining || temperature < 0 || temperature > 35){
minutes = 0;
}else if(temperature == 20){
minutes = 20;
}else{
if(temperature > idealnaTemperature){
n = temperature - idealnaTemperature;
minutes = idealnaTemperature - n;
}else if(temperature < idealnaTemperature){
minutes = temperature;
}
}


#2

Можно немного проще.

var temperature = 35;
var itsRaining = false;
var idealTemperature = 20;
var minutes;

if (temperature < 0 || temperature > 35 || itsRaining) {
minutes = 0;
} else if (temperature > 20 && temperature <= 35) {
minutes = idealTemperature - ( temperature - idealTemperature);
}


#3

можно еще проще :sunglasses:


#4

Теперь вроде ещё проще )


#5

можно исчо проще =) без else


#6

var temperature = 20;
var itsRaining = false;

var minutes = 0;

if(temperature>0 && temperature<35 &&!itsRaining) {minutes = 20 - Math.abs(20 - temperature)};


#7

такого ещо кекс не расказивал