٩(๑❛ᴗ❛๑)۶
After yet again having my computer be shut off by Merlin, I changed the setting of the power button.
I worked on the computer today. And that was it. I don’t feel that I was very productive. Oh, I had to call USAA and cancel the coverage of my Bug that is no more. That call was productive. I have a new policy with them, canceled the old one, changed the due date of when my car insurance is due and updated a few things that needed to be updated. They still had my California driver’s license on the policy. My new policy is called the Non-owner policy. I can still drive and I can rent a car if I wanted to but I just don’t have a car on the policy. Plus, when I get a car, the premium won’t be high cause I already have insurance. I also exercised today on the bike and did some yoga.
New book, “The Ex Hex”, which I just started. So far it’s cute. It’s a small town romance between a couple of witches. I do like a fantasy story so hopefully this will continue to be a good, light read. The book had quite a hype a year ago. I have a few books that are on hold at the library that I’m waiting on: “A Court of Thorns and Roses” and “Love, Theoretically”. I need to go look for more books later.
Come 5pm, I’m going to dust my computer and desk cause it needs it.
Is Thanksgiving next week? I think it is. I’m excited that everyone will be home. Maybe we can put the tree up after Thanksgiving when everyone is home.
I should get back to working on the computer.
JavaScript notes…
———————————-
Create a function that sums two arguments together. If only one argument is provided, then return a function that expects one argument and returns the sum.
For example, addTogether(2, 3) should return 5, and addTogether(2) should return a function.
Calling this returned function with a single argument will then return the sum:
var sumTwoAnd = addTogether(2);
sumTwoAnd(3) returns 5.
If either argument isn’t a valid number, return undefined.
function addTogether() { return false; } addTogether(2,3);
function addTogether() { const [first, second] = arguments; if (typeof (first) === "number") { if (typeof (second) === "number") return first + second; if (arguments.length === 1) return (second) => addTogether(first, second); } }
Fill in the object constructor with the following methods below:
getFirstName()
getLastName()
getFullName()
setFirstName(first)
setLastName(last)
setFullName(first, last)
Run the tests to see the expected output for each method. These methods must be the only available means of interacting with the object. Each test will declare a new Person instance as new Person(‘Bob’, ‘Ross’).
const Person = function(first, last) { this.getFullName = function() { return ""; }; return ""; };
const Person = function(first, last) { let firstName = first; let lastName = last; this.getFirstName = function() { return firstName; }; this.getLastName = function() { return lastName; }; this.getFullName = function() { return this.getFirstName() + " " + this.getLastName(); }; this.setFirstName = function(first) { return firstName = first; }; this.setLastName = function(last) { return lastName = last; }; this.setFullName = function(first, last) { this.setFirstName(first); this.setLastName(last); return this.getFullName(); }; }; const bob = new Person("Bob", "Ross"); console.log(bob.getFullName());
According to Kepler’s Third Law, the orbital period T
of two point masses orbiting each other in a circular or elliptic orbit is:
T=2πa3μ−−−√
a
is the orbit’s semi-major axis
μ=GM
is the standard gravitational parameter
G
is the gravitational constant,
M
is the mass of the more massive body.
Return a new array that transforms the elements’ average altitude into their orbital periods (in seconds).
The array will contain objects in the format {name: ‘name’, avgAlt: avgAlt}.
The values should be rounded to the nearest whole number. The body being orbited is Earth.
The radius of the earth is 6367.4447 kilometers, and the GM value of earth is 398600.4418 km3s-2.
function orbitalPeriod(arr) { const GM = 398600.4418; const earthRadius = 6367.4447; return arr; } orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
function orbitalPeriod(arr) { const GM = 398600.4418; const earthRadius = 6367.4447; const a = 2 * Math.PI; const newArr = []; const getOrbPeriod = function(obj) { const c = Math.pow(earthRadius + obj.avgAlt, 3); const b = Math.sqrt(c / GM); const orbPeriod = Math.round(a * b); // create new object return {name: obj.name, orbitalPeriod: orbPeriod}; }; for (let elem in arr) { newArr.push(getOrbPeriod(arr[elem])); } return newArr; } // test here orbitalPeriod([{ name: "sputnik", avgAlt: 35873.5553 }]);