encapsulating if statement in update

This will most probably have a stupidly easy explanation but I can’t get my head around this, I have a piece of code to create a simple GUI for holding a players level and experience:

#pragma strict

var currentXP : int = 0;
var maxXP : int = 500;
var XPtext : GUIText;
var Level : int = 1;

function Update () 
{
	XPtext.text = "Level " + Level + " XP " + currentXP + " / " + maxXP;
	if(currentXP == maxXP)
	
				//if(Input.GetKeyDown("r")) 
				//currentXP += 10;
		{
			LevelUpSystem ();
		}
}

function LevelUpSystem ()
{
	currentXP = 0;
	maxXP = maxXP + 50;
	Level ++;
}

I want to know how to incorporate this into the update function properly:

//if(Input.GetKeyDown("r")) 
//currentXP += 10;

Thanks!

#pragma strict

var currentXP : int = 0;
var maxXP : int = 500;
var XPtext : GUIText;
var Level : int = 1;
 
function Update () 
{
    XPtext.text = "Level " + Level + " XP " + currentXP + " / " + maxXP;
    if(currentXP == maxXP)
    {
        LevelUpSystem ();
    }
    else if (Input.GetKeyDown(KeyCode.R))
    {
        currentXP += 10;
    }
}
 
function LevelUpSystem ()
{
    currentXP = 0;
    maxXP = maxXP + 50;
    Level ++;
}

I take it this is what you’re looking for? ( i.e. either leveling up or pressing r to get XP).