These are chat archives for FreeCodeCamp/HelpJavaScript

21st
Mar 2018
FlashHero
@FlashHero
Mar 21 2018 02:11
I need some help with css, so I have a fixed navigation and lists are all organized and I have media queries for smaller screens and inside it I change the position fixed to relative of the parent element and when I scroll it works perfectly, the parent element is fixed, but the lists are stacked in top of each other and have tried changing everything from positions and margins but nothing works, help please
Nate Mallison
@NJM8
Mar 21 2018 02:12
@FlashHero do you have a link to some code?
FlashHero
@FlashHero
Mar 21 2018 02:13
@NJM8 I do, but it's too messy, let me organize it
FlashHero
@FlashHero
Mar 21 2018 02:19
@NJM8 I couldn't get it to work on codepen but so everything in bigger screen is fine. The parent div has a fixed navigation and for smaller screen this is the media query
@media screen and (max-width: 480px) {
    nav ul #me {
        float:none;
        display: block;
    }
    nav ul .info {
        float: none;
        display: block;
    }
    #header-wrap{
        height: 50px;
        width: 100%;
        position: relative !important;
    }
}
I seperated the li's with class and id because they weren't suppose to have the same styles but same positioning and displaying
Nate Mallison
@NJM8
Mar 21 2018 02:21
display: block I think makes that element a block level (full width) element
try display: inline-block;
If I understand your problem correctly
FlashHero
@FlashHero
Mar 21 2018 02:22
I want it to be block element, have one list on one line
Nate Mallison
@NJM8
Mar 21 2018 02:23
Hm, I'm not understanding, is this on codepen?
@sjames1958gm Do you have ideas on how to fix my anchor tag focus styling? The styling is coming from bootstrap. I can't believe that it was designed that way and I'm not doing something wrong.
Dardan Demiri
@dardandmr
Mar 21 2018 02:25
@NJM8
FlashHero
@FlashHero
Mar 21 2018 02:25
@NJM8 No, well it's fine, I'll look into it tomorrow but thanks
CamperBot
@camperbot
Mar 21 2018 02:25
flashhero sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 328 | @njm8 |http://www.freecodecamp.org/njm8
Nate Mallison
@NJM8
Mar 21 2018 02:25
OK, sorry I couldn't help @FlashHero
Dardan Demiri
@dardandmr
Mar 21 2018 02:25
@NJM8 do you want to change the default style of bootstrap ?
FlashHero
@FlashHero
Mar 21 2018 02:26
it's fine :+1:
Nate Mallison
@NJM8
Mar 21 2018 02:27
@dardandmr No, I am using an anchor tag styled like a button for an external link, but after I click it and come back to my page it retains the focus/hover pseudo classes and styling. so it appears to still be clicked until I click anywhere else on screen
Dardan Demiri
@dardandmr
Mar 21 2018 02:27
I understand
@NJM8
Just add this code in your page:
<script type = "text/javascript" > document.addEventListener('click', function (e) {
  if (document.activeElement.toString() == '[object HTMLButtonElement]') {
    document.activeElement.blur();
  }
});
 < /script>
I beleive it will do the trick
Nate Mallison
@NJM8
Mar 21 2018 02:34
@dardandmr No go. I tried the same with jQuery and it doesn't work. Also pasted your code into my page, doesn't work.
I tried
  $('.btn').on('click', function() { 
    $(this).blur(); 
  });
well I'm off to bed, let me know if you have any brilliant ideas
Dardan Demiri
@dardandmr
Mar 21 2018 02:37
Okey Good night
I will try to find a solution
;)
the page is here, you can click on an active streamer or my link to my portfolio and come back to the page to see what is going on
Dardan Demiri
@dardandmr
Mar 21 2018 02:44
@NJM8
<script type="text/javascript ">
    $("a").on("click", function () {
      this.blur();
      this.hideFocus = true;
      this.style.outline = 'none';
    });
  </script>
This should work, I tried it

in fact just change the selector to

.btn

Dardan Demiri
@dardandmr
Mar 21 2018 02:53

@NJM8 and if you want to have the outline when clicking than you should add this:

<script type="text/javascript ">
    $(".btn").keypress(function () {
      this.blur();
      this.hideFocus = false;
      this.style.outline = null;
    });
    $(".btn").on("click", function () {
      this.blur();
      this.hideFocus = true;
      this.style.outline = 'none';
    });
  </script>

Works 100%

Markus Kiili
@Masd925
Mar 21 2018 09:36
@Blusoup arr.push(val) adds a new array element to the end of array and returns new length. Post some code of what you need to achieve.
Stephen James
@sjames1958gm
Mar 21 2018 09:48
@Blusoup Assuming by index position you mean the offset in the list?
You could have a variable outside the loop
let i = 0;
then
  bannerDataArr.push(i++);
  bannerDataArr = bannerDataArr.join(";");
Francois Beyers
@Blusoup
Mar 21 2018 09:58
@sjames1958gm Thank you so much! I was gettting way too complicated with this! That worked great. Cant thank you enough! šŸ™šŸ¼
CamperBot
@camperbot
Mar 21 2018 09:58
blusoup sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9122 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Mar 21 2018 09:59
@Blusoup :+1: Sometimes it just takes an extra set of eyes.
Francois Beyers
@Blusoup
Mar 21 2018 10:01
absolutely, I was going waaay to far down a rabbit hole there with more loops
Ahmad Abdolsaheb
@ahmadabdolsaheb
Mar 21 2018 10:21
hi, has anyone used Chai for api testing?
Traek Wells
@TraekWells
Mar 21 2018 11:44

Any willing to help me out with the Wikipedia viewer project? The API returns a multidimensional array and I thought this would iterate over the array and return values for that iteration.

// Variables
const searchButton = document.getElementById('search-button');
const results = document.querySelector('#results .row');


// Add event listener to search button
searchButton.addEventListener('click', getData);

// Create function to retrieve data
function getData(e) {
  const searchText = document.getElementById('search-text').value;
  const url = "https://en.wikipedia.org/w/api.php?action=opensearch&search=" + searchText + "&format=json&origin=*";

  fetch(url)
    .then(response => response.json())
    .then(data => {
      let title = data[1];
      let description = data[2];
      let link = data[3];
      for (let i = 0; i <= data.length; i++) {
        for (let j = 1; j <= data[i].length; j++) {
          results.innerHTML = `
            <div class="col-md-4">
              <div class="card">
                <div class="card-body">
                  <h5 class="card-title">${title[i][j]}</h5>
                  <p class="card-text">${description[i][j]}</p>
                  <a href="${link[i][j]}" class="btn btn-primary">Full article</a>
                </div>
              </div>
            </div>
          `
        }
      }
    })
    .catch(err => console.log(err));
}

I was having more success with only one for loop but I was only getting on result returned.

Iā€™m also getting this in the console:

TypeError: Cannot read property 'length' of undefined
    at fetch.then.then.data (app.js:21)

Is this too vague to help. Thanks everyone.

Stephen James
@sjames1958gm
Mar 21 2018 11:46
@TraekWells Don't use <= for end of array or you will go over the end. Also, why is second loop starting at 1?
data[i].length where i = data.length will give the error above
Traek Wells
@TraekWells
Mar 21 2018 11:47
@sjames1958gm Alright, makes sense. That was a typo on my end. The first for loop starts at 0 and the nested for loop starts at 0.
Stephen James
@sjames1958gm
Mar 21 2018 11:49
@TraekWells :+1:
Nate Mallison
@NJM8
Mar 21 2018 12:46
@dardandmr Thank you that got it working, I adjusted it to be proper jQuery:
$(".btn").keypress(function () {
      $(this).blur();
      $(this).hideFocus = false;
      $(this).css('outline: null');
    });

    $(".btn").on("click", function () {
      $(this).blur();
      $(this).hideFocus = true;
      $(this).css('outline: none');
    });
CamperBot
@camperbot
Mar 21 2018 12:46
njm8 sends brownie points to @dardandmr :sparkles: :thumbsup: :sparkles:
:cookie: 302 | @dardandmr |http://www.freecodecamp.org/dardandmr
Nate Mallison
@NJM8
Mar 21 2018 12:48
After some testing and playing it seems to be that bootstrap adds focus styling to anchor elements when they are clicked. What I'm still not understanding is why I have to manually remove that focus. As a framework having to manually do something that seems so fundamental doesn't make sense to me.
Stephen James
@sjames1958gm
Mar 21 2018 12:50
@NJM8 Is this the case where it navigates to another page and you come back and the tooltip is still there?
Nate Mallison
@NJM8
Mar 21 2018 12:51
However it would seem that if you did use focus for styling you would have to remove it if doing everything vanilla. I just think bootstrap should remove that styling
Yes, well sort of, the issue is with focus styling. The tooltip goes away when the link loses focus
I tried screwing around with it without bootstrap and anchor tags do not lose focus after clicking them to open a link in a new window. I can digest that, I don't normally use focus with vanilla stuff, just hover and active. But for bootstrap to use focus styling, knowing full well that the anchor tag won't lose focus after being clicked, and then not adding the JS to remove it so it works as expected is bad design.
Stephen James
@sjames1958gm
Mar 21 2018 12:57
@NJM8 If bootstrap never gets the event that it lost focus, how would it know to do that?
Nate Mallison
@NJM8
Mar 21 2018 12:58
I think it should know when I click the link, no?
Stephen James
@sjames1958gm
Mar 21 2018 13:01
@NJM8 I would say no, it would know when it got the unfocus event, which I bet doesn't happen when you switch windows/tabs like this.
That is why your code has to "fake" that by doing blur()
I am only guessing to a degree
Dardan Demiri
@dardandmr
Mar 21 2018 13:02
@NJM8 ;)
Nate Mallison
@NJM8
Mar 21 2018 13:06
I guess what I mean is, anchor tags do not have focus styling by default, bootstrap is adding that, so it should remove it too
Traek Wells
@TraekWells
Mar 21 2018 13:43
Is it bad practice to nest a forEach inside of a for loop?
For example, if I want the forEach to start at the [1] index of an array instead of the [0] index?
Markus Kiili
@Masd925
Mar 21 2018 13:46
@TraekWells No, it is not bad.
Traek Wells
@TraekWells
Mar 21 2018 13:47
@Masd925 do you know a better way to exclude the [0] index besides starting a for loop at let i = 1;?
Markus Kiili
@Masd925
Mar 21 2018 13:48
@TraekWells You can also use forEach and exclude the first index value inside the callback. I think I like a loop more there.
Nate Mallison
@NJM8
Mar 21 2018 13:53
@TraekWells You could just test for the index[0] and ignore it:
for (let i = 0; i < thing.length: i++ ) {
  if (i === 0) {
    continue;
  }
}
all the iterator functions also let you access the index if you pass it into the inner function
array.forEach((item, index) => {
  if (index === 0) {
    continue;
  }
})
Traek Wells
@TraekWells
Mar 21 2018 14:04
@NJM8 aaaaahhhhhh. I see. Thanks my friend. That helps.
CamperBot
@camperbot
Mar 21 2018 14:04
traekwells sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 329 | @njm8 |http://www.freecodecamp.org/njm8
Traek Wells
@TraekWells
Mar 21 2018 14:04
@Masd925 Thank you too
Nate Mallison
@NJM8
Mar 21 2018 14:18
@TraekWells no problem, I love iterators.
Jason Luboff
@JLuboff
Mar 21 2018 15:14
:wave:
Nate Mallison
@NJM8
Mar 21 2018 15:15
hi @JLuboff
just in time
Any idea why my event.preventDefault() isn't working when pressing the enter key on input?
Jason Luboff
@JLuboff
Mar 21 2018 15:16
Whats up?
I tried binding the event using the inputs id, didn't work. I've used this exact code in other projects and it was fine
Jason Luboff
@JLuboff
Mar 21 2018 15:18
Looking right now
Nate Mallison
@NJM8
Mar 21 2018 15:19
hmm, actually in my other project when the enter key is pressed I just call the click event on the search button, this one I'm doing what the search button does, let me try that
Jason Luboff
@JLuboff
Mar 21 2018 15:19
Give it a try :)
Nate Mallison
@NJM8
Mar 21 2018 15:20
nope, still reloading the page
Jason Luboff
@JLuboff
Mar 21 2018 15:22
Don't think it'll matter..but any difference if you use keypress instead of keyup?
Is it necessary to have the input field be contained within a form?
Nate Mallison
@NJM8
Mar 21 2018 15:26
ohhh
I forgot about that
it's for styling mostly
so that the input isn't full page width
Jason Luboff
@JLuboff
Mar 21 2018 15:27
Since you're using bootstrap, you can always just stick it in column thats only a couple wide or what not
Nate Mallison
@NJM8
Mar 21 2018 15:33
ah
used a div with a class of form-inline. keeps my styling and now the function works
Jason Luboff
@JLuboff
Mar 21 2018 15:33
:+1:
Nate Mallison
@NJM8
Mar 21 2018 15:33
thanks @JLuboff
CamperBot
@camperbot
Mar 21 2018 15:33
njm8 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2375 | @jluboff |http://www.freecodecamp.org/jluboff
Nate Mallison
@NJM8
Mar 21 2018 15:34
Did you see the stuff I was posting about the anchor tags with btn issue I'm having with bootstrap?
Jason Luboff
@JLuboff
Mar 21 2018 15:35
I did not look up lol let me take a quick peak
Eh... I don't have an answer for that. I haven't been using bootstrap much lately, and haven't used v4 at all
Nate Mallison
@NJM8
Mar 21 2018 15:37
I made a page to highlight the issue and submit a feature request: https://www.natethedev.com/bootstrapanchorfix/
ah ok
My general frustration was spending so much time trying to fix bootstrap, when if I had built it vanilla I could've avoided all that and learned more useful things
ah well
Jason Luboff
@JLuboff
Mar 21 2018 15:39
Thus is the life of using frameworks, sometimes you have to modify things to work how you'd like :D
Nate Mallison
@NJM8
Mar 21 2018 15:42
@dardandmr I'm going to submit a feature request to bootstrap to fix the issues I had, want me to include you in the code? It's your fix really
@JLuboff How's work?
Jason Luboff
@JLuboff
Mar 21 2018 15:43
Just got in less than an hour ago. Haven't done much work yet :worried: lol Need to start though. Have to manipulate an object a bit in my project.
Been checking the latest Formula 1 news lol
Dardan Demiri
@dardandmr
Mar 21 2018 15:44

@NJM8 it's not a fix it's a hack, the code is not something special everyone can do it
so yes you can mention me with this username:

dardandemiri

Nate Mallison
@NJM8
Mar 21 2018 15:45
nice. I haven't been paying attention to F1. Did watch 12 hours of Sebring last weekend. Good racing
@dardandmr Ok
Jason Luboff
@JLuboff
Mar 21 2018 15:47
F1 Season begins this week! I'm excited, its the only racing series I watch. However.. with Alonso also participating in the full season of WEC, I think I'll try and catch a few of those races (or at least parts of them)
Nate Mallison
@NJM8
Mar 21 2018 15:57
twitch TV done, now to burn through the algorithms
Jason Luboff
@JLuboff
Mar 21 2018 15:59
Considering the route you've gone, they shouldn't be terribly difficult for you
Jason Luboff
@JLuboff
Mar 21 2018 16:07
I really need to start using branches via git. I'm working by myself but find I'm changing a large bit of code which breaks a component thus I can't test between the two. Ooops
Nate Mallison
@NJM8
Mar 21 2018 16:13
yeah, I'm running into that as well
changing tons of stuff trying to get something working and then I can't remember everything I changed back
oops
Jason Luboff
@JLuboff
Mar 21 2018 16:16
Heh Luckily I'm using a different route, but my old route doesn't work anymore due to my changes to structure. I've committed enough that I can get the old code working again but I don't think in this case I need to
Onome Sotu
@onomesotu
Mar 21 2018 17:18
Good evening guys
I am trying to solve the symmetric difference problem
The logic isn't complete yet, but i get a type error where I am not suppose to be getting one
Jason Luboff
@JLuboff
Mar 21 2018 17:19
Lets see the code
Onome Sotu
@onomesotu
Mar 21 2018 17:19
Can someone point out something I'm missing please?
function sym(args) {
  args = Array.from(arguments);
  var lengthOfArgs = args.length,
      currentArg = 1,
      symDiff = [];


  function checker(array1, array2){
    for(var i = 0; i < array1.length; ++i){
      if(array2.indexOf(array1[i]) == -1){
        symDiff.push(array1[i]);
      }
    }
  }

  function findSymDiff(arr1, arr2){
    checker(arr1, arr2);
    checker(arr2, arr1);
  }

  findSymDiff(args[0], args[1]);
  currentArg++;

  if(currentArg > lengthOfArgs){
    return symDiff;
  }else{
    findSymDiff(symDiff, args[currentArg]);
  }

}

sym([1, 2, 3], [5, 2, 1, 4]);
type error is array2 is undefined
Jason Luboff
@JLuboff
Mar 21 2018 17:21
@onomesotu args[currentArg] in your else statement is undefined
Onome Sotu
@onomesotu
Mar 21 2018 17:23
jesus christ.... thanks
it should be >=
Thanks @JLuboff
Jason Luboff
@JLuboff
Mar 21 2018 17:24
remember that console.log is your friend :D And also tools like http://pythontutor.com/
CamperBot
@camperbot
Mar 21 2018 17:24
onomesotu sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2376 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Mar 21 2018 17:24
No problem
Onome Sotu
@onomesotu
Mar 21 2018 17:25
I was confused because it pointed to the definition of the function as where the error is
WHy didn't it point to the statement args[currentArg]?
Jason Luboff
@JLuboff
Mar 21 2018 17:27
Becuase the the issue isn't in the else statement persay, you don't get an error becuase you're passing an arguement as undefined you get the error when you try and manipulate an array that is undefined
(If that makes sense)
Onome Sotu
@onomesotu
Mar 21 2018 17:28
yeah.. it does makes sense
Jason Luboff
@JLuboff
Mar 21 2018 17:29
:+1:
Keggatron
@Keggatron
Mar 21 2018 17:30
Does anyone know how someone would add a price value to a redux-form. For instance I'm creating a fake pizza ordering site and I want to attach a base price of 12 to every small pizza ordered, then add an extra like 1.50 for every topping selected and add that to my form values.
So I'm using radio buttons to determine the size, however it only has a value of small medium or large, how would I attach a price that gets entered into form values specific for each one
?
Jason Luboff
@JLuboff
Mar 21 2018 17:33
@Keggatron I don't have experience with redux... but if you're using a dropdown to select pizza size, you can for example have an object for value of each size
<select>
<option value='{"Size": "Small", "Price": "$12.00"}'> Small </option>
<option value='{"Size": "Medium", "Price": "$14.00"}'> Medium </option>
etc etc
</select>
I think you can do something similar with radio buttons
Keggatron
@Keggatron
Mar 21 2018 17:34
ok, would this be possible to do with a radio button?
oh ok awesome, I'll give it a try
Jason Luboff
@JLuboff
Mar 21 2018 17:35
Ya looks like you can do pretty much the same thing with radio buttons. You'll have to manipulate the object with javascript
Keggatron
@Keggatron
Mar 21 2018 17:36
I'm getting an unexpected token error when I try that
wait a minute
Jason Luboff
@JLuboff
Mar 21 2018 17:37
Perhaps it doesn't work within redux.. I was just trying it in w3schools editor which seemed to work, but thats with standard html/JS
Keggatron
@Keggatron
Mar 21 2018 17:37
missed the ' prior to the object
Jason Luboff
@JLuboff
Mar 21 2018 17:38
Ah!
Dardan Demiri
@dardandmr
Mar 21 2018 17:38
I need som Logic help
in my JS Code
with my Simon Game
blob
Brad
@bradtaniguchi
Mar 21 2018 17:40
@dardandmr Looks good BTW, very clean
Dardan Demiri
@dardandmr
Mar 21 2018 17:40

With this function

function show(sTab) {
  setTimeout(() => {
    allSominTabs[sTab].classList.toggle("activatePanel");
  }, 500);
  allSominTabs[sTab].classList.toggle("activatePanel");
}

show(1);

The Blue tab will get highlighted And it works, but when I want to do a secuence it won't work

Brad
@bradtaniguchi
Mar 21 2018 17:41
@dardandmr You got that in a loop somewhere?
Dardan Demiri
@dardandmr
Mar 21 2018 17:41
I tried loops
setInterval
Jason Luboff
@JLuboff
Mar 21 2018 17:42
I had to do a double timeout
within a loop
Which incremented the time
Dardan Demiri
@dardandmr
Mar 21 2018 17:42
I tried that too
but it executes all tabs at a same time
don't know why
Oh guys I must leva right now
if you have any suggestion I will look at that later
thanks
Nate Mallison
@NJM8
Mar 21 2018 17:43
@dardandmr you have a link to the whole thing?
Dardan Demiri
@dardandmr
Mar 21 2018 17:44
Not right now
its offline
Nate Mallison
@NJM8
Mar 21 2018 17:44
ok
Dardan Demiri
@dardandmr
Mar 21 2018 17:44
but I just need the logic
thanks all
Jason Luboff
@JLuboff
Mar 21 2018 17:45
PseudoCode here we come!
For loop run to my array length
setTimeout inside for loop, that calls another function with a Timeout. I pass in several arguments including time (lets say 500 ms)
In the first setTimeout, I have a static time (again lets just say 500 ms) and multiply that by my loops iterator (+ 1)
@dardandmr
Nate Mallison
@NJM8
Mar 21 2018 17:46
ah yes
the old loop in a loop in a loop. with a delay. :smile:
Jason Luboff
@JLuboff
Mar 21 2018 17:47
I also change several things in each timeout but thats the gist above
Nate Mallison
@NJM8
Mar 21 2018 17:48
I haven't done simon yet but I'm planning to use request animation frame with a debounce like function. much more reliable and easy once you get over the hurdle
Jason Luboff
@JLuboff
Mar 21 2018 17:51
Never used animation frame before
Steven Ossorio
@steven-ossorio
Mar 21 2018 18:41
Hello everyone. I'm trying to follow Cracking the Coding Interview and got a question I ran into. The problem is write a method to replace all spaces in a string with '%20' and you are given 'true' length of the string. So for example input: "Mr John Smith ", 13 would output output: "Mr%20John%20Smith"

My question is regarding my solution where ```function URLify(sentence, trueLength) {
let count = 0,
length = trueLength,
result = '';

for(var i = 0; i < sentence.length; i++) {
if(sentence[i] === ' ') count += 1;
}

for(var j = 0; length - 1 >= 0; j++) {
if(sentence[j] === ' ') {
result += '%20';
length--;
} else if(j === 0 || j !== ' ') {
result += sentence[j]
length--;
}
}

return result
}

URLify("Mr John Smith ", 13)```

function URLify(sentence, trueLength) {
  let count = 0,
      length = trueLength,
      result = '';

  for(var i = 0; i < sentence.length; i++) {
    if(sentence[i] === ' ') count += 1;
  }

  for(var j = 0; length - 1 >= 0; j++) {
    if(sentence[j] === ' ') {
      result += '%20';
      length--;
    } else if(j === 0 || j !== ' ') {
      result += sentence[j]
      length--;
    }
  }

  return result
}

URLify("Mr John Smith    ", 13)
The part where I'm doing result += sentence[j] is that doing an O(n) computation? since it's making a copy of the string?
Jason Luboff
@JLuboff
Mar 21 2018 19:02
I forget the exact verbage behind Big O notation, but I think it has to do with using loops. result += is not part of it, but the loop itself is. But just a question.. based on your description...why even use any loops?
Can;t we just trim and replace?
Steven Ossorio
@steven-ossorio
Mar 21 2018 19:12
@JLuboff the you got a good point. Just thought be good to try solving these problems within a counter as they've suggested in the mood. Also taking longer way for onsite practice.
@JLuboff Thanks for the explanation. I thought there was some form of O(n) occurring so I thought that was a O(n ^ 2) solution instead of O(n)
CamperBot
@camperbot
Mar 21 2018 19:13
steven-ossorio sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2377 | @jluboff |http://www.freecodecamp.org/jluboff
Tiago Correia
@tiagocorreiaalmeida
Mar 21 2018 19:23
hey there
Jason Luboff
@JLuboff
Mar 21 2018 20:18
@tiagocorreiaalmeida Howdy
@steven-ossorio If @Chrono79 is around, he'd be good to explain all that. I know he has in the past tried to explain it to me haha
Adel
@AdelMahjoub
Mar 21 2018 20:24
@steven-ossorio is encodeURIComponent or String.replace not allowed ?
Adel
@AdelMahjoub
Mar 21 2018 20:33
is this not allowed too ?
/**
     * 
     * @param {string} sentence 
     * @param {number} length 
     */
    function URLify(sentence, length) {
       return sentence.split('').slice(0, length).map(char => {
            if(char === ' ') {
                return '%20'
            }
            return char
        }).join('');
    }
Onome Sotu
@onomesotu
Mar 21 2018 20:34
Can someone please help out
In my head, my logic is correct..
The computer tells me otherwise
Jason Luboff
@JLuboff
Mar 21 2018 20:35
@Chrono79 :+1: Out of the woodwork he comes!
Onome Sotu
@onomesotu
Mar 21 2018 20:35
function sym(args) {
  var argument = Array.from(arguments);
  var lengthOfArgs = argument.length - 1,
      currentArg = 1,
      symDiff = [];

  function findSymDiff(arr1, arr2){//function that checks for the symmetric differences
    function checker(array1, array2){
      for(var i = 0; i < array1.length; ++i){
        if(array2.indexOf(array1[i]) == -1){
          symDiff.push(array1[i]);
        }
      }
    }
    checker(arr1, arr2);
    checker(arr2, arr1);

    var fallback = symDiff;//assign the result to another variable

    if(currentArg >= lengthOfArgs){//if we are at the end of the array return the differences
      return symDiff;
    }else{
      symDiff = [];  //reset symDiff array to empty
      currentArg++;  //go to the next array index
      console.log(symDiff, fallback, argument[currentArg]);
      findSymDiff(fallback, argument[currentArg]);
    }
  }

  findSymDiff(argument[0], argument[1]);
}

sym([1, 2, 5], [2, 3, 5], [3, 4, 5]);
I wanted to use recursion to keep checking the differences until i get to the end of the array...
but it doesn't return anything
:(
Steven Ossorio
@steven-ossorio
Mar 21 2018 20:42
@JLuboff Thanks. I'll be sure to ask for him whenever he's on.
CamperBot
@camperbot
Mar 21 2018 20:42
steven-ossorio sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2378 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Mar 21 2018 20:42
@steven-ossorio He is, he posted above :D :P
Steven Ossorio
@steven-ossorio
Mar 21 2018 20:44
@AdelMahjoub Honestly. Nothing in the book states we can't use encodeURIComponent or String.replace and honestly I've never heard of those two lol I'll need to check them online so I get a better understanding :D
@AdelMahjoub wow that solution actually would work. I never considered it before and from what i can see it'll maintain O(n) :fire:
@Chrono79 Thanks. I'll read the link and get a better understanding about the big O. Guess I may have missed something while I read cracking the coding interview.
CamperBot
@camperbot
Mar 21 2018 20:46
steven-ossorio sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4612 | @chrono79 |http://www.freecodecamp.org/chrono79
Steven Ossorio
@steven-ossorio
Mar 21 2018 20:46
Thanks everyone for your help :)
loving this channel
Jason Luboff
@JLuboff
Mar 21 2018 20:49
:+1:
Tiago Correia
@tiagocorreiaalmeida
Mar 21 2018 20:50
so @JLuboff codefights round 2 ?
while building a chat one of the ways of having multiple chat's would be pass an extra parameter with the room name when emiting an event or there is a better way?
Jason Luboff
@JLuboff
Mar 21 2018 20:55
No codefights for me, too busy
I'm not too sure on that one, but ya I'd think you'd need a way of specifying the room.
Novice Movie Study
@Stryyder
Mar 21 2018 22:15
I need a dictionary to explain the definitions in the documentation. I hear smoke and smell colors now.
Dardan Demiri
@dardandmr
Mar 21 2018 23:04
@JLuboff your pseodoCode was what I was stuck at.
@NJM8 good luck in your simon Game
Thank you
CamperBot
@camperbot
Mar 21 2018 23:04
dardandmr sends brownie points to @jluboff and @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 334 | @njm8 |http://www.freecodecamp.org/njm8
:star2: 2379 | @jluboff |http://www.freecodecamp.org/jluboff
Jason Luboff
@JLuboff
Mar 21 2018 23:22
@dardandmr :+1: Hope it helps
Dardan Demiri
@dardandmr
Mar 21 2018 23:26
It helped ;)
Jason Luboff
@JLuboff
Mar 21 2018 23:33
Glad it did
Ogundele Olumide
@Lumexralph
Mar 21 2018 23:53
Wow.... just passing by to check if this place is still surviving
Jason Luboff
@JLuboff
Mar 21 2018 23:55
@Lumexralph Of course it is! but I'm out!
Ogundele Olumide
@Lumexralph
Mar 21 2018 23:55
@JLuboff hey dad