<file_sep>// Sandwich Fillings
// Given a sandwich (as an array), return an array of fillings inside the sandwich. This involves ignoring the first and last elements.

// Examples
// getFillings(["bread", "ham", "cheese", "ham", "bread"]) ➞ ["ham", "cheese", "ham"]

// getFillings(["bread", "sausage", "tomato", "bread"]) ➞ ["sausage", "tomato"]

// getFillings(["bread", "lettuce", "bacon", "tomato", "bread"]) ➞ ["lettuce", "bacon", "tomato"]
// Notes
// The first and last elements will always be "bread".

function getFillings(sandwich) {
  return sandwich.filter((x, index, arr) => x != "bread");
}

console.log(getFillings(["bread", "ham", "cheese", "ham", "bread"]));
console.log(getFillings(["bread", "sausage", "tomato", "bread"]));
console.log(getFillings(["bread", "lettuce", "bacon", "tomato", "bread"]));
<file_sep>## Edabit Practice

A set of solutions for challenges on edabit.com
<file_sep>// After N Months...
// Create a function that takes in year and months as input, then return what year it would be after n-months has elapsed.

// Examples
// afterNMonths(2020, 24) ➞ 2022

// afterNMonths(1832, 2) ➞ 1832

// afterNMonths(1444, 60) ➞ 1449
// Notes
// Assume that adding 12 months will always increment the year by 1.
// If no value is given for year or months, return "year missing" or "month missing".
// At least one value will be present.

function afterNMonths(year, months) {
  if (!year) {
    return "year missing";
  }
  if (!months) {
    return "month missing";
  }
  return Math.floor(year + months / 12);
}

console.log(afterNMonths(2020, 13));
<file_sep>// Is the Number a Repdigit
// A repdigit is a positive number composed out of the same digit. Create a function that takes an integer and returns whether it's a repdigit or not.

// Examples
// isRepdigit(66) ➞ true

// isRepdigit(0) ➞ true

// isRepdigit(-11) ➞ false
// Notes
// The number 0 should return true (even though it's not a positive number).
// Check the Resources tab for more info on repdigits.

function isRepdigit(num) {
  console.log("log:", num, num.toString().split(""));
  if (num >= 0) {
    return num
      .toString()
      .split("")
      .every((x, index, arr) => x === arr[0]);
  } else return false;
}

console.log(isRepdigit(333));
console.log(isRepdigit(31233));
console.log(isRepdigit(-33));
<file_sep>// Edabit
const myObject = { one: 1, two: 2, three: 3 };

function hasKey(obj, key) {
  return key in obj;
}

console.log(hasKey(myObject, "three"));
<file_sep>// Both Zero, Negative or Positive
// Write a function that returns true if both numbers are:

// Smaller than 0, OR ...
// Greater than 0, OR ...
// Exactly 0
// Otherwise, return false.

// Examples
// both(6, 2) ➞ true

// both(0, 0) ➞ true

// both(-1, 2) ➞ false

// both(0, 2) ➞ false
// Notes
// Inputs will always be two numbers.

function bothZeroNegPos(firstNumber, secondNumber) {
  if (firstNumber < 0 && secondNumber < 0) {
    return true;
  } else if (firstNumber > 0 && secondNumber > 0) {
    return true;
  } else if (firstNumber === 0 && secondNumber === 0) {
    return true;
  } else {
    return false;
  }
}

console.log(bothZeroNegPos(12, -1));
console.log(bothZeroNegPos(0, 2));
console.log(bothZeroNegPos(6, -2));
console.log(bothZeroNegPos(6, 22));
