Git Product home page Git Product logo

arrow-functions-discussion-questions's Introduction

Arrow Function Discussion Questions

Learning Goals

  • Recognize different types of function syntax

Instructions

Arrow functions are a relatively new feature that was introduced with ES6. They use a different syntax and carry slightly different behavior than function expressions.

Take a look at the following code examples and return values with your table partners. Without looking anything up, see if you can deduce the differences and similarities in how arrow functions behave.

Examples

Arrow Function Shortcuts

const playMusic = function (music) {
  return "Playing some " + music;
};
playMusic("Jazz"); // "Playing some Jazz"
const playMusic = (music) => {
  return "Playing some " + music;
};
playMusic("Jazz"); // "Playing some Jazz"
const playMusic = (music) => {
  "Playing some " + music;
};
playMusic("Jazz"); // undefined
const playMusic = (music) => "Playing some " + music;
playMusic("Jazz"); // "Playing some Jazz"
const playMusic = music => "Playing some " + music;
playMusic("Jazz"); // "Playing some Jazz"
const readBooks = (book1, book2) => {
  return `I read '${book1}' and '${book2}'`;
};
readBooks("The Old Man and the Sea", "1984"); // "I read 'The Old Man and the Sea' and '1984'"
const readBooks = (book1, book2) => `I read '${book1}' and '${book2}'`;
readBooks("The Old Man and the Sea", "1984"); // "I read 'The Old Man and the Sea' and '1984'"
const readBooks = book1, book2 =>  `I read '${book1}' and '${book2}'` // Syntax Error

arrow-functions-discussion-questions's People

Contributors

betalantz avatar ihollander avatar ipc103 avatar lizbur10 avatar maxwellbenton avatar minimumviableperson avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arrow-functions-discussion-questions's Issues

Discrepancies between markdown and Canvas

Canvas Link

https://learning.flatironschool.com/courses/5220/discussion_topics/14199

Concern

The Canvas page for this DQ does not display the same as the markdown of the README. On Canvas, we see:

const playMusic = (music) => "Playing some " + music;
playMusic("Jazz"); // "Playing some Jazz"

const playMusic = (music) => "Playing some " + music;
playMusic("Jazz"); // "Playing some Jazz"

but the markdown correctly has:

const playMusic = (music) => "Playing some " + music;
playMusic("Jazz"); // "Playing some Jazz"

const playMusic = music => "Playing some " + music;
playMusic("Jazz"); // "Playing some Jazz"

omitting parentheses around the parameter.

There are also 9 function examples on the Canvas page compared to 8 on the markdown.

Additional Context

No response

Suggested Changes

Is the Canvas page reading from an older source for it's markdown, but the Github link comes to this repo?

the same example appears twice in a row. On purpose?

Canvas Link

https://learning.flatironschool.com/courses/5185/discussion_topics/13539?module_item_id=396081

Concern

Is this example supposed to appear twice? The two entries seem identical and it doesn't seem valuable for people to examine for differences/similarities for identifying they are the same thing. UNLESS: people should be on the lookout for duplicates entering the codebase, and recognizing such is a skill.(?)

const playMusic = (music) => {
  return "Playing some " + music;
};
playMusic("Jazz"); // "Playing some Jazz"

const playMusic = (music) => {
  return "Playing some " + music;
};
playMusic("Jazz"); // "Playing some Jazz"

Additional Context

No response

Suggested Changes

remove one of the two identical examples. Or maybe the second instance was supposed to have some slight difference?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.