diff --git a/solutions/day-4/index.html b/solutions/day-4/index.html new file mode 100644 index 0000000..db95250 --- /dev/null +++ b/solutions/day-4/index.html @@ -0,0 +1,15 @@ + + + + + + + + Document + + + + + + + \ No newline at end of file diff --git a/solutions/day-4/level1.js b/solutions/day-4/level1.js new file mode 100644 index 0000000..29aebc0 --- /dev/null +++ b/solutions/day-4/level1.js @@ -0,0 +1,20 @@ +// 1.question +let age = parseInt(prompt('Enter your age:', 0)); +(age > 18) ? alert('You are old enough to drive.') : alert(`You are left with ${18 - age} years to drive.`); +// 2.question +let yourAge = parseInt(prompt('Enter your age:', 0)); +let myAge = age; +if (yourAge > myAge) { + console.log(`Your are ${yourAge-myAge} years older than me.`); +} else { + console.log(`Your are ${myAge - yourAge } years younger than me.`); +} +// 3.question +let a = parseInt(prompt('Enter number a:', 0)); +let b = parseInt(prompt('Enter number b:', 0)); +if (a > b) { console.log(`${a} is greater than ${b}`); } +else { console.log(`${b} is greater than ${a}`); } +(a>b)?console.log(`${a} is greater than ${b}`):console.log(`${b} is greater than ${a}`); +// 4.question +let num = parseInt(prompt('Enter number:', 0)); +((num%2)==0)?console.log(`${num} is an even number`):console.log(`${num} is an odd number`); diff --git a/solutions/day-4/level2.js b/solutions/day-4/level2.js new file mode 100644 index 0000000..a80817c --- /dev/null +++ b/solutions/day-4/level2.js @@ -0,0 +1,34 @@ +// 1.question +let marks = parseInt(prompt('Enter the marks:', 0)); +if (marks>=90&&marks<=100) { + console.log('A'); +}else if (marks>=70&&marks<90) { + console.log('B'); +}else if (marks>=60&&marks<70) { + console.log('C'); +}else if (marks>=50&&marks<60) { + console.log('D'); +} else { + console.log('F'); +} +// 2.question +let month = prompt('Enter the month name:'); +if (month == 'September' || month == 'October' || month == 'November') { + console.log('The season is Autumn'); +} else if (month == 'December' || month == 'January' || month == 'February') { + console.log('The season is Winter'); +} else if (month == 'March' || month == 'April' || month == 'May') { + console.log('The season is Spring'); +} else if (month == 'June' || month == 'July' || month == 'August') { + console.log('The season is Summer'); +} else { + console.log('Invalid month'); +} +// 3.question +let day = prompt('What is the day today?','Enter only days.').to; +if (day.toLowerCase() == 'saturday' || day.toLowerCase() == 'sunday') { + console.log(`${day} is a weekend.`); +} else { + console.log(`${day} is a working day.`); + +} \ No newline at end of file diff --git a/solutions/day-4/level3.js b/solutions/day-4/level3.js new file mode 100644 index 0000000..a4e5343 --- /dev/null +++ b/solutions/day-4/level3.js @@ -0,0 +1,78 @@ +// 1.question +let months = [ + { + month: 'january', + days:31 + }, + { + month: 'february', + days:28 + }, + { + month: 'march', + days:31 + }, + { + month: 'april', + days:30 + }, + { + month: 'may', + days:31 + }, + { + month: 'june', + days:30 + }, + { + month: 'july', + days:31 + }, + { + month: 'august', + days:31 + }, + { + month: 'september', + days:30 + }, + { + month: 'octuber', + days:31 + }, + { + month: 'november', + days:30 + }, + { + month: 'december', + days:31 + }, +] +let m = prompt('Enter a month:'); +for (let i = 0; i < months.length; i++){ + if (months[i].month == m.toLowerCase()) { + alert(`${m} has ${months[i].days} days.`); + } +} +// 2.question +let year = parseInt(prompt('Enter the year:', 0)); +for (let i = 0; i < months.length; i++){ + if ((year % 4) == 0) { + if (m.toLowerCase() == 'february') { + + alert(`${m} has 29 days.`); + break; + } + else { + if (m.toLowerCase() == months[i].month) { + alert(`${m} has ${months[i].days} days.`); + } + } + } + else { + if (m.toLowerCase() == months[i].month) { + alert(`${m} has ${months[i].days} days.`); + } + } +} \ No newline at end of file