These are chat archives for FreeCodeCamp/HelpFrontEnd

4th
Oct 2018
Can anyone help me with this question on SO
Spyrantis Theodoros
@thodorisanta
Oct 04 2018 14:33
why when i put my media inside my nav its not working?
abraham anak agung
@padunk
Oct 04 2018 14:35
media as an image?
Spyrantis Theodoros
@thodorisanta
Oct 04 2018 14:46
nav{
  background-color: skyblue;
  font-size: 2em;

  @media (max-width: 700px){
    ul{
      flex-direction: column;
    }
  }

}
like that^
when i put it outside the nav its working normally
abraham anak agung
@padunk
Oct 04 2018 14:52
Ooo, yes, you have to put it outside nav.
Spyrantis Theodoros
@thodorisanta
Oct 04 2018 16:21
@padunk why though? im 100% sure that i've seen it somewhere like that and it workded :/
abraham anak agung
@padunk
Oct 04 2018 16:25
@thodorisanta maybe they use Saas
Spyrantis Theodoros
@thodorisanta
Oct 04 2018 16:26
oh, okay then
krckyboy
@krckyboy
Oct 04 2018 17:18

Hello. I have two arrays of objects.One is with predefined values(predefined object properties) and the other one is dynamic.I need to compare those two arrays and
if the dynamic one doesn 't contain an object with a certain property value, add the object from the array with predefined values.

Predefined array:

var workTimesDefault = [{
        day: "Monday",
        start_time: "06:00",
        end_time: "18:00",
        closed: true,
        id: 0
    },
    {
        day: "Tuesday",
        start_time: "06:00",
        end_time: "18:00",
        closed: true,
        id: 1
    },
    {
        day: "Wednesday",
        start_time: "06:00",
        end_time: "18:00",
        closed: true,
        id: 2
    },
    {
        day: "Thursday",
        start_time: "06:00",
        end_time: "18:00",
        closed: true,
        id: 3
    },
    {
        day: "Friday",
        start_time: "06:00",
        end_time: "18:00",
        closed: true,
        id: 4
    },
    {
        day: "Saturday",
        start_time: "06:00",
        end_time: "18:00",
        closed: true,
        id: 5
    },
    {
        day: "Sunday",
        start_time: "06:00",
        end_time: "18:00",
        closed: true,
        id: 6
    }
];

Dynamic array can be something like this:

dynamicWorkTimes = [
    {
        day: "Monday",
        start_time: "08:00",
        end_time: "15:00",
        id: 0
    },
    {
        day: "Sunday",
        start_time: "12:00",
        end_time: "20:00",
        id: 6
    }
]

What I want to accomplish? I want dynamicWorkTimes to be filled with objects of the remaining days (Tuesday, Wednesday, Thursday, Friday, Saturday) from the predefined arr while keeping its Monday and Sunday values.

Brad
@bradtaniguchi
Oct 04 2018 17:20
@krckyboy REDUCE
so reduce over the static array, and have the "accumulator" value be your dynamicWorkTimes array, for each item in the static array, check if it already exists in the existing array (I'm skipping over mentioning some optimizations just fyi) and add them if they are missing.
krckyboy
@krckyboy
Oct 04 2018 17:24
@bradtaniguchi Thank you. I'll try that.
Brad
@bradtaniguchi
Oct 04 2018 17:24
np, goodluck :D
Manan Shah
@mananshah51
Oct 04 2018 23:13
const increment = (function() {
  "use strict";
  return function increment(number, value = 1) {
    return number + value;
  };
})();
console.log(increment(5, 2)); // returns 7
console.log(increment(5)); // returns 6
Can someone explain me what is this code doing ?
Fernando
@lestairon
Oct 04 2018 23:16
It's adding the first number, with the second
If the second is not specified then it only adds 1 by default
Manan Shah
@mananshah51
Oct 04 2018 23:16
@lestairon Can you please elaborate more and help me understand the code line by line.
Brad
@bradtaniguchi
Oct 04 2018 23:18
its all in an IIFE, which is the outer function there, which usually is used to create "scopes" of code, as the code inside of the IIFE won't "leak" out, unless you explicitly return it (like the increment function).
I also don't think anyone had to name the inner increment function either, but I could be wrong
Fernando
@lestairon
Oct 04 2018 23:19
The name is not necessary in this case, i think
@bradtaniguchi I think he wants to know what it does, rather than why is it made like that
Brad
@bradtaniguchi
Oct 04 2018 23:21
Idk, I only mentioned stuff you didn't mention haha