I feel kind of dumb for asking this but I can't figure out this code challenge. I have to initialize a number with a value of one. Then I have to double this number till it's higher than 1000. After which it will be halved until it reaches 1 again, vice versa.
This is what I have so far. Obviously, it doesn't work as once it goes over 1000 and gets halved it will meet the requirement to get doubled again. I feel pretty stupid for not seeing the solution. Any help would be appreciated.
session_start();
$getal = 1;
if(isset($_SESSION['getal'])){
if($_SESSION['getal'] <= 1000){
$_SESSION['getal'] *= 2;
}elseif ($_SESSION['getal'] > 1000){
$_SESSION['getal'] *= 0.5;
}
}
else{
$_SESSION['getal'] = $getal;
}