JavaScript 2022

Term 3 Wednesday

May - July 2022

This site will be updated live during the sessions

Week 7 Example 3 Inner Function Scope

		
001function calculateVAT(){
		
002	const VAT = 20;
		
003	let price = 10;
		
004	console.log('output from calculateVAT()');
		
005	console.log(`price: ${price}, vat: ${VAT}`);
		
006	function doSomething(){
		
007		price = 20;
		
008		console.log(`output from doSomething() ${price}`);
		
009	}
		
010	function doSomethingToo(){
		
011		let fee = 20;
		
012		if(typeof price !== "undefined") 
		
013		{
		
014			fee = 12;
		
015		}
		
016		console.log(`doSomethingToo() price: ${price}, fee: ${fee}`);
		
017	}
		
018	doSomething();
		
019	doSomethingToo();
		
020}
		
021calculateVAT();
		
022/*
		
023let output = '£' + price + ' is todays sale price';
		
024let output2 = `£${price} is today's sale price`
		
025*/;