Skip to content

armeagle777/homework-scope-and-closure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

scope-and-closure

This branch is made for hometasks

Tasks

Partial sum

➡️ Task: Create a function that implements partial sum

➡️ Expected output

  • sum(1)(2); // 3
  • const addOne = sum(1)
  • addOne(2); // 3
  • const addTen = sum(10);
  • addTen(2); // 12
  • addOne(4); // 5
  • addTen(10); // 20

➡️ Solution

redundant function

➡️ Task: Write a function redundant that takes in a string str and returns a function that returns str.

➡️ Expected output

  • const f1 = redundant("apple"); // //f1() ➞ "apple"
  • const f2 = redundant("pear");//f2() ➞ "pear"
  • const f3 = redundant("");//f3() ➞ ""

➡️ Solution

Add suffix

➡️ Task: Write a function that returns an anonymous function, which transforms its input by adding a particular suffix at the end.

➡️ Expected output

  • add_ly = add_suffix("ly");
  • add_ly("hopeless"); // "hopelessly"
  • add_ly("total"); // "totally"
  • add_less = add_suffix("less");
  • add_less("fear"); // "fearless"
  • add_less("ruth"); // "ruthless"

➡️ Solution

printAfter function

➡️ Task: Create a function printAfter that calls its argument after printing 'hello world'

➡️ Expected output

  • printAfter(print); // 'hello, world' // 'Elon Musk'

➡️ Solution

Function to emplement filtering an array

➡️ Task: Write a function that implements filtering in array

➡️ Expected output

  • filterFalsyValues(values); // [true, {}, { name: "Elon" }];

  • filterFalsyValues(["hello", 1233, []]); // ['hello', 1233, []]

➡️ Solution

Function to remove elements of array with length <= 3

➡️ Task: Write a function which remove elements with length <= 3

➡️ Expected output

  • filterByLength(["kia", "tesla", "bmw", "mercedes"]); // ['tesla', 'mercedes']

➡️ Solution

Are elements of the given array uniwue ?

➡️ Task: Given an array. Determine whether it consists only from uniques or not.

➡️ Solution

Determine if a word or phrase is an isogram.

➡️ Task: Determine if a word or phrase is an isogram. An isogram (also known as a "non pattern word") is a word or phrase without a repeating letter.

➡️ Solution

Sum of even numbers' quadratic.

➡️ Task: Given an array of numbers. Find the sum of numbersʼ quadratic which are even.

➡️ Solution

Check if word is palidrome.

➡️ Task: Check whether string is palindrome, or not.

➡️ Solution

Largest product of adjacent elements.

➡️ Task: Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.

➡️ Solution

Built With

  • Vanilla JavaScript

Author

Tigran Yeranyan

Contributions, issues, and feature requests are welcome!

Give a ⭐️⭐️⭐️⭐️⭐️ if you like this project!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published