0% found this document useful (0 votes)
4 views3 pages

Functions Assignment

The first document contains a JavaScript function that calculates a utility bill based on the number of units consumed, applying different rates for different consumption ranges and a discount for high usage. The second document includes a script that prints numbers from 1 to 100, replacing multiples of 3 with 'fizz', multiples of 5 with 'buzz', and multiples of both with 'fizzbuzz'. Both documents are structured as HTML with embedded JavaScript.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Functions Assignment

The first document contains a JavaScript function that calculates a utility bill based on the number of units consumed, applying different rates for different consumption ranges and a discount for high usage. The second document includes a script that prints numbers from 1 to 100, replacing multiples of 3 with 'fizz', multiples of 5 with 'buzz', and multiples of both with 'fizzbuzz'. Both documents are structured as HTML with embedded JavaScript.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1)

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

</head>

<body>

<script>

let units=prompt('enter the number of units');

function bill(){

if(units<=50){

totalBill=(units*1);

}else if(units>50 && units<=100){

totalBill=(50*1) + ((units-50)*2);

}else if(units>100 && units<=150){

totalBill=(50*1) + (50*2) + ((units-100)*3);

}else if(units>150 && units <=200){

totalBill=(50*1) + (50*2) + (50*3) + ((units-150)*4);

}else if(units>200){

billAmount=(50*1) + (50*2) + (50*3) + (50*4) + ((units-200)*5) ;

dis=billAmount * 0.10;

totalBill=billAmount - dis;

bill(units);

alert('your total bill is : ' + totalBill);


</script>

</body>

</html>

2)

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

</head>

<body>

<script>

for (let num=1; num <= 100; num++){

if (num%3===0 && num%5===0){

[Link]('fizzbuzz');

}else if(num%3===0){

[Link]('fizz')

}else if(num%5===0){

[Link]('buzz');

}else{

[Link](num);

</script>

</body>

</html>

You might also like