How to get a image to scale up and down in a loop

I’m trying to get this image to scale up till scale=2 then scale down till scale=1 and repeat the cycle forever.
I know how to scale up and down but the loop I’m setting up isn’t working. Can someone help me out with this.

displayMode(FULLSCREEN)

function setup()
    imageName = asset.builtin.SpaceCute.Beetle_Ship
    imageSize = spriteSize(imageName)
    scaler = 1
    x,y=WIDTH/2,HEIGHT/2
end

function draw()
    background(0, 191)
    sprite(imageName,x,y,scaler*imageSize) 
    scaler=scaler+.01 
    --scaler=scaler+DeltaTime 
end 

Nvm, I figured it out. If anyone has a easier way then post plz.

displayMode(FULLSCREEN)

function setup()
    imageName = asset.builtin.SpaceCute.Beetle_Ship
    imageSize = spriteSize(imageName)
    scaler = 1
    x,y=WIDTH/2,HEIGHT/2
    t=ElapsedTime + 0.5
    timer=0   
end

function draw()
    background(0, 191)
    sprite(imageName,x,y,scaler*imageSize) 
   
    --scaler=scaler+DeltaTime 
    fill(255)
    if ElapsedTime>t then
        timer = timer + 1
        t=ElapsedTime + 0.5
    end
    text(timer,WIDTH/2+300,HEIGHT/2)
    
    if timer<2 then
    scaler=scaler+.01  
    end
       
    if timer>2 and timer<5 then
    scaler=scaler-.01  
    end
    
    if timer==5 then
        timer=0
        scaler=1
    end
end 

@jarc an approximation to what you have is to use the sine function. This cycles between-1 and 1 with time.
You could add a multiplier into elapsed time to change the speed


sprite(imageName,x,y,1.5*imageSize+0.5*imageSize* math.sin(ElapsedTime))     

Alternatively you could look into tweens.