These are chat archives for FreeCodeCamp/HelpJavaScript

31st
Aug 2017
mambasnoww
@mambasnoww
Aug 31 2017 00:14
can someone help with my javascript code
Ken Haduch
@khaduch
Aug 31 2017 00:15
@mambasnoww - please post what you have and questions, you'll get help here...
mambasnoww
@mambasnoww
Aug 31 2017 00:16
trying to to get the average from userinput and display alert of the average
Ken Haduch
@khaduch
Aug 31 2017 00:19
@mambasnoww - make sure to use the same ID values in your code as you do in your HTML - num1 instead of n1, etc.
Elizabeth Paul
@Kowalatam
Aug 31 2017 00:20
im trying to deal with precision issues .. i am currently using .toPrecision() but its not working exactly as i want as i have to specify number of values i want
can sm1 help me with smtin better ?
:)
mambasnoww
@mambasnoww
Aug 31 2017 00:21
@khaduch i changed fixed the id recognition but onclick its still not displaying the alert
Ken Haduch
@khaduch
Aug 31 2017 00:22
@mambasnoww - it worked for me - did you save your project again? I'll check it once more.
@mambasnoww - I reloaded your project and tried it - it looks like it worked?
mambasnoww
@mambasnoww
Aug 31 2017 00:26
@khaduch my chrome must be blocking the alert then...
Ken Haduch
@khaduch
Aug 31 2017 00:26
@mambasnoww - maybe you are blocking alerts somehow? It works well for me.
check the settings on Chrome and see if there is a way to re-enable the alerts?
Ken Haduch
@khaduch
Aug 31 2017 00:31
mambasnoww
@mambasnoww
Aug 31 2017 00:32
@khaduch thanks a lot this was really hard to debug cause of that
CamperBot
@camperbot
Aug 31 2017 00:32
mambasnoww sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3252 | @khaduch |http://www.freecodecamp.com/khaduch
mambasnoww
@mambasnoww
Aug 31 2017 00:32
@khaduch i appreciate the help :)
Ken Haduch
@khaduch
Aug 31 2017 00:33
@Kowalatam - could you give some examples of what you mean? I'm not sure that I understand... in fact, I'm sure that I don't understand... ;)
@mambasnoww - you're welcome.
Elizabeth Paul
@Kowalatam
Aug 31 2017 00:39
@khaduch dealing with things like 0.2 + 0.4 = 0.6000000000000001
but in my case, i just have things adding up and then giving me a result.. im working on the calculator
Ken Haduch
@khaduch
Aug 31 2017 00:42
@Kowalatam - maybe you want to use .toFixed() instead? It's hard to know exactly what would work out the best?
Elizabeth Paul
@Kowalatam
Aug 31 2017 00:43
@khaduch i tried that but if the value is an integer, it won't log the result
and toFixed also has its limitations :(
as toPrecision() also does
this is currently how it is behaving https://codepen.io/Kowalatam/pen/oeqrxa
Ken Haduch
@khaduch
Aug 31 2017 00:44
some number with very small values, like 0.0000000000549 might not work out to well with a small toFixed value? There are difficulties with precision in calculations. I though that an integer would be shown? I'll check out your project.
Elizabeth Paul
@Kowalatam
Aug 31 2017 00:46
i probably used it wrong when i did then.. thank u.. don't mind the confusing names i gave.. im working on it :) @khaduch
CamperBot
@camperbot
Aug 31 2017 00:46
kowalatam sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3253 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Aug 31 2017 00:46
@Kowalatam - but 0.2 + 0.4 is giving me
Syntax ERROR?
Elizabeth Paul
@Kowalatam
Aug 31 2017 00:47
@khaduch really.. i think i haven't pasted the recent stuff on codepen.. hold on
Ken Haduch
@khaduch
Aug 31 2017 00:47
ok
Elizabeth Paul
@Kowalatam
Aug 31 2017 00:50
with this one the .toprecision is not there.. i was re-arranging my code
i use it in line 52 as
            $("#theResult").html(x.toPrecision(2));
Ken Haduch
@khaduch
Aug 31 2017 00:51
@Kowalatam - I tried something - 2+2= gives the answer 4, then "AC" then 2+2 gives some other answer, AC, then 2+2 = something else? It seems to be accumulating some values somewhere / somehow?
Elizabeth Paul
@Kowalatam
Aug 31 2017 00:52
@khaduch aish.... well.. i think my code is all messed up now ... :( .. everything was working well a few hours ago... :(
i see why now lol @khaduch
i haven't worked on my AC button in days lol.. thank u for pointing that out
it only clears the display but not what calculates :)
Ken Haduch
@khaduch
Aug 31 2017 00:55
@Kowalatam - okay... From my reading on .toPrecision() it will probably not work too easily because it takes the number of significant digits - which I think means any non-zero digits, and then shortens the length from there. So if you have 0.0000023423 and use .toPrecision(2), you'll get 0.0000023, etc.?
Elizabeth Paul
@Kowalatam
Aug 31 2017 00:57
i have fixed the AC button.
@khaduch yeah it does that
but i guess i might not get exactly something perfect but its just that in that result, an example like 100 return 1.0e+2
Gersho
@Gersho
Aug 31 2017 01:00
@khaduch if you have 0.0000012454 shouldn't you use toExponential instead ?
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:00
and i don't like that very much :(
Ken Haduch
@khaduch
Aug 31 2017 01:00
@Kowalatam - this calculation looks good - 20000005+.20000005 = 0.4000001
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:01
@Gersho it starts counting from the non zero number .. in ur case 1
Gersho
@Gersho
Aug 31 2017 01:01
i don't know the specifics of your code but i used the following to handle long display
    if(arg.toString().length > 11){
      arg = arg.toExponential(7);
    }
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:02

displaying that as 0.4 might look more neat i think.. i dunno

@Kowalatam - this calculation looks good - 20000005+.20000005 = 0.4000001

@khaduch
Gersho
@Gersho
Aug 31 2017 01:02
it catches both big ints and extremely small decimals
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:03
@Gersho hmmm
doesnt catch integers ?
Ken Haduch
@khaduch
Aug 31 2017 01:04
@Gersho - that's an interesting idea - I was thinking of something along those lines, I haven't worked that project out yet.
Gersho
@Gersho
Aug 31 2017 01:05
it catches integers, if whatever displayed is longer than 11 caracters , it's presented in scientific notation
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:06
trying it now..
Ken Haduch
@khaduch
Aug 31 2017 01:09
@Kowalatam - :point_up: August 30, 2017 9:02 PM - yes, but it depends on the precision that you want to display? I think case, I actually had those significant digits in my input calculation, so the fact that it was clearly displayed looked good for that case. It does seem like a case by case basis. Some calculators I've seen have a switch that selects the precision of decimal places, at least I recall something like that.
Gersho
@Gersho
Aug 31 2017 01:09
well there's plenty different calculator models
Ken Haduch
@khaduch
Aug 31 2017 01:10
that's for sure...
Gersho
@Gersho
Aug 31 2017 01:10
mine has a double 0 button for exemple
some have % , x² etc..
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:11
@khaduch yeah i might have to use it as it is
just that with .toPrecision(2) would be that 0.4+0.2 = 0.60
i just find it weird lol...
but i'm honestly exhausted :). i might just settle ....
or make an input somewhere that asks the user for the precision value ? :)
Gersho
@Gersho
Aug 31 2017 01:14
you could make a check before using toPrecision, as to not call it if not necessary
Ken Haduch
@khaduch
Aug 31 2017 01:14
@Kowalatam - you might have to, or after you get a reasonably solid implementation, then see if there are any ways to tweak it. But I guess that there isn't a full specification of how the calculator should operate, then probably just using due diligence and making it work reasonably well is a goal. You could probably try to model some other "real" calculators and see how they handle the calculations that look funny to you?
Gersho
@Gersho
Aug 31 2017 01:15

or make an input somewhere that asks the user for the precision value ? :)

make it as you wish, it's YOUR calculator after all :)

as long as it respect the user stories (and math rules too ^^)
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:16
@Gersho i was mostly using .toPrecision to deal with things like 0.4+0.2 = 0.600000000001 .. i exempted things like "π" to show its full decimals
@khaduch @Gersho yeah.. true... well as life is not perfect... the calculator shouldn't be also :)
Ken Haduch
@khaduch
Aug 31 2017 01:18
@Kowalatam - :) yes, it would be handy if they had requirements for particular calculations and precisions, etc. to have an example. Perhaps look at the sample project's calculations and see how well it works? (I'll have to try and start this project one of these days...) Good luck with that!
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:19
@khaduch yes.. thats true.. i could just steal the code they used :)
for the precision ....
Ken Haduch
@khaduch
Aug 31 2017 01:20
I wasn't necessarily recommending that, but you could do a QA run with some of those calculations just to see how the results were displayed.
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:20
@khaduch yeah i know.. lol.... thank you
CamperBot
@camperbot
Aug 31 2017 01:20
:warning: kowalatam already gave khaduch points
kowalatam sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:20
and u too @Gersho thanks
Gersho
@Gersho
Aug 31 2017 01:21
if i keep pressing numbers they go out of the window
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:22
@Gersho ahhh.. didn't consider that thank u
CamperBot
@camperbot
Aug 31 2017 01:22
kowalatam sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 379 | @gersho |http://www.freecodecamp.com/gersho
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:23
but what made u press continously lol
Gersho
@Gersho
Aug 31 2017 01:25
because i could
on my projects, half of my code is preventing the user from being stupid
so i try my "best" when testing ^ ^
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:26
lol.. makes sense.. @Gersho
Mai Thinh
@mthinh
Aug 31 2017 01:27
hello guys, if I have a number like 58999 , how can I round it to 59000
Gersho
@Gersho
Aug 31 2017 01:27
for exemple you need to consider what happen if the person types "2+" and then "x", did he change his mind ? will you consider the + or the x ?
lfvpCO
@lfvpCO
Aug 31 2017 01:27
hello guys
I need your help
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:28
@Gersho yeah.. i took that into consideration.. it would return error...
lfvpCO
@lfvpCO
Aug 31 2017 01:28
I am coding something to caculate the price of a plate acording to how many letters has has my name
and I need the code in JS
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:28
i hope it works as it should though...
Gersho
@Gersho
Aug 31 2017 01:28
@mthinh depending on how you need to round (10, 100, etc) you divide it by 10, then Math.round then multiply it back ? (i didn't test that, just thinking out loud)
Elizabeth Paul
@Kowalatam
Aug 31 2017 01:28
@mthinh sounds tricky lol
Gersho
@Gersho
Aug 31 2017 01:29
@lfvpCO return numberOfLetter * pricePerLetter; ?
Mai Thinh
@mthinh
Aug 31 2017 01:30
@Gersho I'll try your way
lfvpCO
@lfvpCO
Aug 31 2017 01:31
I need something when someone put his or her name that Js calculate the numbers of the letters. I have the code to show intye web

``var price;
var quantity;
var total;

price = 5;
quantity = 30;
total = price * quantity;

var el = document.getElementById('cost');
el.textContent = '$' + total;``

Gersho
@Gersho
Aug 31 2017 01:31
@lfvpCO you'll need to use string.length then, it tells you how many characters there is (this method will charge the customer if there is a space)
lfvpCO
@lfvpCO
Aug 31 2017 01:32
yes
with space
I am new coding JS just 2 days.. and I dont have any idea how to do it.. any pic of code as a example
Gersho
@Gersho
Aug 31 2017 01:34
well first, where is the variable for the sentence the customer has typed ? or is it stored somewhere else ?
is that someone they should be typing in a form ?
lfvpCO
@lfvpCO
Aug 31 2017 01:36
i need a win
window when some put the name.. and that data has to be calculate.. in my code I can change the data and show in the web.. but I need something that someone can put the name and then being calculated
Something like getelementbyid
or something like that
lfvpCO
@lfvpCO
Aug 31 2017 01:43
I need a selector for quantity to change the content..
piteto
@piteto
Aug 31 2017 01:46
string.length does not always tell you the number of characters
Array.from(string).length is a more reliable approach
olgi3rd
@olgi3rd
Aug 31 2017 01:51
@piteto What does the from method do?
piteto
@piteto
Aug 31 2017 01:51
@olgi3rd Array.from() makes an iterable object into an array
And more...
olgi3rd
@olgi3rd
Aug 31 2017 01:54
I didn't know that.
piteto
@piteto
Aug 31 2017 01:55
It's similar to using a spread operator in brackets: [...string].length
Randell Dawson
@RandellDawson
Aug 31 2017 03:17
@lfvpCO - Did you figure out how to solve your problem?
lfvpCO
@lfvpCO
Aug 31 2017 03:19
Not yet. 🙁
I need a pop up windows to insert the name.. then. The code in JS will tell me how many letters the name has and will give me the cost. Point being is that I don't know how to put that pop up window..
korzo
@korzo
Aug 31 2017 03:25
@lfvpCO var person = prompt("Please enter your name");
Mai Thinh
@mthinh
Aug 31 2017 03:26
hey guys, i've finished my pomodoro clock, check it out and give me some words
Randell Dawson
@RandellDawson
Aug 31 2017 03:27
@lfvpCO - Do you have a Codepen or JSFiddle link to what code you have so far?
Gersho
@Gersho
Aug 31 2017 03:29
@mthinh looks nice, but there's a box around the buttons when you click them, also there is nothing telling us if we are in session period or on a break
Mai Thinh
@mthinh
Aug 31 2017 03:30
@Gersho yah, i'll fix it :D
thank you @Gersho
CamperBot
@camperbot
Aug 31 2017 03:30
mthinh sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 380 | @gersho |http://www.freecodecamp.com/gersho
John
@AnonymousLords
Aug 31 2017 03:33
Guys
is
str[i] = /[A-Z]/g a thing?
Gersho
@Gersho
Aug 31 2017 03:34
you mean storing a regex in a variable ?
Randell Dawson
@RandellDawson
Aug 31 2017 03:38
You can store a regex in an array if that is what you are asking.
var str = [];
str[0] = /[A-Z]/g

var testStr = "hello";
str[0].test(testStr); // false;

var testStr2 = "Hello";
str[0].test(testStr2); // true
korzo
@korzo
Aug 31 2017 03:41
@mthinh It looks strange to see time as 0:3:05, but that's probably just me
Gersho
@Gersho
Aug 31 2017 03:42
didn't even notice lol, kinda pointless considering this system isn't meant to use hours
Randell Dawson
@RandellDawson
Aug 31 2017 03:43
@mthinh - Maybe put an upper limit on the number of minutes for work and break.
Mai Thinh
@mthinh
Aug 31 2017 03:44
@rmdawson71 what do you mean? a little bit confused
@korzo ok thank you, i fixed it
CamperBot
@camperbot
Aug 31 2017 03:44
mthinh sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 436 | @korzo |http://www.freecodecamp.com/korzo
Slitherings
@Slitherings
Aug 31 2017 04:34
need help on this challenge
Title Case a Sentence
function titleCase(str) {
  var Splitstr = str.split(" ").length;
  var firstLetter = str.charAt(0).toUpperCase();

  for(var i = 0; i < Splitstr; i++){
    if(firstLetter == i){
      return firstLetter;
    }
  }
  return firstLetter;
}

titleCase("I'm a little tea pot");
i cant figure out a way to get it to capitalize the first word of every Array
Gersho
@Gersho
Aug 31 2017 04:35
what are we supposed to do on that one ?
Markus Kiili
@Masd925
Aug 31 2017 04:35
@Slitherings Strings are immutable.
@Slitherings You can iterate the array of words and make a new capitalized word and assign it back to the array of words.
So first make an array of words.
Slitherings
@Slitherings
Aug 31 2017 04:36
so would i have to split the string i was giving, then for each array capitalize each starting Word
Gersho
@Gersho
Aug 31 2017 04:36
he did, but he's not calling it ?
Slitherings
@Slitherings
Aug 31 2017 04:36
then join it together ?
Gersho
@Gersho
Aug 31 2017 04:37
why don't you use the Splitstr you made ?
Markus Kiili
@Masd925
Aug 31 2017 04:37
It is a number.
Slitherings
@Slitherings
Aug 31 2017 04:37
for(var i = 0; i < Splitstr; i++){
@Gersho my whole code was pretty much a experiment
Markus Kiili
@Masd925
Aug 31 2017 04:37
@Slitherings Do just var Splitstr = str.split(" ");
Gersho
@Gersho
Aug 31 2017 04:38
oh i didn't even notice the .length
guess i'm getting tired xD
Slitherings
@Slitherings
Aug 31 2017 04:38
Its just returning the first word "I"
wont even display the whole word
if it displays the whole "I'm" then i can just add a join at the end of the loop
Gersho
@Gersho
Aug 31 2017 04:38
well you return firstletter;
so it returns it, ending the function
return = end of function
Markus Kiili
@Masd925
Aug 31 2017 04:39
@Slitherings Inside the loop you need to make the new titlecased word from the original looped word, and then assign it back to the array.
Slitherings
@Slitherings
Aug 31 2017 04:39
i need it to capitalize the first letter and still output the whole word
Gersho
@Gersho
Aug 31 2017 04:40
you use return only when you're done modifying what you want
Slitherings
@Slitherings
Aug 31 2017 04:40
dont you hate it when you do alot of code in one day then you come back and its all foreign in your mind again?
Gersho
@Gersho
Aug 31 2017 04:40
yesterday, only god and i knew what this meant, today only god (can't remember who)
Ogundele Olumide
@Lumexralph
Aug 31 2017 04:47
@Masd925 Good Morning
Markus Kiili
@Masd925
Aug 31 2017 04:48
@Lumexralph Morning.
Ghost
@ghost~55a04b725e0d51bd787af54c
Aug 31 2017 04:54
hI
Hi people of javascript
Please help me resolve this issue: https://codepen.io/Refath/pen/XaoMEj
prakash chandra yadav
@prakashyadav008
Aug 31 2017 05:22
hello everyone
can anyone tell me why the api request isnt working
piteto
@piteto
Aug 31 2017 05:23
Uncaught ReferenceError: $ is not defined
Gersho
@Gersho
Aug 31 2017 05:23
no jquery ?
piteto
@piteto
Aug 31 2017 05:23
XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=query&titles=India&prop=revisions&rvprop=content&format=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access.
The first one is like gersho says, add jquery
the second one means you need to use another way to access the API - I don't know if wikipedia allows cross origin
prakash chandra yadav
@prakashyadav008
Aug 31 2017 05:26
thnks man i always forget to add the jquery
Gersho
@Gersho
Aug 31 2017 05:26
iirc for wiki you only need to add a header to your ajax call for it to be accepted
prakash chandra yadav
@prakashyadav008
Aug 31 2017 05:26
thanks @Gersho
CamperBot
@camperbot
Aug 31 2017 05:26
prakashyadav008 sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
piteto
@piteto
Aug 31 2017 05:26
I'm guessing lots of poeple have done that project before you, so an answer should be available from google if you search for the error
CamperBot
@camperbot
Aug 31 2017 05:26
:cookie: 384 | @gersho |http://www.freecodecamp.com/gersho
Gersho
@Gersho
Aug 31 2017 05:27
(any header really, mine is headers: { "Api-User-Agent": "fCC_CodePen_Gersho" }, )
piteto
@piteto
Aug 31 2017 05:27

Yeah, first result from google: https://stackoverflow.com/questions/23952045/wikipedia-api-cross-origin-requests
Add &origin=* to your URL

i had to do this on freeCodeCamp project and the solution was so simple i had to laugh since i spent hours searching it. in your jquery url include this parameter &origin=*

Gersho
@Gersho
Aug 31 2017 05:28
lol your method is even simplier, and yeah i spent quite some time on it too ._.
prakash chandra yadav
@prakashyadav008
Aug 31 2017 05:29
i think i need to add callback=?
Gersho
@Gersho
Aug 31 2017 05:29
depends how you make your call i guess ? i didn't llook at your code tbh ^^
prakash chandra yadav
@prakashyadav008
Aug 31 2017 05:32
so what are the ways to deal with cross origin error
Gersho
@Gersho
Aug 31 2017 05:33
either piteto's &origin=* in your url call, or put a header (if you're using ajax)
prakash chandra yadav
@prakashyadav008
Aug 31 2017 05:34
i am using JSON request
Gersho
@Gersho
Aug 31 2017 05:34
then piteto's
piteto
@piteto
Aug 31 2017 05:36
the header is ignored
prakash chandra yadav
@prakashyadav008
Aug 31 2017 05:37
can anyone give a reference to study AJAX
and Ajax requests
Markus Kiili
@Masd925
Aug 31 2017 05:42
@prakashyadav008 W3Schools ajax material if fine and jQuery has its own docs about ajax methods.
Gersho
@Gersho
Aug 31 2017 05:43
zeal is a nice tool to have a quick look at documentation
Ogundele Olumide
@Lumexralph
Aug 31 2017 05:45
@Masd925 what's happening today?
Markus Kiili
@Masd925
Aug 31 2017 05:46
@Lumexralph Trying to remember how GitHub works.
prakash chandra yadav
@prakashyadav008
Aug 31 2017 05:47
i am getting the response using the wikipedia api
but its hard to extract the info from it
Gersho
@Gersho
Aug 31 2017 05:47
@prakashyadav008 \o/
prakash chandra yadav
@prakashyadav008
Aug 31 2017 05:47
cant make out the response
Gersho
@Gersho
Aug 31 2017 05:47
@prakashyadav008 copy the url you used in your call, use it in your browser
copy to a text file
Ogundele Olumide
@Lumexralph
Aug 31 2017 05:48
@prakashyadav008 study the structure of the data, it's mostly in embedded form of arrays and objects
Markus Kiili
@Masd925
Aug 31 2017 05:49
@prakashyadav008 Browser developer tools can also show the response structure. Might depend on the browser though.
prakash chandra yadav
@prakashyadav008
Aug 31 2017 05:49
https://en.wikipedia.org/w/api.php?action=query&titles=India&prop=revisions&rvprop=content&format=json&origin=*
take a look
Ogundele Olumide
@Lumexralph
Aug 31 2017 05:50
@Masd925 :joy: , how's that coming up?
prakash chandra yadav
@prakashyadav008
Aug 31 2017 05:51
@Gersho
Gersho
@Gersho
Aug 31 2017 05:51
@Masd925 yep depends on browser, firefox will fix it nicely
but you can always make pretty after
prakash chandra yadav
@prakashyadav008
Aug 31 2017 05:51
@Lumexralph
the pretty version still has jumbled up content
since its inside a single array
Gersho
@Gersho
Aug 31 2017 05:52
the form of the data depends on the type of call you made (the wiki api has a LOT of stuff)
Markus Kiili
@Masd925
Aug 31 2017 05:53
@Lumexralph Managed to push some stuff there eventually.
Ogundele Olumide
@Lumexralph
Aug 31 2017 05:54
@prakashyadav008 just check the field you want to access and access it like you'll access nested arrays and objects.... i use an extension in chrome that helps me get a neat json data structure when i'm working with it
@Masd925 how funny you can be in your sarcasm
Markus Kiili
@Masd925
Aug 31 2017 05:58
@Lumexralph No sarcasm this time. Just haven't used git for a while.
Ogundele Olumide
@Lumexralph
Aug 31 2017 06:12
@Masd925 okay.... cool, you can learn git workflow in the process too
Markus Kiili
@Masd925
Aug 31 2017 06:13
@Lumexralph I used it in some group projects at school, but never really used it at work.
murp9702
@murp9702
Aug 31 2017 06:19

Can someone help me spot my bugs? Not giving the output it should. ```function translatePigLatin(str) {

 var stringJoin = [];

var stringSplit = str.split("");

if (stringSplit[0] == "a"||"e"||"i"||"o"||"u") {

  stringJoin.push(str);
  stringJoin += "way";

}

else {

for(var i=0; i<str.length; i++) {

 var chr = str.charAt(i);

    if (chr =='a'||'e'||'i'||'o'||'u')
     break;
    }
    if (i < str.length) {

      stringJoin = str.substr(i) + str.substr(-i) + "ay";
    }

}

return stringJoin;
}

translatePigLatin("glove");

function translatePigLatin(str) {


     var stringJoin = [];
  var stringSplit = str.split("");


    if (stringSplit[0] == "a"||"e"||"i"||"o"||"u") {

      stringJoin.push(str);
      stringJoin += "way";

    }

  else {

    for(var i=0; i<str.length; i++) {

     var chr = str.charAt(i);

        if (chr =='a'||'e'||'i'||'o'||'u')
         break;
        }
        if (i < str.length) {

          stringJoin = str.substr(i) + str.substr(-i) + "ay";
        }



  }









  return stringJoin;
}

translatePigLatin("glove");
Gersho
@Gersho
Aug 31 2017 06:22
put the ``` in a separate line it avoids bugs ;)
i'd put the break in {} just in case
Markus Kiili
@Masd925
Aug 31 2017 06:27
@murp9702 It would need to be like if(chr==='a' || chr==='e' || ...)
The condition you have there is always truthy.
murp9702
@murp9702
Aug 31 2017 06:38
Okay I think I am good now on getting a string with a vowel first to work. Any tips on getting the loop to go through constants to work?
function translatePigLatin(str) {


     var stringJoin = [];
  var stringSplit = str.split("");
  var i;

    if (stringSplit[0] == "a"||stringSplit[0] == "e"||stringSplit[0] == "i"||stringSplit[0] == "o"||stringSplit[0] == "u") {

      stringJoin.push(str);
      stringJoin += "way";

    }

  else {

    for(i=0; i<str.length; i++) {

     var chr = str.charAt(i);

        if (chr =='a'||chr =='e'||chr =='i'||chr =='o'||chr =='u') {
         break;
        }

        if (i < str.length) {
          console.log(i);
          stringJoin = str.substr(i) + str.substr(-i) + "ay";
        }



  }

  }







  return stringJoin;
}

translatePigLatin("california");
Andi Zhang
@AndyGrylls
Aug 31 2017 06:49
$(function(){
var apple = $("li:eq(1)");
apple.setAttribute("title","apple");
});
István Kozma
@Manfred28
Aug 31 2017 07:04

@murp9702 you could write a check to verify that the array's element is a letter. If it's a letter, and it's not a vowel, it is a consonant.

Alternatively (and this is probably the better solution), use regexp

unless I misunderstood what you were trying to do :P
Markus Kiili
@Masd925
Aug 31 2017 07:07
@murp9702 Another compact way to check is if("aeiou".indexOf(chr)>-1){...}
Daniel Romero
@Ranacode
Aug 31 2017 07:17
What's up guys
I'm thinking about make a landing page with a mini admin-panel that allow me to change the data and the images. Any inspirations for this?
Should I use a database for this?
Kelechi Chinaka
@ke1echi
Aug 31 2017 07:20
function arrCheck(value) {
  for (var i = 0; i <= value.length; i++) {
    if (!Array.isArray(value[i])) return false
  }
  return true
}
am trying to check if every element in an array is an array..what am i doing wrong
Markus Kiili
@Masd925
Aug 31 2017 07:20
@kelechy i<value.length
Kelechi Chinaka
@ke1echi
Aug 31 2017 07:21
oh :smile:
thanks @Masd925
CamperBot
@camperbot
Aug 31 2017 07:21
kelechy sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4456 | @masd925 |http://www.freecodecamp.com/masd925
Kelechi Chinaka
@ke1echi
Aug 31 2017 07:22
that additional iteration sometimes confuses me..is there any logic u use for that part @Masd925 :smile:
<=
<
Markus Kiili
@Masd925
Aug 31 2017 07:23
@kelechy Well. Array indices start from 0 so the last element is always at index arr.length -1. So therefore the <.
Kelechi Chinaka
@ke1echi
Aug 31 2017 07:24
ok
Markus Kiili
@Masd925
Aug 31 2017 07:24
@kelechy Another way to check would be value.every(Array.isArray).
Kelechi Chinaka
@ke1echi
Aug 31 2017 07:25
very true so <= gives an extra iteration
yea every()
Gersho
@Gersho
Aug 31 2017 07:27
btw @kelechy i think you'll like my tribute page ;)
https://codepen.io/Gersho/pen/RpGJNJ
Kelechi Chinaka
@ke1echi
Aug 31 2017 07:30
my feedback @Gersho ..i think the last pic is necessary
u could also give us a Wikipedia link where we could read more about him
Gersho
@Gersho
Aug 31 2017 07:31
what do you mean it's necessary ?
oh ok ^^
Kelechi Chinaka
@ke1echi
Aug 31 2017 07:32
is not necessary
aside those..nice piece @Gersho
Markus Kiili
@Masd925
Aug 31 2017 07:33
@kelechy Last pic is a wikipedia link.
Gersho
@Gersho
Aug 31 2017 07:33
hmm, guess i'll go for a black&white one (i still want to, but it's true it kinda breaks the feel of the page)
it's a link to the manga, not the author
thanks for the feedback @kelechy @Masd925
i'll check that tomorrow i'm going to bed
CamperBot
@camperbot
Aug 31 2017 07:34
gersho sends brownie points to @kelechy and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 312 | @kelechy |http://www.freecodecamp.com/kelechy
:star2: 4457 | @masd925 |http://www.freecodecamp.com/masd925
Kelechi Chinaka
@ke1echi
Aug 31 2017 07:35
a bootstrap search glyphicon would be great for that
and i never knew it was a link, because the tooltip does not show that @Gersho
caozhepeng
@caozhepeng
Aug 31 2017 07:36
Profile Lookup How do you do this problem?
Markus Kiili
@Masd925
Aug 31 2017 07:41
@caozhepeng Loop or iterate the array contacts and then check the looped contact as asked.
Mai Thinh
@mthinh
Aug 31 2017 07:51
var squares=  Array.from($('.square'));

  squares.forEach(function(square){
    square.click(function(){
      console.log('Hello');
    })
Hello guys, I tend to add click event to each element in node list, but its not working , pls help
Markus Kiili
@Masd925
Aug 31 2017 07:52
@mthinh You can just do $('.square').click(...); I think.
Mai Thinh
@mthinh
Aug 31 2017 07:56
 $('.square').click(function(){
      $('.square').text('x');
    })
@Masd925 when i click to one of those squares, the other squares will change its text to X too, that not what i want
István Kozma
@Manfred28
Aug 31 2017 08:09
@mthinh use $(this)
might need the ''
Mai Thinh
@mthinh
Aug 31 2017 08:10
@Manfred28 thank you, it works, but is there other way to add Event to nodelist ?
CamperBot
@camperbot
Aug 31 2017 08:10
mthinh sends brownie points to @manfred28 :sparkles: :thumbsup: :sparkles:
:cookie: 172 | @manfred28 |http://www.freecodecamp.com/manfred28
István Kozma
@Manfred28
Aug 31 2017 08:11
what do you mean?
as far as I know in jquery you can only add a click event with $(element).click(callback)
there are other types of events, and you can do practically the same (with different syntax) with vanilla js
Mai Thinh
@mthinh
Aug 31 2017 08:13
ok
István Kozma
@Manfred28
Aug 31 2017 08:14
or well
yeah dunno
but I would suggest you don't overuse jquery and do a few projects with vanilla js
Mai Thinh
@mthinh
Aug 31 2017 08:16
I only use DOM with jquery,
vanilla js for logic part
秦荣泽
@qinrongze
Aug 31 2017 08:39
Golf Code Source code??
Emmanuel Akodia
@akodiaemma
Aug 31 2017 09:02
some one helpme log on to this account http://botondraduly.eu/
sorry website
and explain to me how the video is stored or where exactly its stored
i need help understnadning this
Markus Kiili
@Masd925
Aug 31 2017 09:15
@mthinh You can use event.target inside the click callback to target the element that triggered the event.
@mthinh That way creates an event listener for each element. Another way is to use event delegation and bind the event to the parent element and delegate it to the element that was clicked.
$(selector).on(event, delegateSelector, callback);
korzo
@korzo
Aug 31 2017 09:19
@akodiaemma search for id="homevideo"
Emmanuel Akodia
@akodiaemma
Aug 31 2017 09:21
I have seen it thank you buddy
Emmanuel Akodia
@akodiaemma
Aug 31 2017 09:59
i need help adding the lightgallery.js to my website
i have a repository, can anyone help me out
Johnny
@JohnnyBizzel
Aug 31 2017 10:19
@akodiaemma What did you try so far???
Emmanuel Akodia
@akodiaemma
Aug 31 2017 10:59
its a little hard to explain..but you can check out my index.html on this repo https://github.com/akodiaemma/Expo-2017
help me out if possible, i have imported the lightgallery.css and the .js as well
but i wanted the images boxes to appear
sabahatullah
@sabahatullah
Aug 31 2017 12:03
could anyone tell me if its the right syntax
if(window.sxux.uliso != "IS" && "NO" && "SE" && "FI") {
//do something
}
heroiczero
@heroiczero
Aug 31 2017 12:03
@sabahatullah hmm no
sabahatullah
@sabahatullah
Aug 31 2017 12:04
or should it be
if(window.sxux.uliso != "IS" && window.sxux.uliso != "NO" && window.sxux.uliso != "SE" && window.sxux.uliso != "FI") {
//do something
}
heroiczero
@heroiczero
Aug 31 2017 12:04
@sabahatullah yeah that looks right
Ogundele Olumide
@Lumexralph
Aug 31 2017 12:08
@sabahatullah seems like it
sabahatullah
@sabahatullah
Aug 31 2017 12:29
@heroiczero @Lumexralph so second one is right? both seem to work in chrome console though
heroiczero
@heroiczero
Aug 31 2017 12:30
@sabahatullah "NO" && "SE" && "FI" these are not comparison
sabahatullah
@sabahatullah
Aug 31 2017 12:58
thanks guys
Stephen James
@sjames1958gm
Aug 31 2017 13:02
@sabahatullah You could make it simpler by putting those in an array.
var arr = ["IS", "NO", "SE", "FI"];
if (arr.indexOf(window.sxux.uliso) == -1) {
}
Then if you needed to add an additional value, just update the array not the if statement
baoliehua
@baoliehua
Aug 31 2017 13:05
str=str.filter(function(value){
var k=0;
for(var j=0;j<value.length;j++){
if(value[j]==value[j+1]){
k=1;
}
}
return !k;
});
去除字符串中有重复的
比如“aa”的,但是有错误
Stephen James
@sjames1958gm
Aug 31 2017 13:10
@baoliehua this value[j+1] will go past end of array when j is value.length - 1
EpicTriffid
@EpicTriffid
Aug 31 2017 14:09

So Im having a bit of trouble with Sorted Union. This works no problem:

function uniteUnique(arr) {
  var finalArr = [];
  var conArr = [];
  for (var i = 0; i < arr.length; i++) {
    conArr.push(arguments[i].concat());    
  }
  var otherArr = conArr.reduce(function(a,b) {
      return a.concat(b);
  });
  otherArr.forEach(function(el) {
    if (finalArr.indexOf(el) === -1) {
      finalArr.push(el);        
      }
    });
  return finalArr;


}

uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]);

But when the arguments is changed to ([1, 2, 3], [5, 2, 1]) I get "cannot read property 'concat' of undefined"

Any ideas

Stephen James
@sjames1958gm
Aug 31 2017 14:12
@EpicTriffid arr.length is longer than arguments.length
arguments[i].concat() this doesn't actually do anything
EpicTriffid
@EpicTriffid
Aug 31 2017 14:14
@sjames1958gm Would you be able to explain a little more?
Stephen James
@sjames1958gm
Aug 31 2017 14:15
@EpicTriffid You loop is using arr.length which is wrong you should be using arguments.length
EpicTriffid
@EpicTriffid
Aug 31 2017 14:16
@sjames1958gm Right, so I just swapped it round and it works perfectly. So why does arguments work and not arr?
Stephen James
@sjames1958gm
Aug 31 2017 14:17
@EpicTriffid You are looping over arguments so you should use arguments length which in this case is two
not the array length which is three.
arr only refers to [1, 2, 3] while arguments is ([1, 2, 3], [5, 2, 1])
EpicTriffid
@EpicTriffid
Aug 31 2017 14:18
@sjames1958gm So a for loop only loops over the first argument in the array?
Stephen James
@sjames1958gm
Aug 31 2017 14:19
@EpicTriffid You wanted the loop to cover the indexes of arguments,
conArr.push(arguments[i].concat());
Then you need to use the length of arguments (not the length of arr) as the end of the loop
heroiczero
@heroiczero
Aug 31 2017 14:19
@EpicTriffid yeah because its not in an array
@EpicTriffid it is an argument ([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8])
Razvan Jackson
@RazvanJackson
Aug 31 2017 14:21
Someone who knows node?
EpicTriffid
@EpicTriffid
Aug 31 2017 14:23
@heroiczero @sjames1958gm Thankyou guys. I was going through this thinking to myself that i was going to have to push the arrays into a larger array so i could run a for loop on them, and now I know why!
CamperBot
@camperbot
Aug 31 2017 14:23
epictriffid sends brownie points to @heroiczero and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1677 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 8416 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 31 2017 14:24
@RazvanJackson What is your question/
Razvan Jackson
@RazvanJackson
Aug 31 2017 14:24
Just want to know where to learn node.
EpicTriffid
@EpicTriffid
Aug 31 2017 14:28
@sjames1958gm Also, I now want to condense my code, but it won't let me add the reduce function onto the end of the concat function?
Stephen James
@sjames1958gm
Aug 31 2017 14:34
@RazvanJackson udemy has some good courses
@EpicTriffid You could do Array.from(arguments).reduce(. . .)
EpicTriffid
@EpicTriffid
Aug 31 2017 14:35
@sjames1958gm Im trying
for (var i = 0; i < arguments.length; i++) { conArr.push(arguments[i].reduce(function(a,b) { return a.concat(b); })); }
but it's saying a.concat is not a function
@EpicTriffid because a and b in that case are numbers.
You want to reduce the array that you create from the arguments array
@RazvanJackson Currently only $10 US if that option is available (ends sometime today)
EpicTriffid
@EpicTriffid
Aug 31 2017 14:41
@sjames1958gm Why are they now numbers, but weren't before?
Stephen James
@sjames1958gm
Aug 31 2017 14:53
Before you called reduce on conArr which was an array of arrays,
Here you are calling it on arguments[i] which is a simple array
conArr was like [[1, 2, 3], [5, 2, 1]]
arguments[i] is like [1, 2, 3]
Blauelf
@Blauelf
Aug 31 2017 15:00

@sjames1958gm Funny enough, the course is €10 for me on desktop and €11 in the app. Both far more than $10.

Says 16 hours left.

Just switched to 15 hours.

Long Nguyen
@longnt80
Aug 31 2017 15:02
@Blauelf $10 US for me
Blauelf
@Blauelf
Aug 31 2017 15:03
@longnt80 Depends on where you live. And in-app purchases are probably higher because of the percentage going to AAPL/GOOG/MSFT
Alexander Køpke
@alexanderkopke
Aug 31 2017 15:03
is it a good course?
Stephen James
@sjames1958gm
Aug 31 2017 15:04
10 Euros is 11.50 US
@alexanderkopke Yes and the instructor keeps it updated with new content.
It starts out basic, but covers a large range
@alexanderkopke I took a full React course from the same instructor and was very pleased with the content.
Alexander Køpke
@alexanderkopke
Aug 31 2017 15:05
ah he updates the course. That is a boon
the one with meteor?
Stephen James
@sjames1958gm
Aug 31 2017 15:06
@alexanderkopke No, it was a different one, it appears to have gone away on udemy
Abhinav Mishra
@abhinav-m
Aug 31 2017 15:06
@sjames1958gm hello stephen
Stephen James
@sjames1958gm
Aug 31 2017 15:06
He added async/await recently
Abhinav Mishra
@abhinav-m
Aug 31 2017 15:06
that node.js course
Stephen James
@sjames1958gm
Aug 31 2017 15:06
@abhinav-thinktank :wave:
Abhinav Mishra
@abhinav-m
Aug 31 2017 15:06
im interested.
is that worth the purchase?
seems very highly rated
Alexander Køpke
@alexanderkopke
Aug 31 2017 15:08
weird that the normal price is 85 euro with 31.5 hours content for the meteor course considering there are courses for 200 euro on udemy for 5 hours content or so.
Imma sign up for his react meteor course. Doing another course atm but will do this one next. Thanks for the recommending him @sjames1958gm
CamperBot
@camperbot
Aug 31 2017 15:10
alexanderkopke sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8417 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Abhinav Mishra
@abhinav-m
Aug 31 2017 15:10
hmm i think ill take this node.js one
Stephen James
@sjames1958gm
Aug 31 2017 15:11
@alexanderkopke :+1:
Stephen Grider is another one I would recommend - I am in the middle of his GraphQL course. And just grabbed two React Native for $20 total
Abhinav Mishra
@abhinav-m
Aug 31 2017 15:11
@sjames1958gm you recommend this node one right?
Stephen James
@sjames1958gm
Aug 31 2017 15:11
Yes.
Abhinav Mishra
@abhinav-m
Aug 31 2017 15:11
im a beginner though, will it cover the basics ?
Stephen James
@sjames1958gm
Aug 31 2017 15:11
Yes. Assumes nothing other than basic js knowledge.
Abhinav Mishra
@abhinav-m
Aug 31 2017 15:12
@sjames1958gm allright thanks!
CamperBot
@camperbot
Aug 31 2017 15:12
abhinav-thinktank sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8418 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jason Luboff
@JLuboff
Aug 31 2017 15:12
@sjames1958gm I also used that course and learned a good deal :+1:
Abhinav Mishra
@abhinav-m
Aug 31 2017 15:12
This should be a good starter for node
Jason Luboff
@JLuboff
Aug 31 2017 15:13
@abhinav-thinktank It is good, the only thing I wished he covered more is integrating the front end with the backend but otherwise, he does a very good job of explaining things.
Abhinav Mishra
@abhinav-m
Aug 31 2017 15:13
@JLuboff ok! the projects sound pretty cool
@JLuboff ty, im gonna get it.
CamperBot
@camperbot
Aug 31 2017 15:14
abhinav-thinktank sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2181 | @jluboff |http://www.freecodecamp.com/jluboff
Stephen James
@sjames1958gm
Aug 31 2017 15:14
He also periodically publishes free mini courses and you get the announcement through udemy
Jason Luboff
@JLuboff
Aug 31 2017 15:14
:+1:
Stephen James
@sjames1958gm
Aug 31 2017 15:15
http://www.mead.io/blog.html
He has info on yarn, debugging node, npm
Jason Luboff
@JLuboff
Aug 31 2017 15:16
@sjames1958gm Just curious..the one thing I had trouble with in his node course is how much testing stuff he did. I found it boring to be honest lol. How much of integrating testing modules do you do in actual development?
Stephen James
@sjames1958gm
Aug 31 2017 15:17
I haven't done any large applications, so mostly end-to-end testing.
He does do a lot of that, and it can be a bit tedious, but it is something to have in the old brain box as a reference.
Jason Luboff
@JLuboff
Aug 31 2017 15:18
True
Blauelf
@Blauelf
Aug 31 2017 15:23
@JLuboff I know only about one project, Java, not JavaScript, and developers claim to have unit tests everywhere, but they have no real tests on the higher level, which means they deliver bananaware. But it's hard to automate tests for a moving target, and specifications are changing faster than documentation can keep up. There's no simple fix for that. Wish we had more automated tests. But again, moving target.
Stephen James
@sjames1958gm
Aug 31 2017 15:31
@Blauelf bananaware? new term for me
Blauelf
@Blauelf
Aug 31 2017 15:32
Ripens on the customer's shelf.
Stephen James
@sjames1958gm
Aug 31 2017 15:33
lol
turns black and attracts fruit flies?
We're in the wrong business Arsenal is rumored to be paying $118M for a Monaco footballer.
Blauelf
@Blauelf
Aug 31 2017 15:35
Maybe. With the current version, I have a really bad feeling. Something is weird. Weird as in session management, which everything depends on, and session management is about to be complicated further.
Jason Luboff
@JLuboff
Aug 31 2017 15:47
:banana:ware
Ghost
@ghost~55a04b725e0d51bd787af54c
Aug 31 2017 16:27
Hello everyone! I'm trying to make an app, and this is what I've come to so far: https://codepen.io/Refath/pen/wqRpmO. What I want to do is enable the user to edit the links of the websites in the 4 circles
The icons, I might be able to derive from the favicon of the website, but as a person who knows very little js, I don't know where to begin
Ogundele Olumide
@Lumexralph
Aug 31 2017 16:31
@JLuboff @sjames1958gm writing test is not fun for me but I know the importance
@sjames1958gm of all clubs Arsenal :joy:
Stephen James
@sjames1958gm
Aug 31 2017 16:34
@Lumexralph Yes
Ogundele Olumide
@Lumexralph
Aug 31 2017 16:35
@sjames1958gm i'm of the believe that if it's BDD you just can cover everything, what do you think?
@sjames1958gm which player is that?
Ghost
@ghost~55a04b725e0d51bd787af54c
Aug 31 2017 16:35
Anyone?
Blauelf
@Blauelf
Aug 31 2017 16:47
@Refath Dragged symbols sometimes appear at different position and in different rotation
Ah. Amazon is always left, fakebook always right. Interesting.
Editing links... I'd do some config page with a list of links, but that's probably not the most intuitive way.
Ghost
@ghost~55a04b725e0d51bd787af54c
Aug 31 2017 16:51
@Blauelf Let me try creating a options panel on the left
Blauelf
@Blauelf
Aug 31 2017 16:52
I've used custom startpages around 2000, and those used config pages. Not so much client-side scripting back then :P
Stephen James
@sjames1958gm
Aug 31 2017 16:54
@Lumexralph Lemar
Gustavo Azevedo
@gustavoaz7
Aug 31 2017 17:03
Hey guys. One question using fetch (promise):
I'm getting one info from a first fetch (and assigning it to a variable), which I need to create the link for a second fetch.
Do I really need to nest one fetch inside the other?
(when I don't, the variable is still 'undefined' when sending the request for the second fetch)
Christopher McCormack
@cmccormack
Aug 31 2017 17:05
@gustavoaz7 that, or use promises
promises function similar to nesting but are easier to read
fetch returns a promise I believe
Gustavo Azevedo
@gustavoaz7
Aug 31 2017 17:07
Yes, it does
So it's basically the same thing, just written differently
Christopher McCormack
@cmccormack
Aug 31 2017 17:12
the only time you don't necessarily need to nest is if you're using the data with something like a click event, which may happen much later than the ajax response. In that case you can check for data first and if it's there, use it, if not, do nothing
Stephen James
@sjames1958gm
Aug 31 2017 17:14
@gustavoaz7 The variables passed into a .then for a promise or are defined in a .then callback are not available in later .then callbacks.
But if you are in a .then callback you can use them to create another fetch call.
fetch(URL)
.then(function(response) {
  return response.json();
}).then(function(json) {
    // you could use json to create a new fetch but not response.
   return fetch(newUrlFromJson);
})
.then(function(response2) {
   // response from second fetch
})
.then(function(json2) {
});
Jason Luboff
@JLuboff
Aug 31 2017 17:17
@cmccormack Done with the Agile training?
Gustavo Azevedo
@gustavoaz7
Aug 31 2017 17:17
@cmccormack makes sense. Thank you!
@sjames1958gm That's what I'm about to do right now. Thx
CamperBot
@camperbot
Aug 31 2017 17:17
:star2: 1175 | @cmccormack |http://www.freecodecamp.com/cmccormack
Stephen James
@sjames1958gm
Aug 31 2017 17:17
@gustavoaz7 :+1:
CamperBot
@camperbot
Aug 31 2017 17:17
gustavoaz7 sends brownie points to @cmccormack and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8419 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Christopher McCormack
@cmccormack
Aug 31 2017 17:18
@JLuboff :wave: yes! finally
Long class but pretty interesting
Jason Luboff
@JLuboff
Aug 31 2017 17:19
Nice
Ghost
@ghost~55a04b725e0d51bd787af54c
Aug 31 2017 17:27
Why isn't Google being edited when I click it? https://codepen.io/Refath/pen/XaoMEj?editors=1100
Christopher McCormack
@cmccormack
Aug 31 2017 17:31
@Refath you didn't import jQuery
Ghost
@ghost~55a04b725e0d51bd787af54c
Aug 31 2017 17:32
Oh I see
koder3
@koder3
Aug 31 2017 17:50
@koder3
do i learn Angular 1 or Angular 4
the codepen example for the wikipedia viewer uses Angular 1
but i see people saying use Angular 4
ive already started learning Angular 1
Eric Hasegawa
@EricHasegawa
Aug 31 2017 18:01
@EricHasegawa
https://codepen.io/erichasegawa/pen/brdYKd
Can anyone tell me why the bottom edge of this cuts out on mobile?
Ayush Bahuguna
@relentless-coder
Aug 31 2017 18:04
@EricHasegawa it doesn't
at least on my browser
Eric Hasegawa
@EricHasegawa
Aug 31 2017 18:04
@relentless-coder On your phone?
Ayush Bahuguna
@relentless-coder
Aug 31 2017 18:05
no I tested it on my browser, resized the browser
Eric Hasegawa
@EricHasegawa
Aug 31 2017 18:05
@relentless-coder Oh I see, when I open it up on my phone most of the actual content doesn't fit on the page for some reason, do you have any idea why that would be?
Ayush Bahuguna
@relentless-coder
Aug 31 2017 18:06
let me check
@EricHasegawa could it be the issue that that the api sometimes doesn't work? and you think that it's getting cut off, because that's what happening when I am viewing it in my browser
Eric Hasegawa
@EricHasegawa
Aug 31 2017 18:10
@relentless-coder Yeah it's weird I'm not really sure, I guess I'll just leave it
koder3
@koder3
Aug 31 2017 18:13
@koder3
do i learn Angular 1 or Angular 4
the codepen example for the wikipedia viewer uses Angular 1
but i see people saying use Angular 4
Ayush Bahuguna
@relentless-coder
Aug 31 2017 18:14
@koder3 depends upon what you are looking for. a job that pays better or just the curiosity
koder3
@koder3
Aug 31 2017 18:15
and?
Ayush Bahuguna
@relentless-coder
Aug 31 2017 18:17
learn react if you want a better paying job, else use whatever framework,
koder3
@koder3
Aug 31 2017 18:19
alright
is angular similar to react?
@relentless-coder thanks
CamperBot
@camperbot
Aug 31 2017 18:21
koder3 sends brownie points to @relentless-coder :sparkles: :thumbsup: :sparkles:
:cookie: 377 | @relentless-coder |http://www.freecodecamp.com/relentless-coder
Ayush Bahuguna
@relentless-coder
Aug 31 2017 18:23
@koder3 no. angular's philosophy is more of including javscript into html, while react requires you to write vanilla javascript and plug in your templates.
it's easy to start on Angular, difficult to start on React
I would say, try each framework for a week each.
koder3
@koder3
Aug 31 2017 18:28
alright thanks a lot
@relentless-coder
alpox
@alpox
Aug 31 2017 18:30
@relentless-coder @koder3 angular is not really about including javascript into html. Its more that it defines its own template language
Ayush Bahuguna
@relentless-coder
Aug 31 2017 18:32
@alpox yes, sorry for not framing it in better words. thanks for that
CamperBot
@camperbot
Aug 31 2017 18:32
relentless-coder sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1320 | @alpox |http://www.freecodecamp.com/alpox
koder3
@koder3
Aug 31 2017 18:37
@alpox thanks
CamperBot
@camperbot
Aug 31 2017 18:37
koder3 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1321 | @alpox |http://www.freecodecamp.com/alpox
aRtoo
@artoodeeto
Aug 31 2017 19:10
guys why is it the return wont give me the sum. just the word function
heres the code: this is just a testing.
    test(1,1);
  function test(a,b) {
    return a+b;
  }

  return test;
Christopher McCormack
@cmccormack
Aug 31 2017 19:11
@artoodeeto return test returns the reference to the function test
@artoodeeto try return test(1,1) instead. Your first line will invoke the test function correctly but doesn't do anything with the return value.
>   function test(a,b) {
...     return a+b;
...   }
>
> var a = test;
> a(1,1)
2
Joseph
@revisualize
Aug 31 2017 19:14
:|
They asked in the main chat too.
Christopher McCormack
@cmccormack
Aug 31 2017 19:14
oh well :) :wave: @revisualize
Joseph
@revisualize
Aug 31 2017 19:15
:wave:
I need to go to lunch.
Christopher McCormack
@cmccormack
Aug 31 2017 19:15
me too, let's go
aRtoo
@artoodeeto
Aug 31 2017 19:35

yow brothers from another mother. the algorithm entitled arguments optional. theres a invoke function like this. addTogether(2)(3);//should return 5.
but when i run my code.


function addTogether() {

  var sum = 0;


  if(typeof arguments[0] === 'number' && typeof arguments[1] === 'number') { 
      if(arguments.length > 1) {
          for(var i=0; i<arguments.length; i++){
            sum += arguments[i];
      }
    }else {
      var x = arguments[0];
      return function(y) {
        sum += x + y;
      };
    }
  } else {
    return undefined;
  }


  return sum;
}

it says addTogether is not a function() error is this a bug?

Mark
@vinarius
Aug 31 2017 19:49
Your code works for me
try refreshing the page if it's for a freecodecamp submission, just copy the code onto notepad first
alpox
@alpox
Aug 31 2017 19:54
@vinarius I think something is wrongly cached at your place ;-)
@artoodeeto addTogether(2) returns undefined and can therefore not be called anymore with (3). This is because your first if condition doesn't hold in this case
Mark
@vinarius
Aug 31 2017 19:56
you've got two else statements as well
alpox
@alpox
Aug 31 2017 19:56
@artoodeeto Also, sum += x + y in the returned function cannot work, because the sum variable was already returned before by addTogether. Adding something to it can therefore not help anymore.
@vinarius One is for the inner if, the other for the outer if. Syntactically thats correct... But i guess the logic not
Mark
@vinarius
Aug 31 2017 19:57
what's the fist bump emote for this chat
koder3
@koder3
Aug 31 2017 19:58
:facepunch:
i dont think thats what you are looking for though haha
alpox
@alpox
Aug 31 2017 19:58
Looks like getting a fist in my head :D
koder3
@koder3
Aug 31 2017 19:58
lmao
Mark
@vinarius
Aug 31 2017 19:59
lol
it was meant to be more of a high five than a punch to the face haha
koder3
@koder3
Aug 31 2017 20:00
:hand:
im not sure you wanna use that either lmao
alpox
@alpox
Aug 31 2017 20:00
@vinarius Thats also a high five. High five in the face... :-)
Mark
@vinarius
Aug 31 2017 20:01
hahaha
koder3
@koder3
Aug 31 2017 20:01
xD
firas omrane
@firou1925
Aug 31 2017 20:10
hello world
koder3
@koder3
Aug 31 2017 20:13
can anyone tell me if the react tutorial on freeCodeCamp beta is any good?
Brian
@BrianCodes33
Aug 31 2017 20:13
function countMe(data){
  let result = '';
  let conversion = Array.from(data);
  for (var i=0; i<conversion.length; i++) {
    if (isNaN(conversion[i])) {
      return '';
    } else if (conversion[i] != conversion[i+1]) {
      result += conversion[i] + conversion[i].length;
    } else {
      result += conversion[i].repeat()
    }
  }
  return result;
} 

Given a string of integers, count how many times that integer repeats itself, then return a string showing the count and the integer.

Test.assertEquals(countMe('1123'), '211213');
Chris Juchtmans
@kjuchtmans
Aug 31 2017 20:13
Evening coders! :wave:
Brian
@BrianCodes33
Aug 31 2017 20:13
any help?
Christopher McCormack
@cmccormack
Aug 31 2017 20:14
@firou1925 @kjuchtmans hello
Chris Juchtmans
@kjuchtmans
Aug 31 2017 20:15

Has anyone ever done the InfoSec part of FCC? It seems to reside on these beta pages now...

Is this certificate still obtainable? Is this up to date?

thanks, k

Christopher McCormack
@cmccormack
Aug 31 2017 20:18
@BrianCodes33 what do you expect this to do? result += conversion[i].repeat()
Brian
@BrianCodes33
Aug 31 2017 20:19
@cmccormack that’s the block i’m having trouble with
Christopher McCormack
@cmccormack
Aug 31 2017 20:19
@kjuchtmans no clue sorry
@BrianCodes33 also what do you expect this to do? result += conversion[i] + conversion[i].length; :D both are fairly confusing - maybe write out some pseudocode that you can then fill in with code
@BrianCodes33 perhaps use a while loop for this one - you can update your index internally but have it loop through and increment a counter for each unique item unti it hits a new one, appends the previous count + integer, then move on to the next
Brian
@BrianCodes33
Aug 31 2017 20:23
// if num is not repeated
  //   conversion[i] + 1
// else if num is repeated
  //   length of how many times that num is repeated + conversion[i]
is that poor pseudo code?
Christopher McCormack
@cmccormack
Aug 31 2017 20:24
you don't really want to use variables like that in pseudocode
and what are you comparing it against? what determines if num is repeated?
firas omrane
@firou1925
Aug 31 2017 20:31
@cmccormack can you sacrifice a little bit of time for me?
Christopher McCormack
@cmccormack
Aug 31 2017 20:34
I'm at work right now but I can do my best, and I'm sure there are others on that can help as well right now
Jason Luboff
@JLuboff
Aug 31 2017 20:35
@cmccormack Psh... at work? You're at home ;)
Christopher McCormack
@cmccormack
Aug 31 2017 20:36
right :) hey at home I work more than at the office, too much talking at the office
Jason Luboff
@JLuboff
Aug 31 2017 20:37
Man..if I worked from home I'd get to hang with my dog all day. He would be stoked for the first few days then not want to deal with me haha
Christopher McCormack
@cmccormack
Aug 31 2017 20:37
I actually have to lock my doggies out or they would be crawling all over me all day
Jason Luboff
@JLuboff
Aug 31 2017 20:38
You lock them out?! How cruel!
Christopher McCormack
@cmccormack
Aug 31 2017 20:39
it's like 72F out here it's not cruel :D
but no, just out of my office
Jason Luboff
@JLuboff
Aug 31 2017 20:40
Ugh.. it's 83F here today. I'm surprised its hotter here
Christopher McCormack
@cmccormack
Aug 31 2017 20:41
oops I lied, 79, but it's Flagstaff, like 7,000ft elevation
Jason Luboff
@JLuboff
Aug 31 2017 20:43
Looky here guys, we got a geographer!
Christopher McCormack
@cmccormack
Aug 31 2017 20:44
haha
@firou1925 did you have questions?
firas omrane
@firou1925
Aug 31 2017 20:45
@cmccormack I am asking in other room thanku
CamperBot
@camperbot
Aug 31 2017 20:45
firou1925 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1177 | @cmccormack |http://www.freecodecamp.com/cmccormack
Guderian Raborg
@hypercuber
Aug 31 2017 20:52
How do I make the PointLight always be with the camera?
firas omrane
@firou1925
Aug 31 2017 20:54

@cmccormack I have some problems trying to get the code executing in the order I want (synchronic) so I used setTimeout because it ewecutes in the end and here the code the first one using setTimeout https://codepen.io/firou1925/full/WELmQO/

and the second without nothing https://codepen.io/firou1925/full/NveQyJ/

Christopher McCormack
@cmccormack
Aug 31 2017 20:55
@firou1925 can you describe what isn't working correctly first?
glitz20
@glitz20
Aug 31 2017 20:57
hey guys can anyone have a look and let me know why my text in the body part is not displayed? https://glitch.com/edit/#!/witty-rooster?path=public/style.css:1:0
_
firas omrane
@firou1925
Aug 31 2017 20:57
what I want is to have the last case full before alerting that someone won or it's a draw so I used setTimeout in the first one so that the code will be executed in the end in the function in the line 151 in the first code
@cmccormack so I want ti know is setTimeout the best solution to get my code executing synchrinistically
got my question?
Christopher McCormack
@cmccormack
Aug 31 2017 21:00
@sabin20 which text? I see a guestbook and text
glitz20
@glitz20
Aug 31 2017 21:01
@cmccormack when you go to write in the guestbook and fill the form and press enter, you will only see the title part
Christopher McCormack
@cmccormack
Aug 31 2017 21:01
@firou1925 the purpose of setTimeout is delay invoking a callback function until a set amount of time is lapsed. If that's what you want, that's perfect.
@sabin20 ah ok

@firou1925 I'm not 100% certain what you're trying to run synchronously - can you describe it like:

player clicks > algorithm determines player wins > wait 2 seconds > display alert

something like that?

firas omrane
@firou1925
Aug 31 2017 21:03
@cmccormack no the purpose I used for is to get my code executed in the order so I used setTimeout with 0 seconds not to delay invokink a function so I am asking if there is another solution
player click==> algorithm fill the case ==> alert who wins
Christopher McCormack
@cmccormack
Aug 31 2017 21:05
@firou1925 why are you even using setTimeout if you don't want there to be a timer?
if you want something to run synchronously, don't use asynchronous functions like setTimeout
firas omrane
@firou1925
Aug 31 2017 21:06
https://codepen.io/firou1925/pen/NveQyJ?editors=1010
in this it alerts before filling the blank @cmccormack
and this before using setTimeout
var theCase = document.getElementById(event.target.id);
theCase.className+=" token";
console.log(theCase);
theCase.innerText=components.presentMode;
components.displayArray[Number(event.target.id[1])-1][Number(event.target.id[3])-1]=components.presentMode;
components.casesOcuupied++;
console.log(components.displayArray);
console.log("case occupied" +components.casesOcuupied);
operations.togglePresentMode();
operations.testWin();
if(components.gameOver){
operations.theGameIsOver();
line 151
when someone wins it executes operations.testWin(); before theCase.innerText=components.presentMode;
glitz20
@glitz20
Aug 31 2017 21:15
@cmccormack did you find any error?
fdemaa
@fdemaa
Aug 31 2017 21:16
How i use a variable on a function on my api request ?
Christopher McCormack
@cmccormack
Aug 31 2017 21:16
@firou1925 I believe updating the DOM is also asynchronous. Possibly not updating the value, but drawing the screen may be. setTimeout may be your best option in this case without using something like promises perhaps. Maybe someone else will have a better answer
@fdemaa example?
fdemaa
@fdemaa
Aug 31 2017 21:18
I have a function that will get the search word on an input area, and i want then to use that variable that holds that search word on my request api, so i can make the wikipedia search with that word
firas omrane
@firou1925
Aug 31 2017 21:18
@cmccormack so I have to learn about promises because I don't know about them
thank u body
CamperBot
@camperbot
Aug 31 2017 21:18
firou1925 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: firou1925 already gave cmccormack points
firas omrane
@firou1925
Aug 31 2017 21:18
thank u
Christopher McCormack
@cmccormack
Aug 31 2017 21:18
@sabin20 should it be entries.content?
@firou1925 or just use setTimeout. I would personally recommend just not using alerts, I find them annoying
fdemaa
@fdemaa
Aug 31 2017 21:19
 Html:
<input id="myText" type="text" placeholder="Search.."> <button onclick="myFunction()">Try it</button>

Js:
function myFunction() {
    var searchWord = document.getElementById("myText").value;
    console.log(searchWord);
}


var XMLHttp = new XMLHttpRequest();

XMLHttp.open("GET","https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&origin=*&format=json&list=search&srsearch="+searchWord,true);
XMLHttp.setRequestHeader("Api-User-Agent","Example/1.0");
XMLHttp.send();
@cmccormack
Christopher McCormack
@cmccormack
Aug 31 2017 21:20
@fdemaa try moving your ajax call to it's own function or within your myFunction
firas omrane
@firou1925
Aug 31 2017 21:21
@fdemaa and what is the problem?
glitz20
@glitz20
Aug 31 2017 21:23
@cmccormack I donot think so content is labelled just for the title
Christopher McCormack
@cmccormack
Aug 31 2017 21:23
@fdemaa you're calling the ajax function immediately when your JS file loads, before you've given a value to searchWord. searchWord is also only local in scope to myFunction as well
@sabin20 your property is labeled content though.
  entries.push({
    title:request.body.title,
    content:request.body.body,
    published: new Date()
  });
glitz20
@glitz20
Aug 31 2017 21:25
cool @cmccormack thanks
CamperBot
@camperbot
Aug 31 2017 21:25
sabin20 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1178 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Aug 31 2017 21:26
np
Dominik Soczewka
@Villentrenmerth
Aug 31 2017 21:28
Can someone tell me why return _.merge( ...state, _.mapKeys(action.payload.data, "id")); returns with only target data? Source and target both are not empty, but somehow that function results with only the new data
fdemaa
@fdemaa
Aug 31 2017 21:30
@cmccormack thanks chris
CamperBot
@camperbot
Aug 31 2017 21:30
fdemaa sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1179 | @cmccormack |http://www.freecodecamp.com/cmccormack
Ala Pota
@alapota
Aug 31 2017 21:49
Thank you @Takumar you were right
CamperBot
@camperbot
Aug 31 2017 21:49
alapota sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star2: 3782 | @takumar |http://www.freecodecamp.com/takumar
dyon3334
@dyon3334
Aug 31 2017 21:53
does anyone know what number.EPSILON; does ? with more explanation as on mdn because its very short and unclear to me
Caleb Brenner
@cwborion
Aug 31 2017 21:53

So I’m supposed to write something that prompts the user for 3 different numbers and then adds the numbers to a sum and prints on the page “ The sum of all your numbers is _.” And I’ve succeeded in that except that when I run it, it prints the message 3 times. Here is my code if anyone can help.

var myArr = [num1, num2, num3];

var num1 = +prompt ("Give a number.");

var num2 = +prompt ("Give another number.");

var num3 = +prompt ("Give a number again.");

var total = 0;

var total = num1 + num2 + num3;

for (var i = 0; i < myArr.length; i++){

document.write("The sum of all your numbers is " + total + ".");

}

not sure why only the last line looks correct
Jason Luboff
@JLuboff
Aug 31 2017 21:56
@cwborion It's becuase you're writing it inside your loop. I don't even know why you have a loop or the array...or why you're declaring var total twice..?
Pieter Stokkink
@forkerino
Aug 31 2017 21:57
@Villentrenmerth how does state look?
also, it seems as _.mapKeys() requires a function as second arg (but I have little exp. with lodash)
@JLuboff :wave:
Jason Luboff
@JLuboff
Aug 31 2017 21:57
@forkerino Hello!
Caleb Brenner
@cwborion
Aug 31 2017 21:57
@JLuboff declaring total twice is a mistake. The assignment is to use a for loop to add the three numbers and then put the sum in the string that is printed
Jason Luboff
@JLuboff
Aug 31 2017 21:59
@cwborion Ok. Well, how you currently have the array setup isn't going to work unless you move it after your num1-3 declarations. At which point you can then use a loop to add them and then after the loop, do you document.write
@forkerino How goes it?
Pieter Stokkink
@forkerino
Aug 31 2017 22:00
@dyon3334 Number.EPSILON gives the smallest number (it's a constant). Because not all numbers can be represented as floating points (type 0.1 + 0.2 in the console and you'll see), you can use this to test for almost equality.
Christopher McCormack
@cmccormack
Aug 31 2017 22:01
@forkerino :wave:
Pieter Stokkink
@forkerino
Aug 31 2017 22:01
@JLuboff good! Finally getting used to working 4 days a week. I haven't worked 4 days a week in almost a decade /slacker
@cmccormack Yo!
Caleb Brenner
@cwborion
Aug 31 2017 22:02
@JLuboff ah yes, that worked. Thank you for explaining. I’m still confused as to how the placement of all of these different variables plays into everything. Lots to take in.
CamperBot
@camperbot
Aug 31 2017 22:02
cwborion sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2182 | @jluboff |http://www.freecodecamp.com/jluboff
Jason Luboff
@JLuboff
Aug 31 2017 22:02
@forkerino Thats good. I haven't not worked 5 days a week for over 7 years haha
Christopher McCormack
@cmccormack
Aug 31 2017 22:02
@JLuboff more or less?
Pieter Stokkink
@forkerino
Aug 31 2017 22:02
Yeah, you Americans sure like working a lot.
:P
Christopher McCormack
@cmccormack
Aug 31 2017 22:02
we don't like it, but we don't have great guards against it
Jason Luboff
@JLuboff
Aug 31 2017 22:03
@cwborion Order of operations matter. With your initial code, the array doesn't know what num1-3 are
dyon3334
@dyon3334
Aug 31 2017 22:03
@forkerino are you dutch ?
Jason Luboff
@JLuboff
Aug 31 2017 22:03
@cmccormack more or less?
Pieter Stokkink
@forkerino
Aug 31 2017 22:03
@dyon3334 yes
Christopher McCormack
@cmccormack
Aug 31 2017 22:03
@JLuboff more or less days a week :)
dyon3334
@dyon3334
Aug 31 2017 22:03
@forkerino kunnen we misschien een private chat voeren ?
Pieter Stokkink
@forkerino
Aug 31 2017 22:04
@dyon3334 ok
Jason Luboff
@JLuboff
Aug 31 2017 22:04
Suuureeee
Caleb Brenner
@cwborion
Aug 31 2017 22:04
@JLuboff the ptoblem is, that when I have it written in that order, I can take the for loop out all together and it doesn’t make a difference
Jason Luboff
@JLuboff
Aug 31 2017 22:04
@cwborion Correct. I'm not sure why you're required to use a for loop :)
Caleb Brenner
@cwborion
Aug 31 2017 22:05
@JLuboff confusing. perhpas there is a way to do so with a for loop?
Jason Luboff
@JLuboff
Aug 31 2017 22:05
Yes you can do it with a loop, but its not necessary
Caleb Brenner
@cwborion
Aug 31 2017 22:06
ah, well that’s what my assignment is haha, so I’ll have to figure out how to do it that way
Jason Luboff
@JLuboff
Aug 31 2017 22:06
var num1 = +prompt ("Give a number.");
var num2 = +prompt ("Give another number.");
var num3 = +prompt ("Give a number again.");
var myArr = [num1, num2, num3];
var total = 0;
for(var i = 0; i < myArr.length; i++){
total += myArr[i];
}
document.write....
Caleb Brenner
@cwborion
Aug 31 2017 22:08
@JLuboff written that way it some how adds them and then multiplies them or something, unless it’s the way I have my document.write like set up
Jason Luboff
@JLuboff
Aug 31 2017 22:10
@cwborion Show the code. For me, I just used console.log instead of document.write and used 5, 3, 2 and saw 10
Caleb Brenner
@cwborion
Aug 31 2017 22:11

var num1 = +prompt ("Give a number.");

var num2 = +prompt ("Give another number.");

var num3 = +prompt ("Give a number again.");

var myArr = [num1, num2, num3];

var total = num1 + num2 + num3;

for (var i = 0; i < myArr.length; i++){
total += myArr.length;
}

document.write("The sum of all your numbers is " + total + ".”);

Caleb Brenner
@cwborion
Aug 31 2017 22:17
@JLuboff got it, thank you!
CamperBot
@camperbot
Aug 31 2017 22:17
cwborion sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:warning: cwborion already gave jluboff points
Matej Bošnjak
@mbosnjak01
Aug 31 2017 22:20
@mbosnjak01
Hi
Anyone got an idea on how to skip an object property if it is an array and go to next in javascript?
Caleb Brenner
@cwborion
Aug 31 2017 22:22
@JLuboff one question though, with the following code, if i replace “document.write” with “console.log” it doesn’t show when I open the HTML file I have it linked to in my browser. Do you know why that is?
Randell Dawson
@RandellDawson
Aug 31 2017 22:23
@mbosnjak01 - can you paste the code for the object contents?
I assume you are iterating through the object in some way?
Jason Luboff
@JLuboff
Aug 31 2017 22:23
@cwborion console.log only shows in your browers console, it is only meant for logging (testing). It will not print anythign to screen
Caleb Brenner
@cwborion
Aug 31 2017 22:24
okay cool, i figured that may bewhy. thank you
Jason Luboff
@JLuboff
Aug 31 2017 22:24
:+1:
Randell Dawson
@RandellDawson
Aug 31 2017 22:30
@mbosnjak01 - Here is an example:
var myObj = {
  prop1: "hello",
  prop2: [1,2,3],
  prop3: 5
}
for (var prop in myObj) {
  if (!Array.isArray(myObj[prop])) {
    console.log(prop + ' is not an array') // only displays the property name when the value is not an array
  }
}
Pagnito
@Pagnito
Aug 31 2017 22:49
he i gotta question fo someone who knows how to build a full stack app
Jason Luboff
@JLuboff
Aug 31 2017 22:51
Always best to just ask and if someone can help they will
Ghost
@ghost~55a04b725e0d51bd787af54c
Aug 31 2017 22:59
How do I get the favicon of a website just from the website link?
korzo
@korzo
Aug 31 2017 23:01
@Refath it's usually located at domain.com/favicon.ico, for example https://www.amazon.com/favicon.ico
John
@AnonymousLords
Aug 31 2017 23:03
@Refath cool, that looks nice man
Ghost
@ghost~55a04b725e0d51bd787af54c
Aug 31 2017 23:13
@AnonymousLords Thanks @korzo I'll figure that out with vectors, or something, but right now, the js isn't wokring
CamperBot
@camperbot
Aug 31 2017 23:13
refath sends brownie points to @anonymouslords and @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 438 | @korzo |http://www.freecodecamp.com/korzo
:cookie: 320 | @anonymouslords |http://www.freecodecamp.com/anonymouslords
alpox
@alpox
Aug 31 2017 23:26
@rmdawson71 just put continue; into your if statement
That jumps directly to the next iteration
aRtoo
@artoodeeto
Aug 31 2017 23:33
damn!! im so freakin mad right now. after 3days of studying closures i got nothing so i gave up. on the algorithm challenge i answer it on my own. no closures but in a inefficient way. it is all nested if statements can you DM me ur answer fam please. want to study it. heres my ass code and i really tried my best fam:

function addTogether() {

  var sum = 0;

  console.log(arguments.length);
  console.log(typeof arguments[0]);

  if(arguments.length > 1) {
  if(typeof arguments[0] === 'number' && typeof arguments[1] === 'number') { 
          for(var i=0; i<arguments.length; i++){
            sum += arguments[i];
      }
    }else {
      return undefined;
    }



  } else if(arguments.length === 1) {
    if(typeof arguments[0] === 'number') {

      var n = arguments[0];

        return function(y) {
          if(typeof y === 'number') {
            return sum += n + y;
          } else {
            return undefined;
          }
      };


    } else {
      return undefined;
    }

  }

  return sum;
}
//addTogether(2);
//addTogether(2,3);//should return 5.
//addTogether(2)(3);//should return 5. //this is my error
//addTogether("http://bit.ly/IqT6zt");//should return undefined.
//addTogether(2, "3");//should return undefined.
addTogether(2)([3]);//should return undefined
Stephen James
@sjames1958gm
Aug 31 2017 23:54
@artoodeeto You are using a closure. Your access of n inside the function returned is a closure
return sum += n + y; this should just be return n + y;
Since sum is zero the first works,