diff --git a/src/links/index.js b/src/links/index.js new file mode 100644 index 0000000..6943008 --- /dev/null +++ b/src/links/index.js @@ -0,0 +1,57 @@ +export const PARAMETERS = { + invite: "https://repl.it/classroom/invite/XvipfNO", + exercise1: + "https://repl.it/student_embed/assignment/1492285/0339cc5f2176593cbe1e6a6b6cf40cb2" +}; + +export const RETURN = { + invite: "https://repl.it/classroom/invite/Xvb4pIt", + exercise1: + "https://repl.it/student_embed/assignment/1492272/e1e304a8fbe1dad1eefaddbe897bdae6", + exercise2: + "https://repl.it/student_embed/assignment/1492271/4257dd0bdc509b2cc123249c1ff02526" +}; + +export const ARROW_FUNCTIONS = { + invite: "https://repl.it/classroom/invite/XvedktC", + exercise1: + "https://repl.it/student_embed/assignment/1492279/4905683f6a600f95f4b74d3003cec53a" +}; + +export const CALLBACKS = { + invite: "https://repl.it/classroom/invite/XvhmgdL", + exercise1: + "https://repl.it/student_embed/assignment/1492283/5586c54efd8e2124d7a123f30e8b20f8" +}; + +export const PURE_FUNCTIONS = { + invite: "https://repl.it/classroom/invite/XvdamSz", + exercise1: + "https://repl.it/student_embed/assignment/1492278/37a21c5b28239a43b266961c089ed44d" +}; + +export const FILTER = { + invite: "https://repl.it/classroom/invite/XvJM11a", + exercise1: + "https://repl.it/student_embed/assignment/1490944/600947e6a9cee06b8ed387e0b7cecd0c", + exercise2: + "https://repl.it/student_embed/assignment/1490943/7cf916312a71aab62f56a16b78903406" +}; + +export const MAP = { + invite: "https://repl.it/classroom/invite/XvIJ2r7", + exercise1: + "https://repl.it/student_embed/assignment/1490942/91e0113f0ac30c223dfa0f58280ece73", + exercise2: + "https://repl.it/student_embed/assignment/1490941/0cd4dd9dc924589b1814a3d307e654d8" +}; + +export const REDUCE = { + invite: "https://repl.it/classroom/invite/Xvc7niw", + exercise1: + "https://repl.it/student_embed/assignment/1492273/492ac8a84f624191efd3c043e955ff92", + exercise2: + "https://repl.it/student_embed/assignment/1492277/6369db51be4ea2fd4243a68a1a51a1dd", + exercise3: + "https://repl.it/student_embed/assignment/1492276/ee34964c023ce10ef6d37129343a0e7d" +}; diff --git a/src/slides/function-anatomy-parameters/function-anatomy-parameters.js b/src/slides/function-anatomy-parameters/function-anatomy-parameters.js index 9387c7b..303cfbb 100644 --- a/src/slides/function-anatomy-parameters/function-anatomy-parameters.js +++ b/src/slides/function-anatomy-parameters/function-anatomy-parameters.js @@ -7,27 +7,22 @@ import { ReplFrameSlide } from "../../tools"; -const Slide1 = ListSlideMaker( - "Parameters", - ["0 or many items that are passed into a function for its use", +import { PARAMETERS } from "../../links"; + +const Slide1 = ListSlideMaker("Parameters", [ + "0 or many items that are passed into a function for its use", "A function defines the parameters it expects", - "The order of the parameters passed in should match the order expected by the function"] -); + "The order of the parameters passed in should match the order expected by the function" +]); -const Slide2 = ListSlideMaker( - "Parameters", - ["In ES6, you can assign default parameter values to be used when an argument is not passed in", +const Slide2 = ListSlideMaker("Parameters", [ + "In ES6, you can assign default parameter values to be used when an argument is not passed in", "You can also use the rest operator to group the parameters together as an array", - "It's important to name your parameters well to help with readability"] -); + "It's important to name your parameters well to help with readability" +]); -const Slide3 = ReplClassSignup( - "Parameters", - "https://repl.it/classroom/invite/U53uwpg" -); -const Slide4 = ReplFrameSlide( - "https://repl.it/student_embed/assignment/984641/b612cfbf9148ec128d6929f5fe21cfca" -); +const Slide3 = ReplClassSignup("Parameters", PARAMETERS.invite); +const Slide4 = ReplFrameSlide(PARAMETERS.exercise1); export const FAnatomyParameterSlideSet = [ Slide1, diff --git a/src/slides/function-anatomy-return/function-anatomy-return.js b/src/slides/function-anatomy-return/function-anatomy-return.js index bd30f6f..e48a835 100644 --- a/src/slides/function-anatomy-return/function-anatomy-return.js +++ b/src/slides/function-anatomy-return/function-anatomy-return.js @@ -5,25 +5,19 @@ import { ReplClassSignup, ReplFrameSlide } from "../../tools"; +import { RETURN } from "../../links"; -const Slide1 = ListSlideMaker( - "Returns", - ["A return statement is something you should have in almost all of your functions", +const Slide1 = ListSlideMaker("Returns", [ + "A return statement is something you should have in almost all of your functions", "Without a return, a function resolves to 'undefined'", "You can be very creative about what is returned - for example, you can return another function", - "The result of a function return can be used immediately after that function has finished its business"] -); + "The result of a function return can be used immediately after that function has finished its business" +]); + +const Slide2 = ReplClassSignup("Returns", RETURN.invite); +const Slide3 = ReplFrameSlide(RETURN.exercise1); +const Slide4 = ReplFrameSlide(RETURN.exercise2); -const Slide2 = ReplClassSignup( - "Returns", - "https://repl.it/classroom/invite/UeLeKQb" -); -const Slide3 = ReplFrameSlide( - "https://repl.it/student_embed/assignment/994891/d75eb0695d276c4e4316014626b380cd" -); -const Slide4 = ReplFrameSlide( - "https://repl.it/student_embed/assignment/994774/56685ccab70b740d0cae8b5d22adc1c5" -); export const FAnatomyReturnSlideSet = [ Slide1, BasicCodeSlideMaker(returnCode), diff --git a/src/slides/function-arrow/function-arrow.js b/src/slides/function-arrow/function-arrow.js index 3ef9645..bf17eec 100644 --- a/src/slides/function-arrow/function-arrow.js +++ b/src/slides/function-arrow/function-arrow.js @@ -5,22 +5,17 @@ import { ReplClassSignup, ReplFrameSlide } from "../../tools"; +import { ARROW_FUNCTIONS } from "../../links"; -const Slide1 = ListSlideMaker( - "Arrow Function", - ["A shorthand for a regular function", +const Slide1 = ListSlideMaker("Arrow Function", [ + "A shorthand for a regular function", "Must be defined on a variable - can't use the 'function' keyword", "Can be written in a way to return a value by default and without using the 'return' keyword", - "Can be written as a single line!"] -); + "Can be written as a single line!" +]); -const Slide2 = ReplClassSignup( - "Arrow Function", - "https://repl.it/classroom/invite/U58GrJ" -); -const Slide3 = ReplFrameSlide( - "https://repl.it/student_embed/assignment/994892/2990a9577dc2df49e19e6c36d40ff428" -); +const Slide2 = ReplClassSignup("Arrow Function", ARROW_FUNCTIONS.invite); +const Slide3 = ReplFrameSlide(ARROW_FUNCTIONS.exercise1); export const ArrowSlideSet = [ Slide1, diff --git a/src/slides/function-callback/function-callback.js b/src/slides/function-callback/function-callback.js index 5699a6b..31c689e 100644 --- a/src/slides/function-callback/function-callback.js +++ b/src/slides/function-callback/function-callback.js @@ -6,31 +6,25 @@ import { ReplClassSignup, ReplFrameSlide } from "../../tools"; +import { CALLBACKS } from "../../links"; -const Slide1 = ListSlideMaker( - "Function Callback", - ["Functions can be assigned to variables", - "Functions that are assigned to variables can be invoked like you would expect"] -); +const Slide1 = ListSlideMaker("Function Callback", [ + "Functions can be assigned to variables", + "Functions that are assigned to variables can be invoked like you would expect" +]); const Slide2 = BasicCodeSlideMaker(pureCode); -const Slide3 = ListSlideMaker( - "Function Callback", - ["If we can assign a function to a variable, this means we can assign a function as an argument", - "Parameters that are functions are often referred to as callbacks"] -); +const Slide3 = ListSlideMaker("Function Callback", [ + "If we can assign a function to a variable, this means we can assign a function as an argument", + "Parameters that are functions are often referred to as callbacks" +]); const Slide4 = BasicCodeSlideMaker(pureCode2); -const Slide5 = ReplClassSignup( - "Function Callback", - "https://repl.it/classroom/invite/U57Ds9p" -); +const Slide5 = ReplClassSignup("Function Callback", CALLBACKS.invite); -const Slide6 = ReplFrameSlide( - "https://repl.it/student_embed/assignment/984647/65e52fcb62b3c7f4bd1e7671b32069a0" -); +const Slide6 = ReplFrameSlide(CALLBACKS.exercise1); export const FCallbackSlideset = [ Slide1, diff --git a/src/slides/function-pure/function-anatomy-pure.js b/src/slides/function-pure/function-anatomy-pure.js index 0ef169d..638ad6a 100644 --- a/src/slides/function-pure/function-anatomy-pure.js +++ b/src/slides/function-pure/function-anatomy-pure.js @@ -5,27 +5,27 @@ import { ReplClassSignup, ReplFrameSlide } from "../../tools"; +import { PURE_FUNCTIONS } from "../../links"; const Slide1 = ListSlideMaker( "Pure Function", - ["Minimalistic and explicit - you want these to be small and very clear", - "No side effects! Don't access or change something that exists outside the function; only use or modify values that are passed into or defined inside the function", - "Should have a return statement - think of a pure function like a small factory: you give it the supplies and it outputs the product. The most important part is that the same supplies should always give you the same end product"], - ["A side effect is when a function changes something outside of its local function scope.", - "Why it's a problem: if you mutated a variable outside of the function scope, and that variable is read by another function at some other point in time = potential concurrency bug.", - "A side effect giveaway: no return statement. If it makes sense to call it without a return value it’s likely impure.", - "The function return should be predictable: same inputs results in same outputs, 'idempotent'. Is a function that gets the current date idempotent?", - "These properties make pure functions reliable building blocks, and prefered."] + [ + "Minimalistic and explicit - you want these to be small and very clear", + "No side effects! Don't access or change something that exists outside the function; only use or modify values that are passed into or defined inside the function", + "Should have a return statement - think of a pure function like a small factory: you give it the supplies and it outputs the product. The most important part is that the same supplies should always give you the same end product" + ], + [ + "A side effect is when a function changes something outside of its local function scope.", + "Why it's a problem: if you mutated a variable outside of the function scope, and that variable is read by another function at some other point in time = potential concurrency bug.", + "A side effect giveaway: no return statement. If it makes sense to call it without a return value it’s likely impure.", + "The function return should be predictable: same inputs results in same outputs, 'idempotent'. Is a function that gets the current date idempotent?", + "These properties make pure functions reliable building blocks, and prefered." + ] ); -const Slide2 = ReplClassSignup( - "Pure Function", - "https://repl.it/classroom/invite/U59Jpjv" -); +const Slide2 = ReplClassSignup("Pure Function", PURE_FUNCTIONS.invite); -const Slide3 = ReplFrameSlide( - "https://repl.it/student_embed/assignment/984648/07a60b50ab2b579174bff1011fa952af" -); +const Slide3 = ReplFrameSlide(PURE_FUNCTIONS.exercise1); export const FAnatomyPureSlideSet = [ Slide1, diff --git a/src/slides/functional-programming-filter/function-programming-array-filter.js b/src/slides/functional-programming-filter/function-programming-array-filter.js index 9c115a7..d6bd1b5 100644 --- a/src/slides/functional-programming-filter/function-programming-array-filter.js +++ b/src/slides/functional-programming-filter/function-programming-array-filter.js @@ -5,34 +5,26 @@ import { ReplClassSignup, ReplFrameSlide } from "../../tools"; +import { FILTER } from "../../links"; -const Slide1 = ListSlideMaker( - "Array Filter", - ["Iterates through a list of items in an array and applies a provided function to each item to determine whether to put the result into the new array", +const Slide1 = ListSlideMaker("Array Filter", [ + "Iterates through a list of items in an array and applies a provided function to each item to determine whether to put the result into the new array", "The .filter() method can be called on any array", "The .filter() method expects a function 'callback'", "This function is fired for each item in the array - if there are three items, the function will run three times", - "Each time the function is run, it is passed the current array item as the first parameter"] -); + "Each time the function is run, it is passed the current array item as the first parameter" +]); -const Slide2 = ListSlideMaker( - "Array Filter", - ["The callback function should return a 'truthy' or 'falsy' value", +const Slide2 = ListSlideMaker("Array Filter", [ + "The callback function should return a 'truthy' or 'falsy' value", "If the function returns a truthy value, the current item will be added to the result array. If not, it will be ignored.", "Filter will always return a new array that is the same length or shorter than the original", - "The original list will -not- be changed or mutated"] -); + "The original list will -not- be changed or mutated" +]); -const Slide4 = ReplClassSignup( - "Array Filter", - "https://repl.it/classroom/invite/UfIUspT" -); -const Slide5 = ReplFrameSlide( - "https://repl.it/student_embed/assignment/997023/5c42df2c82f4a8d9922c36b9a92f2383" -); -const Slide6 = ReplFrameSlide( - "https://repl.it/student_embed/assignment/997024/d4a5a2556ea9fbc4cf4aeff970f24fea" -); +const Slide4 = ReplClassSignup("Array Filter", FILTER.invite); +const Slide5 = ReplFrameSlide(FILTER.exercise1); +const Slide6 = ReplFrameSlide(FILTER.exercise2); export const FPFilterSlideSet = [ Slide1, diff --git a/src/slides/functional-programming-map/function-programming-array-map.js b/src/slides/functional-programming-map/function-programming-array-map.js index 5c45e8e..529e8f2 100644 --- a/src/slides/functional-programming-map/function-programming-array-map.js +++ b/src/slides/functional-programming-map/function-programming-array-map.js @@ -5,32 +5,24 @@ import { ReplClassSignup, ReplFrameSlide } from "../../tools"; +import { MAP } from "../../links"; -const Slide1 = ListSlideMaker( - "Array Map", - ["Iterates through a list of items in an array and applies a provided function to each item before putting the result into a new array", +const Slide1 = ListSlideMaker("Array Map", [ + "Iterates through a list of items in an array and applies a provided function to each item before putting the result into a new array", "The .map() method expects a function 'callback'", "This function is fired for each item in the array - if there are three items, the function will run three times", - "Each time the function is run, it is passed the current array item as the first parameter"] -); + "Each time the function is run, it is passed the current array item as the first parameter" +]); -const Slide2 = ListSlideMaker( - "Array Map", - ["The result of the callback function will be added to the new array at the same index as the input from the original", +const Slide2 = ListSlideMaker("Array Map", [ + "The result of the callback function will be added to the new array at the same index as the input from the original", "Map will always return a new array that is the same length of the original", - "The original list will -not- be changed or mutated"] -); + "The original list will -not- be changed or mutated" +]); -const Slide3 = ReplClassSignup( - "Array Map", - "https://repl.it/classroom/invite/UfJXrZW" -); -const Slide4 = ReplFrameSlide( - "https://repl.it/student_embed/assignment/997068/7542de722e6e8190419a5dd009540b01" -); -const Slide5 = ReplFrameSlide( - "https://repl.it/student_embed/assignment/997070/8d1fa5a839000aa36e665e77fe051b05" -); +const Slide3 = ReplClassSignup("Array Map", MAP.invite); +const Slide4 = ReplFrameSlide(MAP.exercise1); +const Slide5 = ReplFrameSlide(MAP.exercise2); export const FPMapSlideSet = [ Slide1, diff --git a/src/slides/functional-programming-reduce/reduce-slides.js b/src/slides/functional-programming-reduce/reduce-slides.js index c799fec..23f80a0 100644 --- a/src/slides/functional-programming-reduce/reduce-slides.js +++ b/src/slides/functional-programming-reduce/reduce-slides.js @@ -8,43 +8,32 @@ import { ReplClassSignup, ReplFrameSlide } from "../../tools"; +import { REDUCE } from "../../links"; -const Slide1 = ListSlideMaker( - "Array Reduce", - ["Iterates through a list of items in an array and applies a provided function to each item to create the desired output value", +const Slide1 = ListSlideMaker("Array Reduce", [ + "Iterates through a list of items in an array and applies a provided function to each item to create the desired output value", "The .reduce() method can be called on any array", "The .reduce() method expects a function 'callback' and accepts an optional 'initial value'", - "Unlike filter and map, reduce does not have to result in an array; it could return any kind of value"] -); + "Unlike filter and map, reduce does not have to result in an array; it could return any kind of value" +]); -const Slide2 = ListSlideMaker( - "Array Reduce", - ["The callback in reduce is different from the previous ones we've seen; it takes in two parameters", +const Slide2 = ListSlideMaker("Array Reduce", [ + "The callback in reduce is different from the previous ones we've seen; it takes in two parameters", "The first parameter in the callback is often referred to as the accumulator; it contains the combined result of the previous iterations' returns", - "The second parameter in the callback is the current array item from the source array"] -); + "The second parameter in the callback is the current array item from the source array" +]); -const Slide3 = ListSlideMaker( - "Array Reduce", - ["In addition to the callback method, reduce can take an optional second parameter: an initial value for the callback's accumulator", +const Slide3 = ListSlideMaker("Array Reduce", [ + "In addition to the callback method, reduce can take an optional second parameter: an initial value for the callback's accumulator", "You often use this to indicate the final output's type", "If you don't provide an initial value, reduce will pass the first item from the source array to the callback instead. This will be used as the initial value of the accumulator", - "The last time the reduce callback fires, the result it outputs will be the final reduced value"] -); + "The last time the reduce callback fires, the result it outputs will be the final reduced value" +]); -const Slide4 = ReplClassSignup( - "Array Reduce", - "https://repl.it/classroom/invite/UdzE1SB" -); -const Slide5 = ReplFrameSlide( - "https://repl.it/student_embed/assignment/994125/d6cbf3fc8c3cd0c249e5e408a086d44a" -); -const Slide6 = ReplFrameSlide( - "https://repl.it/student_embed/assignment/994126/53c2d803a1c1989efbf5e82a1ecd39e1" -); -const Slide7 = ReplFrameSlide( - "https://repl.it/student_embed/assignment/994142/03d8caadb086d52746992fe0973bc866" -); +const Slide4 = ReplClassSignup("Array Reduce", REDUCE.invite); +const Slide5 = ReplFrameSlide(REDUCE.exercise1); +const Slide6 = ReplFrameSlide(REDUCE.exercise2); +const Slide7 = ReplFrameSlide(REDUCE.exercise3); export const ReduceSlideSet = [ Slide1,