Day 31: Almost Done Odin Fundamentals

Got back to The Odin Project Fundamentals course. Finished some more of the JavaScript practice exercises. They were focused on arrays and objects. Honestly, they were light work but still fun to go through. I feel bad going through all this material as someone who is experienced but I also need review material since my knowledge was not built on a solid foundation. I will take the easy win when I can get it lol.

TLDR;

Okay, so here are the highlights of what I did:

  • Practice -> Completed some more JavaScript exercises provided in the “The Odin Project” Fundamentals course. They were focused on working with arrays and objects. I also started reading through the next project which is a Calculator.

Calculator Solution:

const add = function(num1, num2) {
  return num1 + num2;
};

const subtract = function(num1, num2) {
  return num1 - num2;
};

const sum = function(numbers) {
  return numbers.reduce((a,b) => a + b, 0);
};

const multiply = function(numbers) {
  return numbers.reduce((a,b) => a * b);
};

const power = function(base, power) {
  return Math.pow(base, power);
};

const factorial = function(n) {
  if(n === 0) return 1;
  return n * factorial(n-1);
};

Palindrome Solution:

const palindromes = function (str) {
  const letters = str.toLowerCase().split(/[\s,!\.]/).join("");
  const half = Math.floor(letters.length/2);
  for(let i=0; i < half; ++i){
    const start = letters[i];
    const end = letters[letters.length - 1 - i];
    if(start !== end) return false;
  }
  return true;

};

Fibonacci Solution:

const fibonacci = function(n) {
  if(n < 0) return "OOPS";

  let f1 = 0;
  let f2 = 1;
  let fn;

  if(n == 1 || n == 2) return f2;

  for(let i=1;i < n; ++i){
    fn = f1 + f2;
    f1 = f2;
    f2 = fn;
  }
  return fn;
};

getTheTitles Solution:

const getTheTitles = function(books) {
  return books.map(book => book.title);
};

findTheOldest Solution:

const findTheOldest = function(people) {
  return people.reduce((a,b) => {
    const ageA = (a.yearOfDeath ? a.yearOfDeath : new Date().getFullYear()) - a.yearOfBirth;
    const ageB = (b.yearOfDeath ? b.yearOfDeath : new Date().getFullYear()) - b.yearOfBirth;
    return ageA > ageB ? a : b;
  })
};


Goal For Round 7 of the #100DaysofCode Challenge

This is my seventh round of the “#100daysofcode” challenge. I will be continuing my work from round five and round six into round seven. I am currently working through the book “Cracking the Coding Interview” by Gayle Laakmann McDowell. My goal is to become more familiar with algorithms and data structures. This goal was derived from my goal to better understand operating systems and key programs that I use in the terminal regularly e.g. Git. This goal was in turn derived from my desire to better understand the fundamental tools used for coding outside of popular GUIs. This in turn was derived from my desire to be a better back-end developer.

I have no idea if my path is correct but I am walking down this road anyways. Worst case scenario I learn a whole bunch of stuff that will help me out on my own personal projects.