My car is at the collision center now, getting assessed. I should know something soon on how much damage has been done to the Bug.
Therapy was a bit difficult yesterday. I was going over the panic attack I had on Saturday. Saturday, I was sitting in the hotel room watching YouTube while Tommy was studying. Then suddenly I start feeling dread and panic…thinking something bad is going to happen. This lasted for hours. My therapist and I talked this out and came up with some realizations. The next time I have a panic attack I need to write down how I’m feeling and work through the panic to figure out what triggered me and why I’m feeling panic. My therapist says my PTSD is extreme.
I started doing weights in my exercises. My legs and arms are still sore. Today, Tommy and I are going to go for a walk with Merlin and then do some weights. I’m feeling good about exercising now. I’m starting to see results.
I need to finish folding laundry. I will write more later. 🙂
JavaScript notes…
——————————————-
The some method works with arrays to check if any element passes a particular test. It returns a Boolean value – true if any of the values meet the criteria, false if not.
For example, the following code would check if any element in the numbers array is less than 10:
const numbers = [10, 50, 8, 220, 110, 11]; numbers.some(function(currentValue) { return currentValue < 10; });
The some method would return true.
Use the some method inside the checkPositive function to check if any element in arr is positive. The function should return a Boolean value.
function checkPositive(arr) { // Only change code below this line // Only change code above this line } checkPositive([1, 2, 3, -4, 5]);
function checkPositive(arr) { // Only change code below this line return arr.some(function(currentValue) { return currentValue > 0; }); // Only change code above this line } checkPositive([1, 2, 3, -4, 5]);
The arity of a function is the number of arguments it requires. Currying a function means to convert a function of N arity into N functions of arity 1.
In other words, it restructures a function so it takes one argument, then returns another function that takes the next argument, and so on.
Here's an example:
function unCurried(x, y) { return x + y; } function curried(x) { return function(y) { return x + y; } } const curried = x => y => x + y curried(1)(2)
curried(1)(2) would return 3.
This is useful in your program if you can't supply all the arguments to a function at one time. You can save each function call into a variable, which will hold the returned function reference that takes the next argument when it's available. Here's an example using the curried function in the example above:
const funcForY = curried(1); console.log(funcForY(2)); // 3
Similarly, partial application can be described as applying a few arguments to a function at a time and returning another function that is applied to more arguments. Here's an example:
function impartial(x, y, z) { return x + y + z; } const partialFn = impartial.bind(this, 1, 2); partialFn(10); // 13
Fill in the body of the add function so it uses currying to add parameters x, y, and z.
function add(x) { // Only change code below this line // Only change code above this line } add(10)(20)(30);
function add(x) { // Only change code below this line return function(y) { return function(z) { return x + y + z; } } // Only change code above this line }