Hello,

This is how my code looks now:

Code:
//var car already retrieved
//var bus already retrieved
if ( typeof(car) != "undefined" ) {
	
	var year = process(car);
	if( year === false ) {
		//do something
	} else {
		//do something else
	}	
	
}else{
	
	if (typeof( bus ) != "undefined") {

		var year = process(bus);
		if (year === false) {
			//do something
		} else {
			//something else	
		}
	
	} else {
		//do something
	}

}
I know it sucks. It could be wrapped in a function, it could be an object, it could many things that it is not. It's working, but it's lacking elegancy, and completely missing the point good-practice-wise.

I would like to learn how such a simple snippet could be improved.

a) I look if a car variable.
b) if it doesn exist, I look for a bus variable (in the future I will look at other types of vehicles).

Can someone help me refactor this, put on the path of well-written code?