These are chat archives for FreeCodeCamp/HelpFrontEnd

20th
Sep 2017
Maria Theresa Arruda
@arrudamt
Sep 20 2017 00:18
hello guys! i need some help, how can i set my logo name next to the logo and not above it?
iso
@iso1048
Sep 20 2017 00:26
@arrudamt give logoname a padding-top maybe
Maria Theresa Arruda
@arrudamt
Sep 20 2017 00:29
@gothamknight thanks! it worked. i did try padding, but not just the top part. thanks again.
CamperBot
@camperbot
Sep 20 2017 00:29
arrudamt sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 433 | @gothamknight |http://www.freecodecamp.com/gothamknight
George Kemp
@gkemp94
Sep 20 2017 00:53
Hello, is anybody available to help quickly with the random quote generator?
Richard
@rylew0925
Sep 20 2017 01:00
In the "Reverse a String" method, why can't we just reverse the string instead of using the "split" and "join" parameters?

function reverseString(str) {
  return str.split('').reverse('').join('');
}

reverseString("hello");
George Kemp
@gkemp94
Sep 20 2017 01:05
@rylew0925 Hi, we have to make the string an array first
@rylew0925 the reverse method reverses an array in place (Source: MDN documentation)
Richard
@rylew0925
Sep 20 2017 01:06
So using split and join automatically makes the string into an array?
George Kemp
@gkemp94
Sep 20 2017 01:07
@rylew0925 Correct, using split('') creates an array where each element in the array is a letter. Then once you've reversed that array you use join to join all the elements into a single string.
Richard
@rylew0925
Sep 20 2017 01:18
So "split" takes apart the string and makes it into an array, then I use "reverse" to reverse the array, and then I use "join" to piece them all together as a single string?
Richard
@rylew0925
Sep 20 2017 01:36
Is it always going to be required to use the "split" and "join" methods whenever I want to reverse a string?
Richard
@rylew0925
Sep 20 2017 01:47
I'm so burnt out that I am asking obvious questions
a.sanchez
@0100000101010011
Sep 20 2017 01:51
sup folks, just put this up on the hub https://github.com/0100000101010011/gen0 free genesis child starter theme, any feedback or contribution is most welcome
Mr.Chen
@github940075318
Sep 20 2017 02:09
hello
Richard
@rylew0925
Sep 20 2017 02:18
How come the reverse lesson didn't require using split and join?
iso
@iso1048
Sep 20 2017 02:20
@rylew0925 because you were reversing an array not a string
@github940075318 hi
Ken Haduch
@khaduch
Sep 20 2017 03:38
@gkemp94 - did you get your random quote generator sorted out, or do you still need help?
Eric Von Stephan
@EricVon
Sep 20 2017 04:48
hello all
piteto
@piteto
Sep 20 2017 04:52
hello :)
Eric Von Stephan
@EricVon
Sep 20 2017 04:53
can anyone help me with why my menu bar keeps expanding vertical in stead of horizinatl https://codepen.io/ericvstephan/pen/aygXXd . i been trying for he last 3 hours and have no clue
piteto
@piteto
Sep 20 2017 04:56

hmmm, there are a few issues I see:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<link rel="stylesheet" https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js

that second link needs to get deleted
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
^^ the js version doesnt' match the CSS version
bootstrap/3.3.7/ is not the same as bootstrap/4.0.0-beta/
Eric Von Stephan
@EricVon
Sep 20 2017 04:58
kk let mery t
me try sorry is mm on alot of pain drugs at
piteto
@piteto
Sep 20 2017 04:59
coding is much easier with beer
Eric Von Stephan
@EricVon
Sep 20 2017 05:00
lol true but it sucks when your fighting cancer and you us it to keep your mind of other things it works wonders
piteto
@piteto
Sep 20 2017 05:00
We can figure this out though
Seems like you have nearly everything coded right, it's just a matter of how you are loading the resources you need - bootstrap css, jquery and bootstrap.js
Eric Von Stephan
@EricVon
Sep 20 2017 05:02
kk
piteto
@piteto
Sep 20 2017 05:05
@EricVon I made a fork of your codepen here, just a few changes: https://codepen.io/anon/pen/MEyrVq?editors=1010
Eric Von Stephan
@EricVon
Sep 20 2017 05:05
ok i matached the bootstrap versions and deleted the second one
piteto
@piteto
Sep 20 2017 05:05
good, that's the main issue
Eric Von Stephan
@EricVon
Sep 20 2017 05:05
kk
piteto
@piteto
Sep 20 2017 05:06
css goes in the <head> and the JS files like jquery and bootstrap.js go at the end, before </body>
once you fix that, the navbar starts to look like it should
Eric Von Stephan
@EricVon
Sep 20 2017 05:06
oh kk
sorry i just learing this and i got lost for bit
yes it does look right now
thanks
piteto
@piteto
Sep 20 2017 05:09
no problem, it's hard to understand from the documentation the first time through
they treat everyone like they're experts in the documentation
Eric Von Stephan
@EricVon
Sep 20 2017 05:09
just a bit
Eric Von Stephan
@EricVon
Sep 20 2017 05:26
piteto can you take a look at it now and see what it is doing
XueJ
@Shmily-Zed
Sep 20 2017 08:17
I want to ask codepen how to open
krckyboy
@krckyboy
Sep 20 2017 08:48

What am I doing wrong here so that my opacity switches back to its original value, rather than smoothly going back, AFTER I hover off the image? When I hover it, it slowly sets the opacity to .9, but why doesn't it slowly go back to 0 after I move the cursor away from the image? Stuck here, not seeing the problem.

https://codepen.io/krcky/pen/mBPxEQ

Eric Voigt
@ericvoigt
Sep 20 2017 10:08

var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

var entreeValue = testObj["an entree"];
var drinkValue = testObj["the drink"];

oops one second..
So using this bracket notation you are just telling the program that "an entree" will return with "hambruger"
I am little confused..
a
Elizabeth Paul
@Kowalatam
Sep 20 2017 10:24
yeah.. saying testObj["an entree"] is you asking for hamburger
@ericvoigt
Maria Theresa Arruda
@arrudamt
Sep 20 2017 10:50
@krckyboy maybe it is not your opacity, but the background-color that is giving you this effect
Maria Theresa Arruda
@arrudamt
Sep 20 2017 11:10
how can i set the menu-button to the right?
https://codepen.io/arrudamt/pen/wgVYxv
heroiczero
@heroiczero
Sep 20 2017 11:12
@arrudamt do you mean your nav buttons?
Maria Theresa Arruda
@arrudamt
Sep 20 2017 11:13
@heroiczero yeap! i need to fix two things, it is not expanding and it is on the left side
heroiczero
@heroiczero
Sep 20 2017 11:14
@arrudamt you need bootstrap.js for it to expand
@arrudamt you need https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js
Maria Theresa Arruda
@arrudamt
Sep 20 2017 11:15
@heroiczero i will look for that, i have no idea yet about how to do that
@heroiczero is it just add it?
heroiczero
@heroiczero
Sep 20 2017 11:16
@arrudamt you could just add it be using Setting -> Javascript
@arrudamt or use <script src="">
Maria Theresa Arruda
@arrudamt
Sep 20 2017 11:19
@heroiczero thanks! i'll try that
CamperBot
@camperbot
Sep 20 2017 11:19
arrudamt sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1752 | @heroiczero |http://www.freecodecamp.com/heroiczero
Maria Theresa Arruda
@arrudamt
Sep 20 2017 11:20
@lydatech nice! i'll check the code to see how you did it. Thank you!!
CamperBot
@camperbot
Sep 20 2017 11:20
arrudamt sends brownie points to @lydatech :sparkles: :thumbsup: :sparkles:
:star2: 2453 | @lydatech |http://www.freecodecamp.com/lydatech
LydaTech
@lydatech
Sep 20 2017 11:21
@arrudamt I cleaned up your bootstrap calls and added them in the settings. Also I added pull-right to your nav
Maria Theresa Arruda
@arrudamt
Sep 20 2017 11:22
amazing! i'm checking how the code is now. but thanks again! =)
George Kemp
@gkemp94
Sep 20 2017 11:57
@piteto Thanks Eric, I figured it out after some tweaking. Not sure what I had wrong the first time, probably syntax.
CamperBot
@camperbot
Sep 20 2017 11:57
gkemp94 sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 129 | @piteto |http://www.freecodecamp.com/piteto
Semak
@drdextar
Sep 20 2017 13:22
i am facing some issue in 'everything be true challenge'
if someone can guide me regarding the challenge it would be great :)
heroiczero
@heroiczero
Sep 20 2017 13:24
@drdextar can you link the challenge
Semak
@drdextar
Sep 20 2017 13:25
var checkmethod = collection.every(function(array){
if (array.hasOwnProperty(pre))
return true;
else if (!array.hasOwnProperty(pre))
return false;
});
i think i need to modify this block. :)
thanks for sharing the link
Jan Shah
@JanShah
Sep 20 2017 15:09
@drdextar the array doesn't have properties, the values in it do
if you loop through the array you can access the object properties
George Kemp
@gkemp94
Sep 20 2017 15:44
Has anybody else noticed an error in the weather api that they provide us?
Making the same request multiple times yields slightly different results.
Nazar
@IsaakNazar
Sep 20 2017 16:10
Wassup Guys! Need help JS
anyone?
Fredrik Strand Oseberg
@FredrikOseberg
Sep 20 2017 16:42
Anyone experienced with react-redux I can ask a question?
krckyboy
@krckyboy
Sep 20 2017 17:08

Can someone please explain this code to me?

```
.image:hover .overlay {
      opacity: 1;
          }

Is this going on: when .image is in the state of hover, the properties of .overlay change (its opacity goes to 1)?

Richard
@rylew0925
Sep 20 2017 17:16
I'm trying to work on the "Factorialize a Number" lesson. Would someone please explain what I did wrong? It seems correct to me

function factorialize(num) {

if (num === 0 || 1) {
  return 1;
}
else if ((num = num - 1) === 0 || 1) {
  return num * (num * num);
}
}
factorialize(5);
Tom
@moT01
Sep 20 2017 17:18
@FredrikOseberg try the backend room https://gitter.im/FreeCodeCamp/HelpBackEnd
@krckyboy looks like that's what is intended, ...I think I did that once, not sure on the syntax
is that the result you are seeing?
@rylew0925 that if statement looks funny
else if ((num = num - 1)
you setting the value of num in the test?
krckyboy
@krckyboy
Sep 20 2017 17:21
@moT01 It's working, yes, but I was copying the code and tried to understand it. Glad I got it right. Thank you. :)
CamperBot
@camperbot
Sep 20 2017 17:21
krckyboy sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 856 | @mot01 |http://www.freecodecamp.com/mot01
Tom
@moT01
Sep 20 2017 17:22
@gkemp94 yea, there might be some issues with that weather thing. You might want to look around for another one.
Richard
@rylew0925
Sep 20 2017 17:22
@moT01 I was trying to decrement the num by 1 for each run
Tom
@moT01
Sep 20 2017 17:23
pretty sure you should put that stuff in the { }
also, theres no loop there, so you're just doing things once - pretty sure you're going to need to use some sort of loop
Richard
@rylew0925
Sep 20 2017 17:25
But how would I place some loops there if I have to input different numbers?
I mean, I can't just place 5 loops if I also need to input a 10
Tom
@moT01
Sep 20 2017 17:30
use a for loop
for (var i=0; i < num; i++) {}
one way to go anyway
Chris
@bestintown23
Sep 20 2017 17:31
how can i make my satisfaction logo show on the right side of my "we are famous for" section? https://codepen.io/bestintown23/pen/RLPOog
Richard
@rylew0925
Sep 20 2017 17:33
@moT01 Thanks!
CamperBot
@camperbot
Sep 20 2017 17:33
rylew0925 sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 857 | @mot01 |http://www.freecodecamp.com/mot01
George Kemp
@gkemp94
Sep 20 2017 17:42
Anybody able to quickly look at my few lines of code to see why it isn't working?
I'm just trying to get JSON to appear in the console. I can't even do that.
piteto
@piteto
Sep 20 2017 17:46

@gkemp94 Use your browser's console to diagnose this, not the one in codepen, you'll see this error:

XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=query&format=json&list=search&srsearch=Bill%20Gates. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access.

krckyboy
@krckyboy
Sep 20 2017 17:46

Why isn't .overlay-text "CENTER ME" centered, even though there's this code:

    .overlay-text {
        color: yellow;
        display: inline-block;
        position: absolute;
        top: 50%;
        left: 50%;
    }

https://codepen.io/krcky/pen/QqyKQB?editors=1100

George Kemp
@gkemp94
Sep 20 2017 17:48
@piteto How do I solve this issue?
piteto
@piteto
Sep 20 2017 17:48
@gkemp94 add &origin=* to your URL.
var api = "https://en.wikipedia.org/w/api.php?action=query&format=json&list=search&origin=*&srsearch="+search;
Didn't want to straight out give the answer in case you wanted to research a solution first, but since you asked ;) ^ there it is
George Kemp
@gkemp94
Sep 20 2017 17:49
Thanks piteto! I'm not sure what that even meant so I wouldn't know where to even start.
piteto
@piteto
Sep 20 2017 17:50
@krckyboy you have the text pushed over from the left by 50%, which isn't the same as centering the text
@gkemp94 Tens of thousands of people have hit these errors doing these projects before us. The answer is nearly always out there if you search for the error.
The important part is to use your browser's console to find the errors rather than the one in codepen
.overlay-text {
  color: yellow;
  display: inline-block;
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  text-align: center;
}
or:
.overlay-text {
  color: yellow;
  height: 100%;
  width: 100%;
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
}
Liam Docherty
@ldocherty1
Sep 20 2017 18:11
Hi, does anyone have a codepen link or tutorial link on how I can implement the following on my site? When the user scrolls down I want the navigation bar to appear. However, only when they scroll down
John Hui
@mjhui1990
Sep 20 2017 18:26
hi... can anyone help me with my wikiviewer...? I'm not sure if something is wrong with my loop or do i require a call back but when i press search the .innerHTML appends undefined instead of data[1][i] but if it console.log[data[1][1] for instance, it shows the item im searching for.. Thank you https://codepen.io/mjhui90/pen/jGrEmL
piteto
@piteto
Sep 20 2017 18:31
@ldocherty1 I don't know of a tutorial, but with some JS:
window.onscroll = function() {
  navbar.style.display = 'none'
  if(document.body.scrollTop > 0) navbar.style.display = 'block';
}
korzo
@korzo
Sep 20 2017 18:32
@mjhui1990 document.getElementById('searchResult').innerHTML = data[1][i];
You are overwriting element with new data on each iteration.
as last index is 9, you end up with undefined
Liam Docherty
@ldocherty1
Sep 20 2017 18:32
@piteto Thanks much appreciated
CamperBot
@camperbot
Sep 20 2017 18:32
ldocherty1 sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 131 | @piteto |http://www.freecodecamp.com/piteto
Niloy513
@Niloy513
Sep 20 2017 18:41
is anyone here fairly knowledgeable with angularjs and apis
John Hui
@mjhui1990
Sep 20 2017 18:41

@korzo thanks for your help.. I changed it to

for (var i = 0; i <= data[1].length-1; i++) {
document.getElementById('searchResult').innerHTML = data[1][i];   
}

I thought it would loop through the whole array but it's only showing the last item on the array

CamperBot
@camperbot
Sep 20 2017 18:41
mjhui1990 sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 516 | @korzo |http://www.freecodecamp.com/korzo
Niloy513
@Niloy513
Sep 20 2017 18:41
the wikiepedia api to be exact
korzo
@korzo
Sep 20 2017 18:42
@mjhui1990 for (var i = 0; i < data[1].length; i++) {
piteto
@piteto
Sep 20 2017 18:44
@Niloy513 What question do you have?
@mjhui1990 You'll want to append that data, I'm guessing with += instead of =
document.getElementById('searchResult').innerHTML += data[1][i];
Niloy513
@Niloy513
Sep 20 2017 18:45
well I'm trying to make an api call to wiki, I already figured out how to do it with the commented out logic I'm trying to currently figure out how to do it the best with best practice which I'm not being successful in you can take a look https://codepen.io/Niloy513/pen/MEWjpy?editors=0011
I think my main problem has to do with the gsrsearch
property on params object
piteto
@piteto
Sep 20 2017 18:46
XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?&action=query&callback=JSON_CALLBACK&exchars=140&exintro=&exlimit=5&explaintext=&format=json&generator=search&gsrlimit=10&gsrsearch=test&prop=extracts&rawcontinue=. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access.
Cross origin error
John Hui
@mjhui1990
Sep 20 2017 18:49
@piteto thanks it was overriding each post thank you :)
CamperBot
@camperbot
Sep 20 2017 18:49
mjhui1990 sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 132 | @piteto |http://www.freecodecamp.com/piteto
piteto
@piteto
Sep 20 2017 18:50
Glad I could help :)
Niloy513
@Niloy513
Sep 20 2017 18:50
I'm not fairly knowledgeable when it comes to apis, so how would I fix this problem? allow access? if so how would that worked, thanks for the super fast response by the way
piteto
@piteto
Sep 20 2017 18:50
@Niloy513 add this to your params - origin: '*'
you also have some work to do with parsing the results
Niloy513
@Niloy513
Sep 20 2017 18:54
I see I really appreciate the help I'll try to figure out the parsing parts,
@piteto Thank you
CamperBot
@camperbot
Sep 20 2017 18:54
niloy513 sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 133 | @piteto |http://www.freecodecamp.com/piteto
humble_D
@AakashMallik
Sep 20 2017 18:55
@AakashMallik
https://www.topcoder.com/challenge-details/30059421/?type=develop&nocache=true
people who are looking for a development challenge and win a cash prize... here's your chance
krckyboy
@krckyboy
Sep 20 2017 18:59
@piteto But can you please explain to me or give me a good web source where I would learn how to debug and properly use browser's console? Usually it doesn't make sense to me.
piteto
@piteto
Sep 20 2017 19:03
@krckyboy That was for the other person who was getting an error in their Wikipedia viewer app
But, if you want to get better at using your browser console, the documentation is usually a good place to start: https://developers.google.com/web/tools/chrome-devtools/
I don't know of any good tutorials or videos about it unfortunately
krckyboy
@krckyboy
Sep 20 2017 19:04
@piteto Oh, sorry. By the way, you helped me out a lot. But I could have swore that I tried text-align: center and it wouldn't work. But I am not sure if I also included position: relative along with it. I'll probably have to dig into it tomorrow and try to understand a few things about it.
@piteto Thank you! :)
CamperBot
@camperbot
Sep 20 2017 19:04
krckyboy sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 134 | @piteto |http://www.freecodecamp.com/piteto
Adam Kim
@resv
Sep 20 2017 19:08
anyone have any idea why my portfolio for FCC comes out great on atom, and the project section of codepen but on the pen section, my imgs/grid either doesn't display or runs into a bug? all images were converted to postimg.org instead of imgur, but my project section grid just gets all messed up. here is a link to the project section: https://codepen.io/Resv/project/editor/ZogMkO and then on the pen section that doesn't work: https://codepen.io/Resv/pen/oGLgXm
image.png
aRtoo
@artoodeeto
Sep 20 2017 19:30

hey fam. question. if i have this.

var test;
var rest = 1;

test = rest;

question:
are we duplicating the value of rest by just assigning rest to test?
or are we passing the value rest to test? so if we console at the bottom part rest will be undefined??

piteto
@piteto
Sep 20 2017 19:48
@artoodeeto when doing this with primitive values, you're duplicating:
var test;
var rest = 1;
test = rest;
console.log(test, rest); // 1 1
rest = 2;
console.log(test, rest); // 1 2
test = 3;
console.log(test, rest); // 3 2
rest = test = 4;
console.log(test, rest); // 4 4
aRtoo
@artoodeeto
Sep 20 2017 19:49
@piteto yea its will just copy the values not change it. thanks
CamperBot
@camperbot
Sep 20 2017 19:49
artoodeeto sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 135 | @piteto |http://www.freecodecamp.com/piteto
piteto
@piteto
Sep 20 2017 19:50
@artoodeeto With objects, it's different
var test = [1, 2, 3];
var rest = test;
rest.push(4);
console.log(rest, test); // [1, 2, 3, 4] [1, 2, 3, 4]
aRtoo
@artoodeeto
Sep 20 2017 19:50
@piteto yea with object it will reference it
@piteto right. thanks man
CamperBot
@camperbot
Sep 20 2017 19:51
artoodeeto sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
api offline
piteto
@piteto
Sep 20 2017 19:52
no problem, you're welcome
Victor Abeledo
@victorja
Sep 20 2017 20:20
Hi guys, do you know how to make the survey's body text alignment look similar to the one in the example?
my pen:
https://codepen.io/victorabeledo/pen/RLWJgB
niprobin
@niprobin
Sep 20 2017 21:06
Hi guys, I am using a large picture as a background for a div and I would like to make it smaller while filling the div. I tried everything but cannot come up with a solution. The different divs are part of a grid layout, might that be a problem?
best case would be to see the image in full
Johnny
@jtan3
Sep 20 2017 21:19
@niprobin try background-position: center;
Maria Theresa Arruda
@arrudamt
Sep 20 2017 21:34
how can i set the list elements to the right?
https://codepen.io/arrudamt/pen/wgVYxv?editors=1100
Maria Theresa Arruda
@arrudamt
Sep 20 2017 21:46
@JohnnyBizzel you put them way more to the left than it was.
I want the list of elements of my navbar closer to the right margin, and my logo closer to my left margin.
Johnny
@JohnnyBizzel
Sep 20 2017 21:46
@arrudamt So some space between?
Maria Theresa Arruda
@arrudamt
Sep 20 2017 21:46
@JohnnyBizzel yeap
Johnny
@JohnnyBizzel
Sep 20 2017 21:48
Maria Theresa Arruda
@arrudamt
Sep 20 2017 21:57
yeah, something like that. what did you do?
@JohnnyBizzel you inverted the float
Johnny
@JohnnyBizzel
Sep 20 2017 21:58
@arrudamt you had 2 references to difference versions of Bootstrap. I changed it to use one version. Having 2 versions is not a good idea.
I'm not sure what you mean by float
Maria Theresa Arruda
@arrudamt
Sep 20 2017 22:01
wow, it really does make all the difference having just one @JohnnyBizzel , deleting one did the work, thanks!!!
CamperBot
@camperbot
Sep 20 2017 22:01
arrudamt sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1759 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Sep 20 2017 22:01
@arrudamt Yes, stick to 3.3.7 which should be more stable.
Maria Theresa Arruda
@arrudamt
Sep 20 2017 22:02
@JohnnyBizzel didn't know that. thanks again
CamperBot
@camperbot
Sep 20 2017 22:02
arrudamt sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
api offline
Johnny
@JohnnyBizzel
Sep 20 2017 22:02
@arrudamt ;)
Daniel
@Feldbot
Sep 20 2017 23:19
I'm working on the sum all numbers in a range challenge, and my challenge isn't passing for some reason even though I've got the right return values. I used the ... spread operator which is ES6, so I put a declaration in so it should work. Anyone know why this might not be passing?
/*jshint esversion: 6 */

var newArr =[];

function sumAll(arr) {
  var min = Math.min(...arr), max = Math.max(...arr);  
  for (var i = min; i <= max; i++) {
    newArr.push(i);    
  } 
  var answer = newArr.reduce(function(accumulator, currentValue) {
    return accumulator + currentValue;
  }); 
  return answer; 
}

sumAll([1, 4]);
piteto
@piteto
Sep 20 2017 23:24
@Feldbot Move your newArr inside your function. someone hit that issue a couple days ago and it seem free code camp makes you keep your variables inside your functions
Daniel
@Feldbot
Sep 20 2017 23:26
Bingo! Thanks again @piteto, you are on it!
CamperBot
@camperbot
Sep 20 2017 23:26
feldbot sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 136 | @piteto |http://www.freecodecamp.com/piteto
piteto
@piteto
Sep 20 2017 23:26
For what it's worth, it isn't necessary to add everything to an array and then loop through your new array to get a sum. That's 2 loops, plus you're mixing up ES6 and ES5 inside that function.
Daniel
@Feldbot
Sep 20 2017 23:30
@piteto Is it not a good practice to combine ES5 and ES6 in the same script?
@piteto I was following the assignment hints about using Math.min/max and .reduce as well. Aren't these all necessary, roughly?
piteto
@piteto
Sep 20 2017 23:34
@Feldbot I think it's kind of like mixing jquery + vanilla js. Fine to do, but maybe a little more readable not to do it.
function sumAll(arr) {
  const newArr =[], min = Math.min(...arr), max = Math.max(...arr);  
  for (let i = min; i <= max; i++) {
    newArr.push(i);    
  } 
  return newArr.reduce((accumulator, currentValue) => accumulator + currentValue); 
}
or all ES5:
function sumAll(arr) {
  var newArr =[];
  var min = Math.min.apply(null, arr), max = Math.max.apply(null, arr);  
  for (var i = min; i <= max; i++) {
    newArr.push(i);    
  } 
  return newArr.reduce(function(accumulator, currentValue) {
    return accumulator + currentValue;
  }); 
}
whoops, edited the first example to remove var
Daniel
@Feldbot
Sep 20 2017 23:37
@piteto Don't both those examples have two loops as well? I guess I don't quite follow you there...
piteto
@piteto
Sep 20 2017 23:38
That's just the es5 vs es6. To do it with one loop, you could do:
function sumAll(arr) {
  var sum = 0;
  var min = Math.min.apply(null, arr), max = Math.max.apply(null, arr);  
  for (var i = min; i <= max; i++) {
    sum += i;
  } 

  return sum;
}
the idea is to add each number to a variable rather than adding them all to an array and looping through that new array to get a final sum.
Daniel
@Feldbot
Sep 20 2017 23:47
@piteto I started reading about .apply and got way over my head pretty fast with many concepts I haven't had experience with so I opted for the ... spread method, which MDN recommended as the easier solution. I see what you are saying though about reduce being redundant, yours is a good solution.