JavaScript 2022

Term 3 Wednesday

May - July 2022

This site will be updated live during the sessions

Week 8 1 Object Loop

		
001const car = {
		
002	doors: 4,
		
003	colour: 'red',
		
004	maxspeed: 120
		
005}
		
006for(const property in car)
		
007{
		
008	console.log('propety name: ' + property);
		
009	console.log('Value : ' + car[property]);
		
010}
		
011console.log(car.colour);
		
012if(car.hasOwnProperty('lights'))
		
013{
		
014	console.log(car.lights);
		
015}
		
016else{
		
017	console.log('the car doesn\'t have lights');
		
018}
		
019