Basically, this repository is for the coding chanlengings of the course: The Complete JavaScript Course 2022: From Zero to Expert! If you also bought this course and want to know my solution, you can check my practice index following:
- branch : feat/section2CodingChallenging#1
- task: Mark and John are trying to compare their BMI (Body Mass Index), which is calculated using the formula: BMI = mass / height ** 2 = mass / (height * height) (mass in kg and height in meter).
- Your tasks:
- StoreMark'sandJohn's mass and heightin variables
- Calculate both their BMIs using the formula (you can even implement both versions)
- Create a Boolean variable 'markHigherBMI' containing in formation about whether Mark has a higher BMI than John.
- Test data: § Data 1: Marks weights 78 kg and is 1.69 m tall. John weights 92 kg and is 1.95 m tall. § Data 2: Marks weights 95 kg and is 1.88 m tall. John weights 85 kg and is 1.76 m tall.
-
branch : feat/section2CodingChallenging#3
There are two gymnastics teams, Dolphins and Koalas. They compete against each other 3 times. The winner with the highest average score wins a trophy! Your tasks:
- Calculatetheaveragescoreforeachteam,usingthetestdatabelow
- Comparetheteam'saveragescorestodeterminethewinnerofthecompetition, and print it to the console. Don't forget that there can be a draw, so test for that as well (draw means they have the same average score)
- Bonus1:Includearequirementforaminimumscoreof100.Withthisrule,a team only wins if it has a higher score than the other team, and the same time a score of at least 100 points. Hint: Use a logical operator to test for minimum score, as well as multiple else-if blocks 😉
- Bonus2:Minimumscorealsoappliestoadraw!Soadrawonlyhappenswhen both teams have the same score and both have a score greater or equal 100 points. Otherwise, no team wins the trophy Test data: § Data 1: Dolphins score 96, 108 and 89. Koalas score 88, 91 and 110 § Data Bonus 1: Dolphins score 97, 112 and 101. Koalas score 109, 95 and 123 § Data Bonus 2: Dolphins score 97, 112 and 101. Koalas score 109, 95 and 106
- branch : feat/section2CodingChallenging#4 Steven wants to build a very simple tip calculator for whenever he goes eating in a restaurant. In his country, it's usual to tip 15% if the bill value is between 50 and 300. If the value is different, the tip is 20%. Your tasks:
- Calculatethetip,dependingonthebillvalue.Createavariablecalled'tip'for this. It's not allowed to use an if/else statement 😅 (If it's easier for you, you can start with an if/else statement, and then try to convert it to a ternary operator!)
- Printastringtotheconsolecontainingthebillvalue,thetip,andthefinalvalue (bill + tip). Example: “The bill was 275, the tip was 41.25, and the total value 316.25” Test data: § Data 1: Test for bill values 275, 40 and 430 Hints: § To calculate 20% of a value, simply multiply it by 20/100 = 0.2 § Value X is between 50 and 300, if it's>= 50 && <= 300😉
- branch : feat/section3CodingChallenging#1
Back to the two gymnastics teams, the Dolphins and the Koalas! There is a new gymnastics discipline, which works differently. Each team competes 3 times, and then the average of the 3 scores is calculated (so one average score per team). A team only wins if it has at least double the average score of the other team. Otherwise, no team wins! Your tasks:
- Createanarrowfunction'calcAverage'tocalculatetheaverageof3scores
- Usethefunctiontocalculatetheaverageforbothteams
- Createafunction'checkWinner'thattakestheaveragescoreofeachteam as parameters ('avgDolhins' and 'avgKoalas'), and then logs the winner to the console, together with the victory points, according to the rule above. Example: "Koalas win (30 vs. 13)"
- Usethe'checkWinner'functiontodeterminethewinnerforbothData1and Data 2
- Ignoredrawsthistime Test data: § Data 1: Dolphins score 44, 23 and 71. Koalas score 65, 54 and 49 § Data 2: Dolphins score 85, 54 and 41. Koalas score 23, 34 and 27 Hints: § To calculate average of 3 values, add them all together and divide by 3 § To check if number A is at least double number B, check for A >= 2 * B. Apply this to the team's average scores 😉
- branch : feat/section3CodingChallenging#2 Steven is still building his tip calculator, using the same rules as before: Tip 15% of the bill if the bill value is between 50 and 300, and if the value is different, the tip is 20%. Your tasks:
- Writeafunction'calcTip'thattakesanybillvalueasaninputandreturns the corresponding tip, calculated based on the rules above (you can check out the code from first tip calculator challenge if you need to). Use the function type you like the most. Test the function using a bill value of 100
- Andnowlet'susearrays!Socreateanarray'bills'containingthetestdata below
- Createanarray'tips'containingthetipvalueforeachbill,calculatedfrom the function you created before
- Bonus:Createanarray'total'containingthetotalvalues,sothebill+tip Test data: 125, 555 and 44 Hint: Remember that an array needs a value in each position, and that value can actually be the returned value of a function! So you can just call a function as array values (so don't store the tip values in separate variables first, but right in the new array) 😉
- branch : feat/section3CodingChallenging#3 Let's go back to Mark and John comparing their BMIs! This time, let's use objects to implement the calculations! Remember: BMI = mass / height ** 2 = mass / (height * height) (mass in kg and height in meter) Your tasks:
- For each of them, create an object with properties for their full name,mass,and height (Mark Miller and John Smith)
- Create a 'calcBMI' method on each object to calculate the BMI(thesame method on both objects). Store the BMI value to a property, and also return it from the method
- Log to th econsole who has the higher BMI, together with the full name and the respective BMI. Example: "John's BMI (28.3) is higher than Mark's (23.9)!" Test data: Marks weights 78 kg and is 1.69 m tall. John weights 92 kg and is 1.95 m tall.
- branch : feat/section5CodingChallenging#1
Given an array of forecasted maximum temperatures, the thermometer displays a string with the given temperatures. Example: [17, 21, 23] will print "... 17oC in 1 days ... 21oC in 2 days ... 23oC in 3 days ..." Your tasks:
- Create a function 'printForecast' which takes in an array 'arr' and logs a string like the above to the console. Try it with both test datasets.
- Use the problem-solving framework: Understand the problem and breakitup into sub-problems! Test data: § Data 1: [17, 21, 23] § Data2:[12,5,-5,0,4]