Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate rest-and-spread into its own new concept exercise (concept exists) #1500

Open
Tracked by #1418
junedev opened this issue Nov 6, 2021 · 8 comments · May be fixed by #1989
Open
Tracked by #1418

Separate rest-and-spread into its own new concept exercise (concept exists) #1500

junedev opened this issue Nov 6, 2021 · 8 comments · May be fixed by #1989
Assignees
Labels
new exercise ✨ x:action/create Work on something from scratch x:knowledge/elementary Little Exercism knowledge required x:module/concept-exercise Work on Concept Exercises x:size/medium Medium amount of work x:status/claimed Someone is working on this issue x:type/content Work on content (e.g. exercises, concepts)

Comments

@junedev
Copy link
Member

junedev commented Nov 6, 2021

Getting started

Here you can read about what Concept Exercises are and how they are structured:

If you have not done so yet, it is probably also helpful to do a couple of "Learning Exercises" (this is how they are called on the site) yourself. You can also look at the code of an existing concept exercise like bird-watcher (concept for-loops) for reference.

Goal

The goal is to create new concept exercise that teaches the use of the rest and spread operator in the context of functions (rest parameters), arrays and objects.

Motivation

Currently, the concept exercise "Elyses Destructered Enchantments" teaches array destructing and the rest and spread operator (...) which also includes object related content. In the future we also want to teach object destructering as a concept. Since it would be too much to also add that into the same exercise, we want to have a new split. In the future, we want to change "Elyses Destructered Enchantments" so that it focuses on array and object destructering in the context of extracting individual elements/properties. In turn, rest and spread should be covered by a new exercise that the student will complete after "Elyses Destructered Enchantments".

Please note that updating the existing exercise "Elyses Destructered Enchantments" is out of scope for this issue. There will be a separate issue for that later.

Concepts

The concept rest-and-spread already exists but feel free to improve the content or add more advanced content to the about.md file as you see fit.

https://github.com/exercism/javascript/tree/main/concepts/rest-and-spread

Learning Objectives

The student should learn what is covered in the existing concept: https://github.com/exercism/javascript/blob/main/concepts/rest-and-spread/introduction.md

Prerequisites

The following things should be assumed and defined as prerequisites for the exercise.

  • functions
  • array-destructering (in the context of extracting individual elements, no rest operator)
  • Although this concept is not available yet, you can assume the student also already knows about object destructering (in the context of extracting individual properties)

Story

Here some hints what can help to come up with a story for the exercise.

  • Think about/write down some tasks you would like the student to do (just generic tasks, no story), sometimes that already sparks an idea for a story to wrap the tasks.
  • Browse through the existing stories https://exercism.org/docs/building/tracks/stories (click on the individual story in the menu on the left), usually you won't find an exact match but some story might spark your inspiration for some general theme.
  • In the end, you can make nearly every story fit every concept so just picking some theme and rolling with it also works.

Help

You can choose to do this solo-style, or collaborate with multiple people on this. The suggested approach is to

  1. First accept this issue by saying "I'd like to work on this" (no need to wait for a response, just go with it) and optionally request that someone works with you (and wait for a second person to accept your request).
  2. Use this issue to discuss any questions you have, what should be included in the content and what not and to collect reference material.
  3. Create a PR and set "exercism/javascript" as reviewers. Additionally you can write in #maintaining-javascript that your PR is ready for review. Once you incorporated any critical feedback that the reviewer might give you and the PR is approved, it will be merged by a maintainer.
@meatball133
Copy link
Member

Hi, this would be my first time writing an exercise. Although I like to give it a shot if some one wants to work together on this I am happy to do so. Although I like to claim it

@junedev
Copy link
Member Author

junedev commented Nov 6, 2022

@meatball133 I will assign you to this issues. It is quite a challenging task so leave a comment in case you decide not to continue with it at some point.

@junedev junedev added x:status/claimed Someone is working on this issue and removed help wanted labels Nov 6, 2022
@meatball133
Copy link
Member

Well, I have come up with some kind of story and would like to hear what you think.

So you have a friend who is a bird watcher. They aren't that good at handling computer data and would like your help.

The first exercise is to convert a number of inputs to an array:

getListOfBirds(5, 7, 12, 3, 14, 8, 3);
// => [5, 7, 12, 3, 14, 8, 3]

//solution:
function getListOfBirds(...birds){
    return birds
}

The second one is to move the first 2 elements to the end of an array:

birdsPerDay = [2, 5, 0, 7, 4,  0, 1, 3, 1];
fixListOfBirds(birdsPerDay);
// => [0, 7, 4,  0, 1, 3, 1, 2, 5]

//solution:

function fixListOfBirds(birds){
    const [a, b, ...rest] = birds
    return [...rest,a,b]
}

The third one is to add an array of elements after the first element in an array:

birdsPerDay = [2, 5, 0, 7, 4, 1];
missingBirds = [3, 0, 6, 1];
CorrectListOfBirds(birdsPerDay, missingBirds);
// => [2, 3, 0, 6, 1, 5, 0, 7, 4, 1]

//solution:

function CorrectListOfBirds(birds, missing){
      const [a, ...rest] = birds
      return [a, ...missing, ...rest]
}

Is these good exercises or should they be more advanced and is there anything I could improve?

@junedev
Copy link
Member Author

junedev commented Nov 7, 2022

Looks like good start, two thoughts on this:

  • Can you double check you covered the points linked above under "learning objectives"? It looks like the object parts are missing.
  • There is already an exercise called "bird watcher" in the JavaScript track so maybe the theme can be changed a bit to not repeat itself, e.g. it could be about observing traffic on a street instead of watching birds.

@meatball133
Copy link
Member

Yes I can add 1-2 more exercises that covers object. I will also look into having a bit different theme aswell. Thanks for the feedback

@meatball133
Copy link
Member

meatball133 commented Nov 8, 2022

Alright, new story you are suppose to help your friend who is a train driver. One element in an array should represent one wagon and the number in it represents the wieght of the wagon.

The fourth exercise is to add missing information to the trains routing system.

route = "cityX - cityZ";
missingRouteInformation = {
  length: 100,
  timeOfArrival: "10:10"
};
addMissingRouteInfo(route, missingRouteInformation);
// => {route: "cityX - cityZ",   length: 100, timeOfArrival: "10:10"}

//solution:

function addMissingRouteInfo(route, missingRouteInformation){
     return {route, ...missingRouteInformation} 
}

The fifth exercise is to remove timeOfArrival element of the object.

routeInformation= {
  route: "cityX - cityZ",
  length: 100,
  timeOfArrival: "10:10"
};
removeTimeOfArrival(routeInformation);
// => {route: "cityX - cityZ",   length: 100}

//solution:

function removeTimeOfArrival(routeInformation){
     const timeOfArrival, ...restOfInformation = routeInformation
     return restOfInformation
}

@meatball133
Copy link
Member

I would very much appricate feedback and I would personally say this covers all of the topics in the syllabus.

@meatball133
Copy link
Member

meatball133 commented Nov 11, 2022

Added a first iteration of the files. I would like to get some feedback this far and then I will continue to finish up the rest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new exercise ✨ x:action/create Work on something from scratch x:knowledge/elementary Little Exercism knowledge required x:module/concept-exercise Work on Concept Exercises x:size/medium Medium amount of work x:status/claimed Someone is working on this issue x:type/content Work on content (e.g. exercises, concepts)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants