Skip to content

Instantly share code, notes, and snippets.

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);
}
View averageOfNumbers.md
  • Part 1 - Write a function that takes two numbers and returns the average of the two numbers.

  • Part 2 - Write a second function to calculate the average of 3 numbers by extending the code written in the first function.

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){
View gist.md

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.

View gist:bdb6329528e9b014f9af23e4eaeeaa9a

You are given two variables age and day.

Write the code such that :

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

For a senior citizen(age greater than or equal to 65),if it is weekend(Saturday/Sunday) the price is 70 and for weekdays the price is 80.

For anyone else the price is 100.

View gist:b3b45cfafe40b5065fe2d72419bf7067
/*
Todo: Add more context and make the problem statement more clear.(station 6)
Write code to print as follows using "if-else" statement:
For adults(age greater than or equal to 21) :
Please go to station 6.
For child you must print 2 statements
You are not eligible to vote
Please go to station 6.
*/
View partyTime.js
let anuBirthDay = 26;
let anuBirthMonth = "August";
let anuBirthYear = 1986;
let currentDay = 26;
let currentMonth = "February";
let currentYear = 2021;
let isPartyTime = ; // Write your expression here
console.log(isPartyTime);