-
-
Notifications
You must be signed in to change notification settings - Fork 616
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
Comments
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 |
@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. |
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? |
Looks like good start, two thoughts on this:
|
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 |
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
} |
I would very much appricate feedback and I would personally say this covers all of the topics in the syllabus. |
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. |
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
(conceptfor-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)Story
Here some hints what can help to come up with a story for the exercise.
Help
You can choose to do this solo-style, or collaborate with multiple people on this. The suggested approach is to
The text was updated successfully, but these errors were encountered: