(New to programming) Why doesn't this work?

I am new to programming in unity and after searching for stuff online i thought this was going to work, but it doesn’t.

Here’s the code:

using UnityEngine;

public class weaponAttack : MonoBehaviour
{
    [SerializeField]
    private float secondAttackDelay = 10f;
    private float secondAttackTimer = 0f;

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            secondAttackTimer += 1;
            if (secondAttackTimer >= secondAttackDelay)
            {
                Debug.Log("Stab!");
                secondAttackTimer = 0;
            }
            if (Input.GetMouseButtonUp(0) && secondAttackTimer < secondAttackDelay)
            {
                Debug.Log("Slash!");
            }
        }
    }
}

What i want is so that when you click the console displays “Slash!”, but when you hold down the mouse button for long enough(secondAttackDelay) the console would show “Stab!” instead. It always displays “Stab!” no matter how quick i am to click.

What is the problem here?

Can i use a coroutine to do the timing? (I tried it)

[SerializeField]
private float secondAttackDelay = 10f;
private float secondAttackTimer = 0f;

void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        secondAttackTimer = 0 ;
    }   
    else if (Input.GetMouseButton(0))
    {
        secondAttackTimer += Time.deltaTime ;
    }
    else if ( Input.GetMouseButtonUp(0) )
    {
        if( secondAttackTimer < secondAttackDelay)
            Debug.Log("Slash!");
        else
            Debug.Log("Stab!");
            
        secondAttackTimer = 0 ;
    }
}

If you want to “stab” automatically:

[SerializeField]
private float secondAttackDelay = 10f;
private float secondAttackTimer = 0f;
private bool preparingSecondAttack;

void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        secondAttackTimer = 0 ;
        preparingSecondAttack = true;
    }   
    else if (preparingSecondAttack && Input.GetMouseButton(0))
    {
        secondAttackTimer += Time.deltaTime ;
        
        if( secondAttackTimer >= secondAttackDelay)
        {
            Debug.Log("Stab!");
            preparingSecondAttack = false ;
        }
    }
    else if ( preparingSecondAttack && Input.GetMouseButtonUp(0) )
    {
        if( secondAttackTimer < secondAttackDelay)
            Debug.Log("Slash!");
            
        secondAttackTimer = 0 ;
        preparingSecondAttack = false ;
    }
}