Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
McLarenCollege / ticketPriceUsingIfElseIfPart1Solution.md
Created Jul 6, 2022
Ticket Price Using If Else If Part1 Solution
View ticketPriceUsingIfElseIfPart1Solution.md
let age = 23;
let day = 'Monday';
let price;
if (age <= 12) {
    price = 50;
}
if (age >= 65) {
    if (day === 'Saturday' || day === 'Sunday') {
 price = 70;
View foundationsSyllabus.md

Foundations Course Syllabus

  • Basic Data Types and Operators (String, Number, +, -)
  • Variables (Declaration, Assignment, Naming rules)
  • Compound Expressions (%, ++, --, +=)
  • Boolean data type and logical operators (or, and, not)
  • If/else and Ternary Operator
  • Functions
  • Arrays and Loops
  • Objects
  • Array and String Methods
View functionTracing.md

Write down your function tracing

function rossy(state) {
    return (state === 4);
}

function maxwell(a, b) {
    return rossy(a) || (a > b);
}
@McLarenCollege
McLarenCollege / averageOfNumbers.md
Last active Jan 18, 2022
Exercise Name : Average Of Three Numbers
View averageOfNumbers.md

Here is an example of a function

function square(num){
   let squareOfNum = num * num;
   return squareOfNum;
}
let result = square(5);
console.log("The square is " + result);

Write a function named averageOf3 that takes three numbers as parameters and returns the average of the three numbers.

View functions3.md

Write a function names getExamResult that accepts the students marks of three subjects as arguments and returns the strings "pass" or "fail" depending on whether he has passed or failed .For passing the average score should be greater than or equal to 40. Please use the ternary operator to solve this question. Dont use if-else.

// Write your function here
function ...



// Here we will test our function with some input values
let geometryScore = 55;
View functions hw2.md

Write a function called findGreatest that accepts three numbers as arguments and returns the greatest of the three numbers using if-else statemets

let num1 = 5;
let num2 = 6;
let num3 = 7;

// Write your function here
View function hw1.md

Write a function named getTicketPrice() that accepts age and day as arguments and returns the ticket price base on the following rules.

  • Children (age <=12) the ticket price is always 50.
  • For senior citizens(age greater than or equal to 65) if it is weekend(Saturday/Sunday) the price is 70 and for other days the price is 80.
  • For anyone else the price is 100.
let age=35;
let day ="Monday";
function getTicketPrice(age,day){
@McLarenCollege
McLarenCollege / ticketPriceChildAdult.md
Last active Dec 21, 2021
Ticket Price Child Adult
View ticketPriceChildAdult.md

Given a person's age and a day ,write the code for the following scenario:

If the person is an Adult (age >=18) , the ticket price on Weekends is 100 and on weekdays is 80.

If the person is a child (age <18), the ticket price is always half of the adult price for that particular day.

CODE TEMPLATE


@McLarenCollege
McLarenCollege / ticketPriceUsingIfElsePart2.md
Last active Dec 21, 2021
Exercise Name : Ticket Price Using If-else part2
View ticketPriceUsingIfElsePart2.md

//NOTE: Dont use if-else-if. You can use only if-else

Given two variables age and day, write code to determine the ticket price as per the following rules :

  • For a child (age less than 12) the ticket price is always 50.

  • For a senior citizen(age greater than or equal to 65):

    i) if it is weekend (Saturday/Sunday) the price is 70.
    

ii)if it is a weekday the price is 80.