Skip to content

Instantly share code, notes, and snippets.

View suhailgupta03's full-sized avatar
:octocat:

Suhail Gupta suhailgupta03

:octocat:
View GitHub Profile
// Input 5
// output 11
// (5 + 5) + 1
function multiply(n){
return 2 * n
}
function add(n) {
return n + 1
function greaterThan(n) {
return function(m) {
return m > n;
};
}
var greaterThanTen = greaterThan(10);
var result1 = greaterThanTen(11)
console.log(result1)
function greet(name) {
return `Hello, ${name}!`;
}
function shout(textFunction, name) {
const text = textFunction(name);
// toUpperCase is a built-in function of the
// String object which returns the value of
// the string converted to uppercase (capital letters)
const shoutText = text.toUpperCase();
function Animal() {
this.walk = function() {
console.log("I'm walking")
}
this.legs = function() {
console.log("I have 4 legs")
}
}
let livingThing = {
doesLiveInfinitely() {
console.log("I do not live infinitely.")
}
}
let animal = {
eats: true,
walk() {
console.log("Animal walks");
class Animal {
walk() {
console.log("This animal walks")
}
legs() {
console.log("This animal has 4 legs")
}
} // All the common functionalities
// are represented in the class named Animal
// // SPORTS is a class
// // cricket is an object (or an instance of this class)
// // tennis is an object (or an instance of this class)
// function Sports(name, totalPlayers) {
// this.game = name;
// this.totalP = totalPlayers;
// this.printTotalPlayers = function() {
// console.log(this.totalP);
// }
// var dog = {
// name: 'Rex',
// age: 2,
// color: "brown",
// }
function Dog(name, breed, color) {
this.name = name;
// this keyword refers to the current object
// this is the object that is created when the
/**
* const name = 'Rex';
const age = 2;
const color = "brown";
function description() {
console.log(
`This is ${name}, he is ${age} years old and his color is ${color}`
)
}
function Dog() {
const name = "Buzo";
const age = 3;
const color = "black";
const sound = "woof";
function bark() {
console.log(sound);
}