LearnFrenzy
Sign in Take a free test
JS

JavaScript Programming · Topic 15 of 25

Arrow Functions Questions and Concepts

  • 4 exercises
  • 60 questions
  • ~60 min
  • Answers explained

Programs & Examples

Arrow Functions · Study material

A pricing pipeline built from small arrows

Curried arrows (discount(25), addTax(18)) create configured functions that pipe combines into reusable pricing rules.

// Small arrow functions combined into a pricing pipeline
const pipe = (...fns) => (x) => fns.reduce((v, f) => f(v), x);
const discount = (pct) => (p) => p * (1 - pct / 100);
const addTax = (pct) => (p) => p * (1 + pct / 100);
const round2 = (p) => Math.round(p * 100) / 100;
const rupees = (p) => `₹${p.toFixed(2)}`;

const studentPrice = pipe(discount(25), addTax(18), round2, rupees);
const regularPrice = pipe(addTax(18), round2, rupees);

const courses = [{ name: "JavaScript", fee: 1999 }, { name: "Python", fee: 2499 }];
courses.forEach(({ name, fee }) => console.log(`${name.padEnd(11)} regular ${regularPrice(fee)}  student ${studentPrice(fee)}`));

Output

JavaScript  regular ₹2358.82  student ₹1769.12
Python      regular ₹2948.82  student ₹2211.61

Countdown with setTimeout

The timer example on the Introduction tab keeps this across repeated setTimeout calls simply by using an arrow function.

Ready to test your Programming?

Timed online tests with instant scores and explanations.

About this section

About JavaScript Programming

Why it matters

  • JavaScript runs every web page and, with Node.js, servers, tools and APIs – it is the most used language in the world
  • Front-end, full-stack and MERN roles test JavaScript first, and many campus coding rounds allow it
  • "Predict the output" questions on hoisting, closures, this, coercion and the event loop are interview favourites
  • Modern ES6+ – let/const, arrow functions, destructuring, promises and async/await – is what companies expect from freshers

Who it is for

  • College students (B.Tech, BCA, MCA, B.Sc CS) learning web development and preparing for semester exams and viva
  • Freshers preparing for campus placements, online assessments and front-end interviews
  • Developers moving to React, Angular, Vue or Node.js who need strong core JavaScript
  • Anyone revising ES6 and asynchronous JavaScript before an interview

What every topic gives you

  • Study material in five tabs: concepts with runnable examples, coding techniques, programs, interview questions and a cheat sheet
  • Topic-wise MCQs on concepts and ES6 features
  • "Predict the output" puzzles – hoisting, coercion, closures, promises and timers
  • "Find the error" debugging: SyntaxError, ReferenceError, TypeError and silent logic bugs
  • Coding problems with solutions and real output, every one run on Node.js – run any study example in your browser

Asked in

  • Campus placements
  • TCS, Infosys, Wipro, Accenture, Cognizant tests
  • Front-end developer interviews
  • MERN / full-stack interviews
  • Online coding assessments
  • University practicals

How to use this section

  1. Read the study material of a topic and run the examples in the browser.
  2. Practise the four exercises – MCQs, output, debugging, coding problems – each marked Easy, Medium or Hard, and read every explanation.
  3. Revise with the interview questions and cheat sheet, then move to the next topic.

Search LearnFrenzy

Esc

Quick links