These are chat archives for FreeCodeCamp/HelpJavaScript

1st
Aug 2017
Bradley Sands
@sandsbe
Aug 01 2017 00:15
clearAll and equal IDs keep showing up in output
I feel like I had this calculator that only worked part of the time in school
njordomir
@njordomir
Aug 01 2017 00:16
Lol, I just wrote code so inefficient it crashed Chrome developer tools multiple times, but it passed the test after a few minutes of thinking :P I should probably find an alternative solution.
Jim Tryon
@jimtryon
Aug 01 2017 00:17
@njordomir Yeah, even though you have a working solution, I’d suggest refactoring that so it doesn’t crash any more :P
Stephen James
@sjames1958gm
Aug 01 2017 00:17
@artoodeeto In isMath you need && not ||
Nick Janne
@njanne19
Aug 01 2017 00:55
I'm really lost with D3... I have this so far, https://codepen.io/njanne19/pen/LjNeQr but not totally sure where to go from here. Why are all my bars so damn big
aRtoo
@artoodeeto
Aug 01 2017 01:11
@sjames1958gm ha?? i dont have && or ||
Stephen James
@sjames1958gm
Aug 01 2017 01:12
@artoodeeto Oops wrong person.
@sandsbe if (input !== 'clearAll' || input !== 'clearLast' || input !== 'decimal' || input !== 'equal') {
These need to be &&
@artoodeeto You need to apply some error checking on the response from channels request
These are a couple of checks to prevent undefined getting on the screen.
      if (userData.error) {
        console.log(userData.error);
        return;
      }
      else if (!userData.status) {
        console.log("No status: " + users);
        return;
      }
aRtoo
@artoodeeto
Aug 01 2017 01:17
@sjames1958gm so i need to filter my live search??
Ruchika Sharma
@ruchika90
Aug 01 2017 01:17
@manish-giri ty for helping
CamperBot
@camperbot
Aug 01 2017 01:17
ruchika90 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6344 | @manish-giri |http://www.freecodecamp.com/manish-giri
Stephen James
@sjames1958gm
Aug 01 2017 01:17
@artoodeeto yes, as you type you get lots of misses as far as real users
aRtoo
@artoodeeto
Aug 01 2017 01:18
@sjames1958gm or what if i could just target the array users??
Stephen James
@sjames1958gm
Aug 01 2017 01:18
@artoodeeto You could, really how much functionality is up to you.
@artoodeeto Might be an interesting challenge to get this working.
aRtoo
@artoodeeto
Aug 01 2017 01:19
@sjames1958gm aight bro thanks. yea
CamperBot
@camperbot
Aug 01 2017 01:19
artoodeeto sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8210 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 01 2017 01:28
@artoodeeto :+1:
Bradley Sands
@sandsbe
Aug 01 2017 01:30
ty @sjames1958gm. Ok. So || is a straight up OR. One, OR the other. &&, when its done with !== basically means "none of these", correct? That's what I was going for.
CamperBot
@camperbot
Aug 01 2017 01:30
sandsbe sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8211 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 01 2017 01:31
@sandsbe Yes, so for it to be none of those you need NOT this one AND NOT that one AND not t'other one
Bradley Sands
@sandsbe
Aug 01 2017 01:32
BOOM. I was losing my mind there for a bit.
John
@AnonymousLords
Aug 01 2017 01:36
I am honestly confused on why this wont work

function titleCase(str) {
  arrayStr = str.toLowerCase().split(" ");

  for (var i =0; i < arrayStr.length; i++) {
    arrayStr[i][0].toUpperCase();

  }

  return arrayStr.join(' ');

}

titleCase("Im a little tea pot");
It upper cases each word
kumquatfelafel
@kumquatfelafel
Aug 01 2017 01:37
string functions return a new string (well, not all of them necessarily return a string but...), they do not modify the original.
John
@AnonymousLords
Aug 01 2017 01:37
How do i reassign arrayStr teh new value
kumquatfelafel
@kumquatfelafel
Aug 01 2017 01:39
How do i reassign arrayStr teh new value
John
@AnonymousLords
Aug 01 2017 01:40
Would i make arrayStr[i][0].toUpperCase(); = to another varaible?
kumquatfelafel
@kumquatfelafel
Aug 01 2017 01:40
close
Try and see what happens. Won't be quite what you want, but a start
John
@AnonymousLords
Aug 01 2017 01:41
My for loop output isnt given to anything .-.

function titleCase(str) {
  arrayStr = str.toLowerCase().split(" ");

  for (var i =0; i < arrayStr.length; i++) {
    var arr = arrayStr[i][0].toUpperCase();
    if (i == arrayStr.length) {
      arrayStr = arr;
    }

  }
  return arrayStr.join(' ');

}

titleCase("Im a little tea pot");
console.log(arrayStr[i][0].toUpperCase());
I
A
L
T
P
=> 'im a little tea pot'
Hummm
kumquatfelafel
@kumquatfelafel
Aug 01 2017 01:43
@AnonymousLords You don't actually need to create a new variable.
John
@AnonymousLords
Aug 01 2017 01:44
If i do arrayStr = arrayStr[i][0].toUpperCase(); its only one letter
Stephen James
@sjames1958gm
Aug 01 2017 01:44
@AnonymousLords You have to add back in the rest of the string.
Then perhaps store back into arrayStr[i]
kumquatfelafel
@kumquatfelafel
Aug 01 2017 01:45
@AnonymousLords what is arrayStr[0], e.g.
John
@AnonymousLords
Aug 01 2017 01:45
@kumquatfelafel First letter of each word, because my string is separated by words
Stephen James
@sjames1958gm
Aug 01 2017 01:46
@AnonymousLords First figure out how to convert arrayStr[i] to title case, not just one upperCase letter
kumquatfelafel
@kumquatfelafel
Aug 01 2017 01:46
arrayStr[0], for titleCase("Im a little tea pot"); would be Im
John
@AnonymousLords
Aug 01 2017 01:47
arrayStr = str.toLowerCase().split(" "); @kumquatfelafel
@sjames1958gm Okay
kumquatfelafel
@kumquatfelafel
Aug 01 2017 01:48
As @sjames1958gm points out, you have set up a way to get a capitalized version of that first letter for each string. But you still need the rest of that string somehow.
John
@AnonymousLords
Aug 01 2017 01:48
Its each of the words in teh string
But combing those captilized letters back is my issue
Stephen James
@sjames1958gm
Aug 01 2017 01:49
@AnonymousLords arrayStr[i][0].toUpperCase() this is a start - just concatenate the rest of the string to it
think of string functions that grab part of a string
kumquatfelafel
@kumquatfelafel
Aug 01 2017 01:49
:point_up:
John
@AnonymousLords
Aug 01 2017 01:49
Okay
kumquatfelafel
@kumquatfelafel
Aug 01 2017 01:50
And you'll need to store the result properly when time comes.
off for time being.
John
@AnonymousLords
Aug 01 2017 01:51
@sjames1958gm So after that add a join?
Stephen James
@sjames1958gm
Aug 01 2017 01:52
@AnonymousLords join is for converting array to string, so no.
What string functions get a subset of a string?
John
@AnonymousLords
Aug 01 2017 01:52
Im not sure
kumquatfelafel
@kumquatfelafel
Aug 01 2017 01:53

Join at the very end??? It's a possibility, just remember,

@AnonymousLords join is for converting array to string

John
@AnonymousLords
Aug 01 2017 01:55
arrayStr[i] = arrayStr[i][0].toUpperCase().substring(i, 4);
.substring(i, 4);
kumquatfelafel
@kumquatfelafel
Aug 01 2017 01:58
Do you want to take a part of the string from just the first character, or a part of the string from the entire word?
John
@AnonymousLords
Aug 01 2017 01:59
entire word?
kumquatfelafel
@kumquatfelafel
Aug 01 2017 01:59
remember, with method chaining, this ...
arrayStr[0][0].toUpperCase().substring(i,4);
would be like
"I".toUpperCase().substring(i,4)
would be like...
"I".substring(i,4);
John
@AnonymousLords
Aug 01 2017 02:00
Okay
Kelechi Chinaka
@ke1echi
Aug 01 2017 02:01
do u really need the entire word? @AnonymousLords because you already has the first letter
John
@AnonymousLords
Aug 01 2017 02:01
Im just tryingt o combine teh first letter with teh word
kumquatfelafel
@kumquatfelafel
Aug 01 2017 02:02
@kelechy doesn't need the entire word, but does need to take a substring of word, not first character.
Kelechi Chinaka
@ke1echi
Aug 01 2017 02:03
that would give you Llittle @AnonymousLords
John
@AnonymousLords
Aug 01 2017 02:03
okay
Kelechi Chinaka
@ke1echi
Aug 01 2017 02:03
you just need to add from the second letter
John
@AnonymousLords
Aug 01 2017 02:03
I still am confused on substrings to
Kelechi Chinaka
@ke1echi
Aug 01 2017 02:04
add from second to the end..using any of the str methods
John
@AnonymousLords
Aug 01 2017 02:05
Can you put this into eay terms
John
@AnonymousLords
Aug 01 2017 02:05
more understandable terms .-.
Kelechi Chinaka
@ke1echi
Aug 01 2017 02:05
slice() substr() substring() checkout doc on how to use them @AnonymousLords
kumquatfelafel
@kumquatfelafel
Aug 01 2017 02:09

indexStart
An integer between 0 and the length of the string, specifying the offset into the string of the first character to include in the returned substring.

e.g. substring(0) will return a substring starting at the very first index of string (i.e. from the very beginning) up until the end of the string.

indexEnd
Optional. An integer between 0 and the length of the string, which specifies the offset into the string of the first character not to include in the returned substring.

e.g. substring(0,2) will return string starting at first character (index 0) and ending before the third character (index 2)

John
@AnonymousLords
Aug 01 2017 02:15


function titleCase(str) {

  arrayStr = str.toLowerCase().split(" ");
  var result = 0;

  for (var i =0; i < arrayStr.length; i++) {
   result = arrayStr[i][0].toUpperCase().substring(1); 
  }
  arrayStr = result;
  arrayStr.join(' ');

return arrayStr.join(" ");

}

titleCase("Im a little tea pot");
TypeError: arrayStr.join is not a function
kumquatfelafel
@kumquatfelafel
Aug 01 2017 02:16
Is result an array?
John
@AnonymousLords
Aug 01 2017 02:16
@moigithub result is beig overwritten
;-;
@kumquatfelafel Yes it is
supposed to be
first word, first chacter
But its getting over written each time it loops
Okay
function titleCase(str) {
  arrayStr = str.toLowerCase().split(" ");
  var result = 0;

  for (var i =0; i < arrayStr.length; i++) {
  arrayStr[i][0].toUpperCase().substring(1);

  }

  arrayStr = arrayStr.join(' ');

return arrayStr;

}

titleCase("Im a little tea pot");`
Still no way to reassign it
Thats what i have so far
Kelechi Chinaka
@ke1echi
Aug 01 2017 02:21
do u really need the [i] @AnonymousLords
Stephen James
@sjames1958gm
Aug 01 2017 02:22
@AnonymousLords
arrayStr[i] = arrayStr[i][0].toUpperCase() + restofstring arrayStr[i]
John
@AnonymousLords
Aug 01 2017 02:22
@kelechy it needs to loop threw teh words
Am i close guys?
Kelechi Chinaka
@ke1echi
Aug 01 2017 02:23
ok
Stephen James
@sjames1958gm
Aug 01 2017 02:23
@AnonymousLords
You have to assign the value to a variable. why not assign it back into arrayStr[i] so when you join you get the right result
kumquatfelafel
@kumquatfelafel
Aug 01 2017 02:23
@AnonymousLords Here's a piece of code where I change all the values of an array to 5.
var array = [1,2,3,4];
for (var i = 0; i < array.length; i++) {
  array[i] = 5;
}
John
@AnonymousLords
Aug 01 2017 02:23
@kumquatfelafel know that
Kelechi Chinaka
@ke1echi
Aug 01 2017 02:23
any good materials on react @moigithub
John
@AnonymousLords
Aug 01 2017 02:24
arrayStr[i] = arrayStr[i][0].toUpperCase().substring(1); just puts out ' '
Then i need to add teh rest of teh string abck to it
kumquatfelafel
@kumquatfelafel
Aug 01 2017 02:25
@AnonymousLords That's because you are taking the substring starting at the second letter of the first letter of each word. Which makes no sense.
John
@AnonymousLords
Aug 01 2017 02:25
word basically
Stephen James
@sjames1958gm
Aug 01 2017 02:25
arrayStr[i].substring(1) will give you the rest of the string
@kelechy https://www.youtube.com/user/learncodeacademy
This guy has some good react playlists
kumquatfelafel
@kumquatfelafel
Aug 01 2017 02:26
substring(1) is right function, but being used on wrong value. In this particular case, you don't actually want to use chaining, you want to call substring function on the word itself. Not the character.
John
@AnonymousLords
Aug 01 2017 02:26
so i?
Moisés Man
@moigithub
Aug 01 2017 02:27
first char + rest of word
Stephen James
@sjames1958gm
Aug 01 2017 02:27
@AnonymousLords
arrayStr[i] = arrayStr[i][0].toUpperCase() + arrayStr[i].substring(1);
replace the word with the uppercase first character + rest of string
Kelechi Chinaka
@ke1echi
Aug 01 2017 02:28
thanks @sjames1958gm
CamperBot
@camperbot
Aug 01 2017 02:28
kelechy sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8212 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
John
@AnonymousLords
Aug 01 2017 02:28
@kumquatfelafel I used 1 as teh substring because i already had the first letter
@sjames1958gm worked, i didnt know i could use + in this case
So arrayStr[i] = arrayStr[i][0].toUpperCase() + arrayStr[i].substring(1); Is uppercasing the first letter of each word, then i is looping threw each word and adding that two the result of the uppercase, ignoring the first character of each word because we already have that. Then making it to teh value of that word.
I think i have a better understanding of this now
kumquatfelafel
@kumquatfelafel
Aug 01 2017 02:31

@AnonymousLords I know. Right function call, but called on wrong thing.

What you were doing would be like saying "J".substring(1), i.e. return string starting at second character of "J". But "J" is only one character.

John
@AnonymousLords
Aug 01 2017 02:31
Oh okay
I didnt know i could use + in this
I know taht you can add two strings using the addition sign, but i didn't know i could do that with this.
kumquatfelafel
@kumquatfelafel
Aug 01 2017 02:32
Result of toUpperCase() is a string. So you can +, much like you could with any other string.
John
@AnonymousLords
Aug 01 2017 02:33
Thanks @kumquatfelafel @kelechy @sjames1958gm @moigithub , i think i could of got this sooner if i knew about the addition sign :P. You guys are the best!
CamperBot
@camperbot
Aug 01 2017 02:33
anonymouslords sends brownie points to @kumquatfelafel and @kelechy and @sjames1958gm and @moigithub :sparkles: :thumbsup: :sparkles:
:cookie: 294 | @kelechy |http://www.freecodecamp.com/kelechy
:cookie: 561 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
:star2: 8213 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 3546 | @moigithub |http://www.freecodecamp.com/moigithub
John
@AnonymousLords
Aug 01 2017 02:34
I feel like i'm getting too much help on this challenges. Coding is hard, but every time i do a challenge it makes the next one much easier @kumquatfelafel @sjames1958gm
Enstien failed math, but it was because he learned differently.
I think its because i'm more of a visual learner, and a lot of these documents are paragraphs of words and a couple examples.
Huỳnh Trần Khanh
@khanh2003
Aug 01 2017 02:41

@AnonymousLords

i'm more of a visual learner

visual learner, text learner, hamburger learner, water learner, unicorn learner, ... did you know learning style is a myth?
btw, Einstein is very good at math. In primary school, he was at the top of his class and far above the school requirements. another link.

Abhishek Kumar Tiwari
@abhkt2611
Aug 01 2017 02:43
hello
Joseph
@revisualize
Aug 01 2017 02:58
Hello.
Bradley Sands
@sandsbe
Aug 01 2017 03:14
HELLO
hillsie
@Hillsie
Aug 01 2017 03:52
Hi there, does anyone have any suggestions on how to convert a large number to decimal. For instance, 7.125774134884027e+26 to see this number as a decimal?
without the e notation.
CallMeOrange
@EgnaroDev
Aug 01 2017 03:59
I'd like to know too...
Joel Y.
@zapcannon99
Aug 01 2017 04:02

Kinda hard to do that in Javascript as the data that holds integers doesn't have enough bits. You'd probably have to create your own functions/classes or find a library to do that.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

Or maybe you can write you function where you interpret the number into a string.
hillsie
@Hillsie
Aug 01 2017 04:07
Thanks @zapcannon99 .I’m thinking how that would work. I’m trying to solve a problem of adding to large number like. '712569312664357328695151392', ‘8100824045303269669937’, . One way would be to convert each to a string, then load them into an array and add number by number while carrying the ten.
CamperBot
@camperbot
Aug 01 2017 04:07
hillsie sends brownie points to @zapcannon99 :sparkles: :thumbsup: :sparkles:
:cookie: 327 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
Joel Y.
@zapcannon99
Aug 01 2017 04:08
If it's simple addition and subtraction, that might be your best option. There is a library that does accurate (and large number) math. I just need to find it....
hillsie
@Hillsie
Aug 01 2017 04:10
Great thanks, I’m supposed to solve it first principals. Part of my daily coding exercise :)
but I’ll take a look anyhow.
Joel Y.
@zapcannon99
Aug 01 2017 04:10
Mkay. I believe that you are definitely taking the right approach.
Kelechi Chinaka
@ke1echi
Aug 01 2017 04:12
Expected: '712577413488402631964821329', instead got: '7.125774134884027e+26'
how do i solve the problem
hillsie
@Hillsie
Aug 01 2017 04:12
@kelechy exactly.
one of the problems I found on code wars.
Kelechi Chinaka
@ke1echi
Aug 01 2017 04:14
yea
i really want to know how js handles large num
Joel Y.
@zapcannon99
Aug 01 2017 04:15
uh, I think it just doesn't hahahaha
hillsie
@Hillsie
Aug 01 2017 04:15
converts it to scientific notation?
Joel Y.
@zapcannon99
Aug 01 2017 04:15
Yeah, I think it does
but I think there is definitely a point in which it just does 1e99 or something similar.

From MDN:

The MAX_SAFE_INTEGER constant has a value of 9007199254740991. The reasoning behind that number is that JavaScript uses double-precision floating-point format numbers as specified in IEEE 754 and can only safely represent numbers between -([2^53] - 1) and [2^53] - 1.

Guderian Raborg
@hypercuber
Aug 01 2017 04:18
@Hillsie Putting digits of big number as elements in array might help
Joel Y.
@zapcannon99
Aug 01 2017 04:18
@hypercuber That's what he was thinking.
or at least some version of it
Tarun Khandelwal
@Delwalt
Aug 01 2017 04:19
Hi Guys.
Guderian Raborg
@hypercuber
Aug 01 2017 04:19
Tell me what does 7.125774134884027e+26 mean and I will try to do it if you want
Joel Y.
@zapcannon99
Aug 01 2017 04:19
Hi
Tarun Khandelwal
@Delwalt
Aug 01 2017 04:19
I need some help with JS
Guderian Raborg
@hypercuber
Aug 01 2017 04:19
@Delwalt tell us question
Claudio Restifo
@Marmiz
Aug 01 2017 04:20
Or don't use JS for handling high precision points since it's notoriously unreliable >.<
Joel Y.
@zapcannon99
Aug 01 2017 04:20
lol, indeed.
Claudio Restifo
@Marmiz
Aug 01 2017 04:20
(used to be at least)
Tarun Khandelwal
@Delwalt
Aug 01 2017 04:20
Hi @hypercuber I am actually looking for a stack slider.
Its not a question just want to know if you know any such slider.
Guderian Raborg
@hypercuber
Aug 01 2017 04:20
Or maybe there is another way to solve the problem you are on
Would like to know problem that deal with big number
@Delwalt Idk about slider
hillsie
@Hillsie
Aug 01 2017 04:21
@hypercuber its a scientific notation. https://en.wikipedia.org/wiki/Scientific_notation
Basically, the number multiplied by 10 to the exponent 26
Tarun Khandelwal
@Delwalt
Aug 01 2017 04:22
Capture.PNG
Somethig like this
Ok @hypercuber thanks.
CamperBot
@camperbot
Aug 01 2017 04:22
delwalt sends brownie points to @hypercuber :sparkles: :thumbsup: :sparkles:
:cookie: 361 | @hypercuber |http://www.freecodecamp.com/hypercuber
Guderian Raborg
@hypercuber
Aug 01 2017 04:25
@Hillsie If you want to go from like 6,720,000,000 to 6.72×109 maybe start with a string not number?
hillsie
@Hillsie
Aug 01 2017 04:27
@hypercuber , thanks. look at using it like this so far:
function sumStrings(a,b) { 
    for (var digit in a){
        console.log(a[digit])
    }
CamperBot
@camperbot
Aug 01 2017 04:27
hillsie sends brownie points to @hypercuber :sparkles: :thumbsup: :sparkles:
:cookie: 362 | @hypercuber |http://www.freecodecamp.com/hypercuber
Joel Y.
@zapcannon99
Aug 01 2017 04:27
@Hillsie You'd have to be careful to go right to left rather than left to right
hillsie
@Hillsie
Aug 01 2017 04:28
Good point
Kelechi Chinaka
@ke1echi
Aug 01 2017 04:30
hey guyys i still dont get the idea
pls throw some more explanation
hillsie
@Hillsie
Aug 01 2017 04:31
@kelechy will do in due course. I’ll try code it up and post it later.
Markus Kiili
@Masd925
Aug 01 2017 04:54
@Hillsie Remember that those digits are not guaranteed to be iterated in order when you use a for...in loop.
hillsie
@Hillsie
Aug 01 2017 04:55
@Masd925 Didn’t know that. I thought that the position of the string character is fixed.
'123'[1]
‘1
Markus Kiili
@Masd925
Aug 01 2017 04:58
@Hillsie It is, but for iterating array or string indices, you should use a for loop or an array iterator. for...in loop is for iterating object property keys, and the order is not guaranteed, although browsers seem to be doing the iteration in insertion order (at this moment). The language standard doesn't state the order so you should not rely on it.
hillsie
@Hillsie
Aug 01 2017 05:00
so you are saying this might not occur in order
    for (var adigit in a){
        x.push(a[adigit]);
    }
Markus Kiili
@Masd925
Aug 01 2017 05:01
@Hillsie Yes.
hillsie
@Hillsie
Aug 01 2017 05:02
@Masd925 thanks for the head up. So whats the standard for looping over a string. Nothing like Python then?
CamperBot
@camperbot
Aug 01 2017 05:02
hillsie sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4359 | @masd925 |http://www.freecodecamp.com/masd925
Kelechi Chinaka
@ke1echi
Aug 01 2017 05:02
Expected: '712577413488402631964821329', instead got: '7.125774134884027e+26'
caneno
@caneno
Aug 01 2017 05:02
hi guys
Markus Kiili
@Masd925
Aug 01 2017 05:02
@Hillsie Simple for loop, or split and array iterator.
Kelechi Chinaka
@ke1echi
Aug 01 2017 05:02
@Masd925 how does js solve this problem
caneno
@caneno
Aug 01 2017 05:02
I am breaking my head with this challenge hope you guys can help me
Kelechi Chinaka
@ke1echi
Aug 01 2017 05:02
how does it handle large figures
hillsie
@Hillsie
Aug 01 2017 05:02
Just part of the solution @kelechy
Kelechi Chinaka
@ke1echi
Aug 01 2017 05:03
dont get it @Hillsie
caneno
@caneno
Aug 01 2017 05:03

function rot13(str) { // LBH QVQ VG!
  var str1 = "";
  for(var i = 0; i < str.length; i++){
    if(str.charCodeAt(i) >= 78){
      str1 += str.charCodeAt(i) - 13;
    }else if(str.charCodeAt(i) < 78){
      str1 += str.charCodeAt(i) + 13;
    }
    console.log(String.fromCharCode(str1));
  }

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
I can only get the F to ouput
hillsie
@Hillsie
Aug 01 2017 05:04
@kelechy … I’m building up to it. I’ll post when I have a working solution :)
Markus Kiili
@Masd925
Aug 01 2017 05:04
@kelechy If I remember correctly, there is no simple way.
Joel Y.
@zapcannon99
Aug 01 2017 05:05
@caneno Why not use str1.concat(str.charCodeAt(i));
hillsie
@Hillsie
Aug 01 2017 05:05
@kelechy @Masd925 was just pointing out that there is no loop like in Python ;)
caneno
@caneno
Aug 01 2017 05:05
let me try it
Markus Kiili
@Masd925
Aug 01 2017 05:06
@Hillsie ES6 JS also has for...of loop.
Joel Y.
@zapcannon99
Aug 01 2017 05:07
@caneno Actually, don't you need to convert the new value back to a character
You are adding toString() values of integers to str1 rather than actual characters.
hillsie
@Hillsie
Aug 01 2017 05:08
@Masd925 thanks. And I see it loops over a string.
CamperBot
@camperbot
Aug 01 2017 05:08
hillsie sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: hillsie already gave masd925 points
Kelechi Chinaka
@ke1echi
Aug 01 2017 05:08
so no way to get the expected output @Masd925
hillsie
@Hillsie
Aug 01 2017 05:09
@Masd925 Side topic. I see ES6 using let more often than var. Why’s that?
Markus Kiili
@Masd925
Aug 01 2017 05:09
@kelechy There is always a way...
Joel Y.
@zapcannon99
Aug 01 2017 05:09
When there is a will
caneno
@caneno
Aug 01 2017 05:09
@zapcannon99 I am able to convert to ascii but all the numers are together and I am not able to convert back to string
Markus Kiili
@Masd925
Aug 01 2017 05:09
@Hillsie Keeps variables on block scope.
hillsie
@Hillsie
Aug 01 2017 05:09
@kelechy Patience , I’m working on it…. :)
@Masd925 and var in JS variables apply at a function level ?
Markus Kiili
@Masd925
Aug 01 2017 05:10
@Hillsie Yes. Or at script (global) scope.
hillsie
@Hillsie
Aug 01 2017 05:11
@Masd925 with var You can’t see it outside the function, right?
Markus Kiili
@Masd925
Aug 01 2017 05:12
@Hillsie That is correct.
Kelechi Chinaka
@ke1echi
Aug 01 2017 05:12
:ear: :ear: @Masd925
hillsie
@Hillsie
Aug 01 2017 05:12
@Masd925 by script, it’s global in the .js file?
Kelechi Chinaka
@ke1echi
Aug 01 2017 05:12
@Hillsie ok :smile:
Markus Kiili
@Masd925
Aug 01 2017 05:13
@Hillsie It you have several scripts on a page, they all use the same global scope.
hillsie
@Hillsie
Aug 01 2017 05:14
wow, yes, again thanks @Masd925 , that certainly clarified it for me. Ok, I prefer ES6. I’ll need to understand how to transpile.
CamperBot
@camperbot
Aug 01 2017 05:14
hillsie sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: hillsie already gave masd925 points
Use it after adding/subtracting and getting your integer that represents your new charcode
hillsie
@Hillsie
Aug 01 2017 05:20
@zapcannon99 let me try a little further. I’m nearly there. It’s a bit bloated so far.
Joel Y.
@zapcannon99
Aug 01 2017 05:21
@Hillsie If you need more help let me know soon. I'm about to turn in for the night.
hillsie
@Hillsie
Aug 01 2017 05:22
:+1:
I’ll post for comments
Joel Y.
@zapcannon99
Aug 01 2017 05:22
oooh ok
GL
caneno
@caneno
Aug 01 2017 05:25
@zapcannon99 my issue is that when I convert it to ascii it gives me long number so when I try to convert it back to string it does not work
Joel Y.
@zapcannon99
Aug 01 2017 05:25
Can I see your new code again?
caneno
@caneno
Aug 01 2017 05:26
function rot13(str) { // LBH QVQ VG!
  var str1 = str.split("");
  var str2 = "";
  for(var i = 0; i  < str.length; i++){
    str2 += str.charCodeAt(i);
  }
  console.log(String.fromCharCode(str2));

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
this is not to solve the issue this code is for me to understand why is not outputting the string
I am no using the str1for now
Joel Y.
@zapcannon99
Aug 01 2017 05:28

I understand.

So you are not using String.fromCharCode() in the right place.

Use it as you convert you get and change each charcode

In this example, it would be str2 += String.fromCharCode(str.charCodeAt(i));

Try this for your example. I hope it becomes clearer where you need to go from there.
caneno
@caneno
Aug 01 2017 05:29
ah let me try it
awesome ok let me try it all together
Joel Y.
@zapcannon99
Aug 01 2017 05:30
I also can't form coherent sentences. It's getting late XP.
caneno
@caneno
Aug 01 2017 05:37
it is clear now I am trying to integrate the if is less than 78 to add 13
Joel Y.
@zapcannon99
Aug 01 2017 05:38
Cool. You just have to do one step (change two lines) from the code you first posted in order to get the result you want I think
caneno
@caneno
Aug 01 2017 05:46
I am not able to add the - 13 or +13 I am so tempted to look at the answer
u.u
Joel Y.
@zapcannon99
Aug 01 2017 05:47
let me see what you have
caneno
@caneno
Aug 01 2017 05:47

function rot13(str) { // LBH QVQ VG!
  var str1 = "";
  for(var i = 0; i < str.length; i++){
    if(str.charCodeAt(i) >= 78){
      str1 += String.fromCharCode(str.charCodeAt(i)) ;
      console.log(str1);
    }else if(str.charCodeAt(i) < 78){
      str1 += String.fromCharCode(str.charCodeAt(i)) ;
    }
    console.log(str1);
  }

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Joel Y.
@zapcannon99
Aug 01 2017 05:47
You didn't add the 13 at all?
caneno
@caneno
Aug 01 2017 05:48
when I doo I get the string with - 13 or +13
Joel Y.
@zapcannon99
Aug 01 2017 05:48
well, str.charCodeAt(i) returns a number right?
caneno
@caneno
Aug 01 2017 05:48
yes
Joel Y.
@zapcannon99
Aug 01 2017 05:48
So you can add 13 to a number
and then get the new char code
sorry, new char from the char code
Markus Kiili
@Masd925
Aug 01 2017 05:48
@zapcannon99 It is pretty hard to make a solution to the Caesar cipher that is easy to read and understand. Use of any magic numbers like 13, 26 or 64 easily makes it hard or requires comments.
caneno
@caneno
Aug 01 2017 05:49
yeah
Joel Y.
@zapcannon99
Aug 01 2017 05:49
@Masd925 Yeah, but I'm pretty sure that this is the exercise, and it specifies 13
caneno
@caneno
Aug 01 2017 05:49
gotta run
I try it tomorrow thanks for everything
Joel Y.
@zapcannon99
Aug 01 2017 05:50
K
caneno
@caneno
Aug 01 2017 05:50
@zapcannon99 thanks
CamperBot
@camperbot
Aug 01 2017 05:50
caneno sends brownie points to @zapcannon99 :sparkles: :thumbsup: :sparkles:
:cookie: 328 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
Markus Kiili
@Masd925
Aug 01 2017 05:50
@zapcannon99 Yes. Just commenting how hard it is to make an easily understandable solution.
Joel Y.
@zapcannon99
Aug 01 2017 05:50
@caneno You're close to getting the result you want.
@Masd925 I'm just trying to get him to his answer with what he has. I know there are other ways to do it.
Markus Kiili
@Masd925
Aug 01 2017 05:51
@zapcannon99 Yeah. I am not commenting that solution or your help on it. Just the problem in general.
Joel Y.
@zapcannon99
Aug 01 2017 05:52
Fair enough. I take long about ways of explaining. I might be a bad way of going about it though.
It seems to be the case.
Sorry for reading your message incorrectly.
Markus Kiili
@Masd925
Aug 01 2017 05:58
@zapcannon99 No problem. Keep up the good work :+1:
Joel Y.
@zapcannon99
Aug 01 2017 06:01
@Masd925 You too! :thumbsup:
Philippe Tremblay
@philtrem
Aug 01 2017 08:01
I'm building a drum machine in Javascript, it's pretty much done except I'm having a problem with playback... Playing sounds is not performant enough it seems... There is delay that is introduced. I verified it's not the javascript timers, btw.
anyone could help ?
I'm wondering if there is not a better way to play sounds
I should also mention I made sure to keep my files smalls
Abhinav Mishra
@abhinav-m
Aug 01 2017 08:02
@philtrem aah, there is audio context
@philtrem but that won't work for you since youre trying to emulate a drum machine..
Philippe Tremblay
@philtrem
Aug 01 2017 08:03
most individual samples are ~20kb I think
hillsie
@Hillsie
Aug 01 2017 08:08
@kelechy @Masd925 @zapcannon99 I’ve completed the addition in string format function. it’s a bit long. So I’ve added a gist link. The point of it was to be able to add a long number and display this without the scientific “e” notation. The code could be optimised, but this works.
https://gist.github.com/anonymous/b0f73611ce9506fc330fd66c171d5e0d
hillsie
@Hillsie
Aug 01 2017 08:26
still renders it anyway, sorry channel.
Owais Ahmed
@owaisehmed
Aug 01 2017 08:51
Im on "Seek and Destroy" task and confused as to how can i access the the numbers or strings after the array as we have been only provided with an array in the function. Can anybody please help?
Markus Kiili
@Masd925
Aug 01 2017 08:52
@owaisehmed Use the arguments object.
Darth Skywalker
@AdiSkywalker
Aug 01 2017 09:45
@Hillsie :+1: :+1:

@Hillsie

You could replace this

for (let adigit of a){
        x.push(adigit);
    }
    for (let bdigit of b){
        y.push(bdigit);
    }
    let tempArr = x.slice();

simply with

x = a.split('');
y = b.split('');

let tempArr = x.slice();
hillsie
@Hillsie
Aug 01 2017 09:50
:+1: @AdiSkywalker , let me try that.
EpicTriffid
@EpicTriffid
Aug 01 2017 09:51
Im trying to figure out how to count the number of times a number appears in an array. I'm basically looking to write an if statement that says "if x occurs only once, do this". I was thinking of trying to do a count of the occurrences of all numbers in the array, but I don't know where i would store them, and I'm sure there's a better way
Markus Kiili
@Masd925
Aug 01 2017 09:56
@EpicTriffid You need to somehow loop through the array elements. So you can use a for loop or some array iterator method like forEach or reduce. You could store the number of occurences on a plain object.
hillsie
@Hillsie
Aug 01 2017 09:57
@EpicTriffid I would probably also describe what you want to do in sudo code. The doco for JS is pretty good. There are some methods you could use here. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
Write down the steps in sudo code then translate that into written code.
Blauelf
@Blauelf
Aug 01 2017 09:58

@EpicTriffid You could count them, like

var histogram = array.reduce(function(hist, elem) { hist[elem] = (hist[elem] || 0) + 1; return hist; }, Object.create(null));

Object.create(null) creates an object without a prototype, which is somewhat near a dict. I used that before there were ES6 maps.

Markus Kiili
@Masd925
Aug 01 2017 09:59
@Hillsie You must have been using linux for too long ;) You must mean pseudocode.
hillsie
@Hillsie
Aug 01 2017 10:00
:smile: baahaahhaa!!
Darth Skywalker
@AdiSkywalker
Aug 01 2017 10:01

@Hillsie

One more thing... This whole part

let x = [];
    let y = [];
    let total = []; //initialise the string. 
    let subtotal = 0;


    // lots of duplicate code from here. Could probably be added to a helper function.

    for (let adigit of a){
        x.push(adigit);
    }
    for (let bdigit of b){
        y.push(bdigit);
    }
    let tempArr = x.slice();

    for(let checkLeading of x){
        if (checkLeading == 0){
            tempArr.shift();
        } else{
            // break on first occurance of 
            break;
        }
    }
    x = tempArr.slice();
    tempArr = y.slice();
    for(let checkLeading of y){
        if (checkLeading == 0){
            tempArr.shift();
        } else{
            // break on first occurance of 
            break;
        }
    }
    y = tempArr.slice();

    x = x.reverse();
    y = y.reverse();

can be replaced with

let x = parseInt(a).toString().split('');
let y = parseInt(b).toString().split('');
let total = []; //initialise the string. 
let subtotal = 0;



x = x.reverse();
y = y.reverse();
Markus Kiili
@Masd925
Aug 01 2017 10:02
@AdiSkywalker x.reverse(); etc. would be enough. Mutator method.
hillsie
@Hillsie
Aug 01 2017 10:02
@AdiSkywalker Thanks. Like it
CamperBot
@camperbot
Aug 01 2017 10:02
hillsie sends brownie points to @adiskywalker :sparkles: :thumbsup: :sparkles:
:cookie: 302 | @adiskywalker |http://www.freecodecamp.com/adiskywalker
Darth Skywalker
@AdiSkywalker
Aug 01 2017 10:03
parseInt will get you rid of trailing 0s
split will converge it to array
@Masd925 Yes... I haven't paid attention to that part. I was just optimising the initial setup
Markus Kiili
@Masd925
Aug 01 2017 10:03
Yeah.
hillsie
@Hillsie
Aug 01 2017 10:04
aah, I think I didn’t use it because with big numbers it converted it to e notation.
Darth Skywalker
@AdiSkywalker
Aug 01 2017 10:04
@Hillsie Oh!
is it?
Then my bad
Well then that defeats the purpose
hillsie
@Hillsie
Aug 01 2017 10:05
There are some test cases at the bottom.
Nicolas Ramirez
@kamatheuska
Aug 01 2017 10:08
Hello there! I want to make a function which can show one letter at a time, like a typing machine. This is the code i got so far (I also tried other things, but until yet nothing worked). Help please!
var greeting = "¡Hola! ¿Qué quieres hacer?"
  var toType = greeting.split("");
  var i = 0;
  var h1 = $("h1");

  var myVar = setInteval(function() { 
    h1.append(toType[i]);
    i++;
  }
, 800);

  if (!(i < toType.length)) {
    clearInterval(myVar);
  }
no idea why the last part looks like a string....
Markus Kiili
@Masd925
Aug 01 2017 10:10
@kamatheuska That last check happens before the setinterval callbacks execute.
Darth Skywalker
@AdiSkywalker
Aug 01 2017 10:10
@Hillsie This will work now
var _a = a.split('');
var _b = b.split('');
let x = _a.slice( _a.findIndex( n => +n !== 0 ));
let y = _b.slice( _b.findIndex( n => +n !== 0 ));
let total = []; //initialise the string. 
let subtotal = 0;
hillsie
@Hillsie
Aug 01 2017 10:11
:+1: @AdiSkywalker
Nicolas Ramirez
@kamatheuska
Aug 01 2017 10:11
@Masd925 how should I use the clear interval then? I had no luck googling it...
hillsie
@Hillsie
Aug 01 2017 10:12
let me plug it into my IDE and try fiture out whats happening.
Markus Kiili
@Masd925
Aug 01 2017 10:12
@kamatheuska Try doing the check inside the setInterval callback.
Darth Skywalker
@AdiSkywalker
Aug 01 2017 10:12
Fabien SHAN
@X140hu4
Aug 01 2017 10:13
Does anyone knows a comprehensive guide for programming in Google spreadsheets? I am used to doing stuff in VBA in excel >.<
Darth Skywalker
@AdiSkywalker
Aug 01 2017 10:13
@kamatheuska
var myVar = setInteval(function() { 
    h1.append(toType[i]);
    if (!(i++ < toType.length)) {
      clearInterval(myVar);
    }
  }
, 800);
Your if condition is checked before your i starts incrementing
so it is never true and thus the interval never clears
Nicolas Ramirez
@kamatheuska
Aug 01 2017 10:15
@AdiSkywalker I see, let me test it and I comeback, @Masd925 thanks to both!
CamperBot
@camperbot
Aug 01 2017 10:15
kamatheuska sends brownie points to @adiskywalker and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 303 | @adiskywalker |http://www.freecodecamp.com/adiskywalker
:star2: 4360 | @masd925 |http://www.freecodecamp.com/masd925
hillsie
@Hillsie
Aug 01 2017 10:23
@AdiSkywalker I’m not yet familar with the => operator.
let x = _a.slice( _a.findIndex( n => +n !== 0 ));
basically you are saying, find the first occurance of the array index where n is !== to 0. As this is a strict search, (!== vs !=), I would have thought it would not do the type conversion. I thought teh _a variable would have a string in it.
The slice the array and return the remainder.
EpicTriffid
@EpicTriffid
Aug 01 2017 10:24
Yello, me again. Right, so im working on Diff Two Arrays on FCC (https://www.freecodecamp.com/challenges/diff-two-arrays), and my logic currently is concatenate the two arrays, duplicate, and loop both, then run through an index of, comparing both and if any of the loops ===-1, push to a new array. Would it work?
Chris Juchtmans
@kjuchtmans
Aug 01 2017 10:25
A good afternoon to you all, fine coders! :wave:
Markus Kiili
@Masd925
Aug 01 2017 10:25
@Hillsie + (Unary plus) coerces to type Number there.
hillsie
@Hillsie
Aug 01 2017 10:25
Aha, got ya
Markus Kiili
@Masd925
Aug 01 2017 10:25
I like Number(n) more.
hillsie
@Hillsie
Aug 01 2017 10:25
man I like this language. Still some way to go.
Darth Skywalker
@AdiSkywalker
Aug 01 2017 10:26
@Hillsie The => is ES6 arrow function. If you don't understand it clearly, this is how the code looks without using it
let x = _a.slice( _a.findIndex( function(n){
  return +n !== 0;
} ));
Chris Juchtmans
@kjuchtmans
Aug 01 2017 10:27

"Validate US Phone Numbers"

why is a test string with 7 digits returning true in my below code? Should return false
Is my length check incorrect?

code:

function telephoneCheck(str) {
  // Good luck!
  var arr,
      result;

  arr = str.match(/[0-9]/g);

  if (arr.length=11){
    if(arr[0]===1) {
      result=true;
    }
  } result=false;

  if (arr.length=10){
    result=true;
  } else {
    result=false;
  }
  return result;
}

telephoneCheck("555-5555");

The arr looks correct though. thanks!

Darth Skywalker
@AdiSkywalker
Aug 01 2017 10:27
You're right.. The contents of _a (and _b) are strings. But if you notice there is a little + next to n that is being compared
@Hillsie
hillsie
@Hillsie
Aug 01 2017 10:30
Thanks guys @AdiSkywalker @Masd925 , let me begin my deep dive into functions and objects.
CamperBot
@camperbot
Aug 01 2017 10:31
hillsie sends brownie points to @adiskywalker and @masd925 :sparkles: :thumbsup: :sparkles:
:warning: hillsie already gave adiskywalker points
:star2: 4361 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 01 2017 10:31
@Hillsie OK. Come back when you can tell us why Object.length is 1.
hillsie
@Hillsie
Aug 01 2017 10:32
:)
Markus Kiili
@Masd925
Aug 01 2017 10:32
;)
EpicTriffid
@EpicTriffid
Aug 01 2017 10:33
This is going to be messy as hell, and probably infuriate y'all, but can anyone tell me where im going wrong here?

function diffArray(arr1, arr2) {
var newArr = [];
var fullArr = arr1.concat(arr2);
var secArr = fullArr.slice(0);
for (var i = 0; i < fullArr.length; i++) {
for (var j = 0; j < secArr.length; j++) {
if (fullArr.indexOf(secArr[j]) === -1) {
newArr.push(secArr[j]);
}
}
}

// Same, same; but different.
return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);

And be gentle. My brain is currently melting
Marianissimus
@Marianissimus
Aug 01 2017 10:39
@EpicTriffid doesnt concat return full array - like this [1, 2, 3, 5, 1, 2, 3, 4, 5] ? @EpicTriffid
heroiczero
@heroiczero
Aug 01 2017 10:40
@EpicTriffid personally would try using a filter or reduce
Marianissimus
@Marianissimus
Aug 01 2017 10:40
@EpicTriffid and why do you need var secArr - you could use the argument arr2, right?
Markus Kiili
@Masd925
Aug 01 2017 10:41
@EpicTriffid Yes, but having two copies of the full array doesn't help here.
EpicTriffid
@EpicTriffid
Aug 01 2017 10:42
I was thinking filter, but i dont know what the query would be for it
hillsie
@Hillsie
Aug 01 2017 10:42
@kjuchtmans if (arr.length=10){
Markus Kiili
@Masd925
Aug 01 2017 10:44
That if always executes. = is the assignment operator. Use === for comparisons.
Ryan Williams
@Ryanwfile
Aug 01 2017 10:45
If I have a parent component with a state of x : 0, how would I increment x by 1 in a child component, I know I need to use a callback just having difficulty setting up the this.setState function
hillsie
@Hillsie
Aug 01 2017 10:45
@Masd925 :smile: was waiting for @kjuchtmans to recognise it.
heroiczero
@heroiczero
Aug 01 2017 10:45
@EpicTriffid once you concat the arr and use indexOf if its not in one of the arr return the number so a if with a || statement
EpicTriffid
@EpicTriffid
Aug 01 2017 10:47
@heroiczero Right, I'll try that
@Marianissimus @Masd925 And yeah, i just realised why having a duplicate doesnt work. facepalm
Stephen James
@sjames1958gm
Aug 01 2017 10:53
@Ryanwfile Pass a function as a prop to the child that the child calls, the parent function updates the state
Marianissimus
@Marianissimus
Aug 01 2017 10:56
@EpicTriffid anyway, you gave me an idea to refactor my own solution - something like if arr1.indexOf(elementinfullarr) === -1 && arr2.indexOf(el) !== -1 II the exact opposite, push el
Nicolas Ramirez
@kamatheuska
Aug 01 2017 10:57
Marianissimus
@Marianissimus
Aug 01 2017 11:06
@EpicTriffid Wow, I'm amazed by this refactor I just made: ) the logic is even simpler: if (arr1.indexOf(el) === -1) || if (ar2.indexOf(el) == -1) // if one element from the concat array does not appear in one of the 2 initial arrays, just push it into the final arr. that's all
Jon
@jonandrepedersen
Aug 01 2017 11:07
Anyone else on the: "freeCodeCamp Algorithm Challenge Guide: Diff Two Arrays"? I wanted to follow the suggestion to team up with someone :)
Marianissimus
@Marianissimus
Aug 01 2017 11:09
I just gave more than a hint... @jonandrepedersen :)
Jon
@jonandrepedersen
Aug 01 2017 11:11
Ohh you were talking about it straight above xD Haha, I might turn to those hints later. For now wanna try to solve it myself. Hehe, was just looking for a "coder-buddy", hehe :p
Nicolas Ramirez
@kamatheuska
Aug 01 2017 11:11
well...here is the code
var user = ["ivoneparra", "saulparra", "kamatheuska"];
var current_user = user[0];
var greeting = "¡Hola!" + current_user + "¿Qué quieres hacer?"
var toType = greeting.split("");
var i = 0;


var myVar = setInteval(function() {
  document.getElementById("target").innerHTML = "nico";
  if (!(i++ < toType.length)) {
    clearInterval(myVar);
  }
}, 50);
Stephen James
@sjames1958gm
Aug 01 2017 11:13
@kamatheuska
document.getElementById("target").textContent += toType[i];
Nicolas Ramirez
@kamatheuska
Aug 01 2017 11:15
Instead of document.getElementById("target").innerHTML = toType[i];?
@sjames1958gm what do you mean?
Stephen James
@sjames1958gm
Aug 01 2017 11:17
@kamatheuska Dont you want to add each character to the field each timeout?
Wisdom Peters
@blackcytographer
Aug 01 2017 11:18
Hello guys I need help in writing a function that takes two argument a n b. N a is raise to the power of b, without using math. Pow().
Stephen James
@sjames1958gm
Aug 01 2017 11:18
@kamatheuska You are not putting HTML into the element so textContent is more appropriate
Nicolas Ramirez
@kamatheuska
Aug 01 2017 11:19
@sjames1958gm yes, but I still get errors on the console :(
heroiczero
@heroiczero
Aug 01 2017 11:19
@blackcytographer a**b in ES7
Stephen James
@sjames1958gm
Aug 01 2017 11:19
@blackcytographer You mean multiply a times itself b times
Marianissimus
@Marianissimus
Aug 01 2017 11:20
@blackcytographer you could create a loop (for i=0; i<=b; i++) {do math with a and i}
Stephen James
@sjames1958gm
Aug 01 2017 11:20
@heroiczero If the assignment is to not use Math.pow() why would using ** be allowed?
@kamatheuska What errors?
Nicolas Ramirez
@kamatheuska
Aug 01 2017 11:21
Uncaught ReferenceError: setInteval is not defined at window.onload
hillsie
@Hillsie
Aug 01 2017 11:21
I would have thought that this code would have created and instance of the Object, with the line var newTricks = oldDog; but it seems to point to the same object, because if I update the one, the oldDog ends up with a new property.
 var oldDog = {
  "name": "Camper",
  "legs": 4,
  "tails": 1,
  "friends": ["everything!"]
};
var newTricks = oldDog;  // seems to point to the same object.

newTricks.dance = "Tango"
console.log(newTricks);
console.log(oldDog);
Stephen James
@sjames1958gm
Aug 01 2017 11:22
@Hillsie variables store object references so your assignment just copies the reference.
Markus Kiili
@Masd925
Aug 01 2017 11:22
@Hillsie Yes, variables hold primitive values or references to objects. That just copies the reference.
Stephen James
@sjames1958gm
Aug 01 2017 11:23
@kamatheuska Maybe it is mispelled, that would be the first check I would make
hillsie
@Hillsie
Aug 01 2017 11:25
I’m guessing there is a way of creating an instance of the object and I just haven’t found it yet. @sjames1958gm @Masd925 Thanks guys.
CamperBot
@camperbot
Aug 01 2017 11:25
hillsie sends brownie points to @sjames1958gm and @masd925 :sparkles: :thumbsup: :sparkles:
:warning: hillsie already gave masd925 points
:star2: 8214 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 01 2017 11:25
@Hillsie You can use constructor functions.
hillsie
@Hillsie
Aug 01 2017 11:25
:+1:
Markus Kiili
@Masd925
Aug 01 2017 11:27
@Hillsie If you mean cloning an existing object, there are many ways depending whether you wan't a shallow or deep copy etc.
hillsie
@Hillsie
Aug 01 2017 11:28
@Masd925 what do you mean by shallow or deep?
Markus Kiili
@Masd925
Aug 01 2017 11:29
@Hillsie If there are property values that are objects, do you wan't to clone them too or just copy the reference.
hillsie
@Hillsie
Aug 01 2017 11:31
@Masd925 I guess I am looking to understand JS objects. They behave very much like Python dictionaries if I compare them. They seem to have a bit more flexibility in JS.
Chris Juchtmans
@kjuchtmans
Aug 01 2017 11:31
@Hillsie @Masd925 Dang! thats right, how could I not see it... must be the hot weather :smile: thanks people
CamperBot
@camperbot
Aug 01 2017 11:31
kjuchtmans sends brownie points to @hillsie and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 206 | @hillsie |http://www.freecodecamp.com/hillsie
:star2: 4362 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 01 2017 11:32
@Hillsie A simple way to clone on object is:
var obj = {cat:"pants"};
var copy = JSON.parse(JSON.stringify(obj));
hillsie
@Hillsie
Aug 01 2017 11:32
@kjuchtmans No worries, it clicked for me too when I found a common point of reference.
@Masd925 Let me try it out and see what it does.
Markus Kiili
@Masd925
Aug 01 2017 11:34
@Hillsie Has its limitations and might not do what you wan't.
EpicTriffid
@EpicTriffid
Aug 01 2017 11:40
@jonandrepedersen Hi Jon. Im on Diff Array now if you'd like to team up?
hillsie
@Hillsie
Aug 01 2017 11:41
@Masd925 Brilliant, that creates an instance of the object and now it can have independent properties.
Jon
@jonandrepedersen
Aug 01 2017 11:41
Cool, I'm actually ahead to the next challenge. But yeah, sure :) @EpicTriffid
EpicTriffid
@EpicTriffid
Aug 01 2017 11:44
@jonandrepedersen Dammit lol. Any insights?
Jon
@jonandrepedersen
Aug 01 2017 11:44
Aye. Also started a private chat:)
But up to you if you wanna chat here or there @EpicTriffid
EpicTriffid
@EpicTriffid
Aug 01 2017 12:01
did it guys! Thanks to @jonandrepedersen!
CamperBot
@camperbot
Aug 01 2017 12:01
epictriffid sends brownie points to @jonandrepedersen :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @jonandrepedersen |http://www.freecodecamp.com/jonandrepedersen
EpicTriffid
@EpicTriffid
Aug 01 2017 12:01

'
function diffArray(arr1, arr2) {
var newArr = [];
var fullArr = arr1.concat(arr2);

fullArr.filter(function(x) {
if (arr1.indexOf(x) === -1 || arr2.indexOf(x) === -1) {
newArr.push(x);
}
});

// Same, same; but different.
return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);'

Jon
@jonandrepedersen
Aug 01 2017 12:01
You did the work. I only gave a few hints
Markus Kiili
@Masd925
Aug 01 2017 12:02
@EpicTriffid That is not how you should use filter. You should return the condition from the callback and use the new array returned from filter.
You are using it to make side effects. For that you should use forEach instead.
EpicTriffid
@EpicTriffid
Aug 01 2017 12:04
@Masd925 Im not sure I quite understand?
heroiczero
@heroiczero
Aug 01 2017 12:04
@EpicTriffid yeah you could have just return the x and will give you the same effect
@EpicTriffid filter picks and chooses and right now your using your filter as if it is a loop
Markus Kiili
@Masd925
Aug 01 2017 12:06
@EpicTriffid Filter is used like this:
function diffArray(arr1, arr2) {
  var fullArr = arr1.concat(arr2);
  return fullArr.filter(function(x) {
    return  arr1.indexOf(x) === -1 || arr2.indexOf(x) === -1;
  });
}
Filter returns a new array made from elements that satisfy the condition there.
No need for a result array like you did.
EpicTriffid
@EpicTriffid
Aug 01 2017 12:08
@Masd925 @heroiczero Ah, yup. That makes sense. Thanks for that clarification
CamperBot
@camperbot
Aug 01 2017 12:08
epictriffid sends brownie points to @masd925 and @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1561 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 4364 | @masd925 |http://www.freecodecamp.com/masd925
EpicTriffid
@EpicTriffid
Aug 01 2017 12:12
@Masd925 Is there any big issues from using filter like i did?
Markus Kiili
@Masd925
Aug 01 2017 12:13
@EpicTriffid Just confuses the reader.
EpicTriffid
@EpicTriffid
Aug 01 2017 12:13
@Masd925 Righto
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:14
@EpicTriffid What you did is precisely what .filter does internally. And you were reimplementing it
kinda counter productive
on top of confusing
EpicTriffid
@EpicTriffid
Aug 01 2017 12:18
@AdiSkywalker So, to clarify, filter automatically creates a new array based on the query you tell it to use? And I what I was doing was telling it to query the data and push it to an array, despite the array already having been created and which was just sitting there, waiting to be returned?
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:19
It wasn't sitting there waiting. Since you didn't return anything from the function, filter returned an empty array
which was not catched in any other variable
but since you were performing operation inside the function, you got your self covered.. But in semantically incorrect way
EpicTriffid
@EpicTriffid
Aug 01 2017 12:21
@AdiSkywalker Id covered my butt for not having returned the filter array?
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:22
you covered your butt with this newArr.push(x); :laughing:
EpicTriffid
@EpicTriffid
Aug 01 2017 12:22
Very weird butt covering!
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:22
again, filter loops over array anyway. So there is no way that your code wouldn;t have worked.
Only thing is .filter is not the right choice for doing what you were doing
You should have user .forEach instead
EpicTriffid
@EpicTriffid
Aug 01 2017 12:24
I was getting so confused because i kept thinking i needed to loop through the arrays with a for loop, and not figuring that filter and foreach were already going to be doing that for me.
My brain takes to scenic route when it comes to logic
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:24
@EpicTriffid :laughing:
no worries.
keep at it
EpicTriffid
@EpicTriffid
Aug 01 2017 12:25
@AdiSkywalker Thankyou :)
CamperBot
@camperbot
Aug 01 2017 12:25
epictriffid sends brownie points to @adiskywalker :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @adiskywalker |http://www.freecodecamp.com/adiskywalker
IsmailHusseinCR
@IsmailHusseinCR
Aug 01 2017 12:31
function outer() {
    var a = 1;

    function inner() {
        var b = 2;

        console.log( a + b );    
    }

    console.log( a );    
}

outer();
inner();
Hi FCC
inner() is not defined
is it because its out of its scope
Markus Kiili
@Masd925
Aug 01 2017 12:32
@IsmailHusseinCR JS has function scope and inner is only defined inside outer.
John Alcher
@alchermd
Aug 01 2017 12:32
React guys out there: is passing props more than one level deep a normal thing?
IsmailHusseinCR
@IsmailHusseinCR
Aug 01 2017 12:33
ohkay @Masd925
Jefferson
@jeffersonnnn
Aug 01 2017 12:33

hi guys, can i get help for the repeat the string challenge, please.

Here is my code


function repeatStringNumTimes(str, num) {
  if (num === 0) {
    return str;
  } else if (num > 0){
    str.repeat(num);
  } else {
    return num;
  }
}

repeatStringNumTimes("abc", 3);
i cant seem to pass any of the test cases.
Kelechi Chinaka
@ke1echi
Aug 01 2017 12:34
no return for your else if @jeffersonnnn
Jon
@jonandrepedersen
Aug 01 2017 12:35
@jeffersonnnn Hmm, I believe I solved it by concatinating the str x number of times. How about trying something like that
perhaps with a for loop? @jeffersonnnn
Wisdom Peters
@blackcytographer
Aug 01 2017 12:41
@sjames1958gm yes sir that is what i mean
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:41
@jeffersonnnn str.repeat(num); should be return str.repeat(num);
Jefferson
@jeffersonnnn
Aug 01 2017 12:43
@AdiSkywalker @kelechy point take guys. Thanks. I can‘t pass the last test case thougn
CamperBot
@camperbot
Aug 01 2017 12:43
jeffersonnnn sends brownie points to @adiskywalker and @kelechy :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @kelechy |http://www.freecodecamp.com/kelechy
:cookie: 308 | @adiskywalker |http://www.freecodecamp.com/adiskywalker
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:44
@jeffersonnnn You need to return empty string "" when n <= 0
Jefferson
@jeffersonnnn
Aug 01 2017 12:44
that one indicates that num is negative. How do i make num negative
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:44
currently you're returning either str or num in case n <= 0
Jefferson
@jeffersonnnn
Aug 01 2017 12:45
@AdiSkywalker ah! i think that should solve that. I shall be back...
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:45
else {
    return num;
  }
Should be
else {
    return '';
  }
Wisdom Peters
@blackcytographer
Aug 01 2017 12:45
Hello guys I need help in writing a function that takes two argument a n b. and A is raise to the power of B, without using math. Pow(). or a**b
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:48
@blackcytographer
function myPow(num, toThePower){
  var result = num;
  var i = toThePower;
  while(--i) result *= num;
  return result;
}

myPow(5,3); // 125
Wisdom Peters
@blackcytographer
Aug 01 2017 12:50
@AdiSkywalker thanks a millon
CamperBot
@camperbot
Aug 01 2017 12:50
blackcytographer sends brownie points to @adiskywalker :sparkles: :thumbsup: :sparkles:
:cookie: 309 | @adiskywalker |http://www.freecodecamp.com/adiskywalker
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:50
@blackcytographer :+1:
Jefferson
@jeffersonnnn
Aug 01 2017 12:52
@AdiSkywalker thank you so much. Two bonfires in a day? Whoops, this feels good!
CamperBot
@camperbot
Aug 01 2017 12:52
jeffersonnnn sends brownie points to @adiskywalker :sparkles: :thumbsup: :sparkles:
:warning: jeffersonnnn already gave adiskywalker points
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:53
@jeffersonnnn on a side node, you could simplify your code like this
function repeatStringNumTimes(str, num) {
  return str.repeat( num > 0 ? num : 0);
}

repeatStringNumTimes("abc", 3);
Wisdom Peters
@blackcytographer
Aug 01 2017 12:53
@AdiSkywalker Write a function called longest which will take a string of space separated words and will return the longest one. this is my code but it is not running any ideal please?

function longest(str){

var arr = str.split(" ");
var maxLength = 0;
// assume the longest word is the first word of the array
for(var i = 0; i < arr.length; i++) {
if(arr[i].length > maxLength) {
maxLength = arr[i].length;
}
}
return maxLength;
};

longest("this is andela");

Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:54
What do you mean it's not running any ideal ?
@blackcytographer
The code looks good to me
Diego Mayer
@Chrono79
Aug 01 2017 12:56
@AdiSkywalker I think he meant any idea
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:56
@Chrono79 Oh! I see
Wisdom Peters
@blackcytographer
Aug 01 2017 12:56
@AdiSkywalker it takes a string of spaces
Darth Skywalker
@AdiSkywalker
Aug 01 2017 12:56
But this code must run
@blackcytographer string of space separated words
a string wherein the words are separated by space
Tomasz
@Tgralak
Aug 01 2017 12:58
function translatePigLatin(str) {
  var vowels = ["a","e","i","o","u"];
  var res;
  for (i=0;i<str.length;i++) {
    if (str[0] !== vowels[i]) {
      res = str.slice(1,str.length) + str.slice(0,1) + "ay";
    }
    else {
      res = str + "way";
    }
  }  
  return res;
}

translatePigLatin("california");
Hello again. Does anyone know why my code doesn't work? It's something with "if" statement?
Diego Mayer
@Chrono79
Aug 01 2017 12:58
@blackcytographer your code is ok (remove the semicolon after the } ), is the function name right?
Wisdom Peters
@blackcytographer
Aug 01 2017 12:59
@Chrono79 yea dont know what is wrong the question says Write a function called longest which will take a string of space separated words and will return the longest one.
Darth Skywalker
@AdiSkywalker
Aug 01 2017 13:00
@blackcytographer return longest word or return length of longest word?
As of now you're returning length of longest word
Kelechi Chinaka
@ke1echi
Aug 01 2017 13:01
convert to an array using split(' ') then sort the with length @blackcytographer
Darth Skywalker
@AdiSkywalker
Aug 01 2017 13:01
If you want longest word you need to do
function longest(str){
  var arr = str.split(" ");
 var longestWord = '';
// assume the longest word is the first word of the array
 for(var i = 0; i < arr.length; i++) {
    if(arr[i].length > longestWord.length) {
      longestWord = arr[i];
    }
  }
  return longestWord;
};

longest("this is andela");
@blackcytographer
Diego Mayer
@Chrono79
Aug 01 2017 13:02
@blackcytographer if your code is not for the FCC Find the Longest Word in a String, your code should be like @AdiSkywalker suggested
@Tgralak try your code at http://www.pythontutor.com/javascript.html#mode=edit see what it does
Kelechi Chinaka
@ke1echi
Aug 01 2017 13:05
return string.split(' ').sort((a, b) => {
return b.length - a.length
})[0];
@blackcytographer that if you dont want to use loop
Diego Mayer
@Chrono79
Aug 01 2017 13:06
maybe throwing arrow functions it's too much right now ;)
Kelechi Chinaka
@ke1echi
Aug 01 2017 13:06
:smile: sorry for that
:wave: @Chrono79
Diego Mayer
@Chrono79
Aug 01 2017 13:07
np, he'll encounter them sooner or later :wave:
Kelechi Chinaka
@ke1echi
Aug 01 2017 13:07
hows the day been
Diego Mayer
@Chrono79
Aug 01 2017 13:07
sligthly rainy
Wisdom Peters
@blackcytographer
Aug 01 2017 13:07
@Chrono79 thanks
CamperBot
@camperbot
Aug 01 2017 13:07
blackcytographer sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4502 | @chrono79 |http://www.freecodecamp.com/chrono79
Wisdom Peters
@blackcytographer
Aug 01 2017 13:07
@kelechy my guy thanks how far
CamperBot
@camperbot
Aug 01 2017 13:07
blackcytographer sends brownie points to @kelechy :sparkles: :thumbsup: :sparkles:
:cookie: 296 | @kelechy |http://www.freecodecamp.com/kelechy
Kelechi Chinaka
@ke1echi
Aug 01 2017 13:08
nice..i think its the rainy season @Chrono79
good, u @blackcytographer
Tomasz
@Tgralak
Aug 01 2017 13:09
Hello, could anyone help me with my code? I have no idea why it doesn't work with all the cases:
function translatePigLatin(str) {
  var vowels = ["a","e","i","o","u"];
  var res;
  for (i=0;i<str.length;i++) {
    if (str[0] !== vowels[i]) {
      res = str.slice(1,str.length) + str.slice(0,1) + "ay";
    }
    else {
      res = str + "way";
    }
  }  
  return res;
}

translatePigLatin("california");
Diego Mayer
@Chrono79
Aug 01 2017 13:09
@Tgralak did you try running your code in pythontutor as I said?
Kelechi Chinaka
@ke1echi
Aug 01 2017 13:09
i ranked up @CW @Chrono79 ...this code thingy begining to make sense :smile:
Tomasz
@Tgralak
Aug 01 2017 13:10
@Chrono79 sorry, didnt see the message, will do
Diego Mayer
@Chrono79
Aug 01 2017 13:11
@kelechy :+1:
Tomasz
@Tgralak
Aug 01 2017 13:13
@Chrono79 I did, but i dont really understand it
Kelechi Chinaka
@ke1echi
Aug 01 2017 13:15
what does the challenge want you to do @Tgralak
OldmanVimes
@OldmanVimes
Aug 01 2017 13:16
function mutation(arr) {
  arr[0]=arr[0].toLowerCase();
  arr[1]=arr[1].toLowerCase();
    for (var i=0; i<arr[1].length;i++){
      if (arr[0].indexOf(arr[1][i])== -1){

      return false;
      }
    return true;}
}

mutation(["hello", "hey"]);
except this case, all cases are satisfied
Tomasz
@Tgralak
Aug 01 2017 13:16
@kelechy im doing Pig Latin challenge
OldmanVimes
@OldmanVimes
Aug 01 2017 13:16
what am I doing wrong?
Ryan Williams
@Ryanwfile
Aug 01 2017 13:18
@sjames1958gm Thanks, I figured it out soon after I posted. Had trouble figuring out to setState{ count : this.state.count +1}
CamperBot
@camperbot
Aug 01 2017 13:18
ryanwfile sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8215 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Diego Mayer
@Chrono79
Aug 01 2017 13:19
@OldmanVimes you're returning both true and false inside the loop
That makes it only checks the first letter
Kelechi Chinaka
@ke1echi
Aug 01 2017 13:19
what does it want you to do..i mean instruction @Tgralak
OldmanVimes
@OldmanVimes
Aug 01 2017 13:21
@Chrono79 thanks a lot, that did it. But could you just make me understand why?
CamperBot
@camperbot
Aug 01 2017 13:21
oldmanvimes sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4503 | @chrono79 |http://www.freecodecamp.com/chrono79
Tomasz
@Tgralak
Aug 01 2017 13:21
@kelechy in "if" statement i want to check if first letter is a vowel from array, if its false its replacing first letter at the end of string and adds "ay", if its true i want to only add "way" at the end, but the else statement doesnt work i think
Diego Mayer
@Chrono79
Aug 01 2017 13:21
@OldmanVimes both words started with the same letter, and your code returned true then
OldmanVimes
@OldmanVimes
Aug 01 2017 13:21
Just want to get a clear understanding @Chrono79
Tomasz
@Tgralak
Aug 01 2017 13:22
@kelechy
function translatePigLatin(str) {
  var vowels = ["a","e","i","o","u"];
  var res;
  for (var i=0;i<str.length;i++) {
    if (str[0] !== vowels[i]) {
      res = str.slice(1,str.length) + str.slice(0,1) + "ay";
    }
    else {
      res = str + "way";
    }
  }  
  return res;
}

translatePigLatin("california");
Diego Mayer
@Chrono79
Aug 01 2017 13:22
you need to check the whole second word before you can say for sure there is no new letter in it @OldmanVimes
OldmanVimes
@OldmanVimes
Aug 01 2017 13:23
Yeah I got all that, but how did my "return true" function being in the loop affect the program?
Diego Mayer
@Chrono79
Aug 01 2017 13:24
@OldmanVimes try your code here: http://www.pythontutor.com/javascript.html#mode=edit and see it for yourself
it short-circuited the loop execution
return exits the loop and the function, so no other letter was checked
OldmanVimes
@OldmanVimes
Aug 01 2017 13:27
Thanks a lot @Chrono79 .
CamperBot
@camperbot
Aug 01 2017 13:27
oldmanvimes sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: oldmanvimes already gave chrono79 points
Tiago Correia
@tiagocorreiaalmeida
Aug 01 2017 13:29
hello everyone
function timercountdown(timetogodown) {
  if(isPaused){
    clock = timetogodown;
    updateclock();
  }else{
    var int = setInterval(function() {
      if(timetogodown === 0){
        clearInterval(int);
        console.log("over");
        $(".Timer").html("Time: " + 0);
        breakcountdown(breaktime);
      }else{
       $(".Timer").html("Time: " + timetogodown);
          timetogodown-- ;
      }
    }, 1000);
  }
}
 // I got this Function and then I created a stop button

$(".pause").click(function(){
  $(".play").removeClass("active");
  $(".pause").addClass("active");
  isPaused = true;
})
shouldnt this work?
Tomasz
@Tgralak
Aug 01 2017 13:30
I have a question. How do i execute code, like, not instantly but after my if statement check every "i" in loop?
  for (var i=0;i<str.length;i++) {
    if (str[0] !== vowels[i]) {
      res = str.slice(1,str.length) + str.slice(0,1) + "ay";
    }
}
Tiago Correia
@tiagocorreiaalmeida
Aug 01 2017 13:31
you store the values and call them after the loop I think
Wisdom Peters
@blackcytographer
Aug 01 2017 13:32

please any ideal in writing a function my_sort which takes in a list of numbers (integers).

The function should return a list of sorted numbers such that odd numbers come first and even numbers come last.

Tiago Correia
@tiagocorreiaalmeida
Aug 01 2017 13:33
split the odds to one place and the others to another
sort them seprated
and then concat them

var vec1 = ['a', 'b', 'c'];
var vec2 = ['d', 'e', 'f'];

var vec3 = vec1.concat(vec2);

// vec3 é um novo vector [ "a", "b", "c", "d", "e", "f" ]

got it?:D
show me what you have if you need further help
Wisdom Peters
@blackcytographer
Aug 01 2017 13:34
@tiagocorreiaalmeida ok sir thanks
CamperBot
@camperbot
Aug 01 2017 13:34
blackcytographer sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @tiagocorreiaalmeida |http://www.freecodecamp.com/tiagocorreiaalmeida
Tiago Correia
@tiagocorreiaalmeida
Aug 01 2017 13:35
use a loop with a if statement inside if its odd push the value to arrayodd else push to arrayeven
after the loop you just have to concat them that's it, gl
Stephen James
@sjames1958gm
Aug 01 2017 13:38
@tiagocorreiaalmeida
timetogodown-- this updates a local variable and not any global countdown
Tiago Correia
@tiagocorreiaalmeida
Aug 01 2017 13:40
https://codepen.io/tiagocorreia/pen/LjGwmg my problem stands at the pause button if wanan give it a look would be happy
Wisdom Peters
@blackcytographer
Aug 01 2017 13:42
my code seem not to run pls any ideal?

function isIsogram(str) {
str = str.toLowerCase();
//Change to LowerCase and run a for loop.
var arr = str.split(" ");
var letters = [];
// using a for loop to checked through the array

for (var i = 0; i < arr.length; i++) {
if(letters.indexOf(arr[i] === -1)) {
letters.push(arr[i]);
}
else {
return false;
}
}
return true;
};

isIsogram("Dermatoglyphics");

Diego Mayer
@Chrono79
Aug 01 2017 13:45
@blackcytographer arr is an array of words, each arr[i] is a word
if you want to iterate over letters, use str[i] no need to work with arrays
Marianissimus
@Marianissimus
Aug 01 2017 13:45
@blackcytographer indexOf(arr[i]) - close the bracket there
Jon
@jonandrepedersen
Aug 01 2017 13:46

Heya. So I'm on the Roman Number converter challenge. I have listed out the array of Roman Numbers, I have converted the parameter (num) to string and reversed. Now I know I need to loop over these, but I cannot really wrap my head around the following:

  1. How exactly I would do the loop, e.g. that the first digit would be within the [0] array, tenths [1] and so forth.
  2. How I would deal with 1000s

Any hint would be appreciated, I'm afraid if I'll google it I'll stumble upon the solution without any clue of how it actually should work.

`

function convertToRoman(num) {
var rom = [
[I, II, III, IV, V, VI, VII, VIII, IX],
[X, XX, XXX, XL, L, LX, LXX, LXXX, XC],
[C, CC, CCC, CD, D, DC, DCC, DCCC, CM],
[M] // thousands??
];

var dig = num.toString().split("").reverse();

var romNum = "";
for(var i =0;i<dig.length;i++){
romNum = // HEEELP
}
return romNum;
}

convertToRoman(36);
`

Wisdom Peters
@blackcytographer
Aug 01 2017 13:46
@Chrono79 done that still not working
Jon
@jonandrepedersen
Aug 01 2017 13:46
Sorry, how did I do the correct code preview again? I thought it was with this sign? ` ?
Kelechi Chinaka
@ke1echi
Aug 01 2017 13:47
check if every character is the last instance in the array @blackcytographer
Wisdom Peters
@blackcytographer
Aug 01 2017 13:47
@kelechy ok
Tiago Correia
@tiagocorreiaalmeida
Aug 01 2017 13:47
@Chrono79 can you look into my pen?
Diego Mayer
@Chrono79
Aug 01 2017 13:47
@blackcytographer did you change what @Marianissimus told you too?
@tiagocorreiaalmeida paste the link
Wisdom Peters
@blackcytographer
Aug 01 2017 13:48
@kelechy broderly any sample example?
Kelechi Chinaka
@ke1echi
Aug 01 2017 13:48
your indexOf() is not correct @blackcytographer
close it
Wisdom Peters
@blackcytographer
Aug 01 2017 13:49
@kelechy any suggestions?
Tiago Correia
@tiagocorreiaalmeida
Aug 01 2017 13:49
https://codepen.io/tiagocorreia/pen/LjGwmg how can I work around with my pause button?the idea is stop the function and store the value
Diego Mayer
@Chrono79
Aug 01 2017 13:49
@jonandrepedersen use three ``` before and after your code
Kelechi Chinaka
@ke1echi
Aug 01 2017 13:50
  1. u need to split to an array of characters
Marianissimus
@Marianissimus
Aug 01 2017 13:51
@blackcytographer also the logic doesn't quite work. your letters array starts as empty, so it will be filled with anything inside var arr / str. split. so?!
Jon
@jonandrepedersen
Aug 01 2017 13:51

@Chrono79 perfect. Thanks

function convertToRoman(num) {
  var rom = [
    [I, II, III, IV, V, VI, VII, VIII, IX],
    [X, XX, XXX, XL, L, LX, LXX, LXXX, XC],
    [C, CC, CCC, CD, D, DC, DCC, DCCC, CM],
    [M] // thousands??
  ];

  var dig = num.toString().split("").reverse();

  var romNum = "";
  for(var i =0;i<dig.length;i++){
    romNum = // HEEELP
  }
 return romNum;
}

convertToRoman(36);

So I'm on the Roman Number converter challenge. I have listed out the array of Roman Numbers, I have converted the parameter (num) to string and reversed. Now I know I need to loop over these, but I cannot really wrap my head around the following:

  1. How exactly I would do the loop, e.g. that the first digit would be within the [0] array, tenths [1] and so forth.
  2. How I would deal with 1000s

Any hint would be appreciated, I'm afraid if I'll google it I'll stumble upon the solution without any clue of how it actually should work.

CamperBot
@camperbot
Aug 01 2017 13:51
jonandrepedersen sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4504 | @chrono79 |http://www.freecodecamp.com/chrono79
Wisdom Peters
@blackcytographer
Aug 01 2017 13:51
@kelechy like using .join(") or what
Diego Mayer
@Chrono79
Aug 01 2017 13:51
@kelechy no need to use split there, he can access a single letter directly
Kelechi Chinaka
@ke1echi
Aug 01 2017 13:52
2.check if the character is the last instance in that array str.indexOf(char) === str.lastIndexOf(char)
ok, i dont know his logic, just tryna make it easy @Chrono79
Diego Mayer
@Chrono79
Aug 01 2017 13:53
:+1:
Kelechi Chinaka
@ke1echi
Aug 01 2017 13:53
if it is, then do something else raise an alarm :smile: @blackcytographer
Marianissimus
@Marianissimus
Aug 01 2017 13:54
@jonandrepedersen in my solution, I thought about the logic of it much more. yes, you have to reverse it, yes, you have to try a little trick (hack?) :)
Diego Mayer
@Chrono79
Aug 01 2017 13:55
@tiagocorreiaalmeida what should I see? I've found a bug when you press play more than once
Marianissimus
@Marianissimus
Aug 01 2017 13:55
@jonandrepedersen i didn't find such an array as yours useful - but, remember, that's just my solution. there are too many combinations to keep adding strings into arrays (DCCLVII), etc
caneno
@caneno
Aug 01 2017 13:55
Hi guys
Marianissimus
@Marianissimus
Aug 01 2017 13:56
@jonandrepedersen also, these are strings inside the array, use quotas var rom = ["I", "C"], etc
Jon
@jonandrepedersen
Aug 01 2017 13:57
@Marianissimus hehe there sure is.
Haha yeah ooops! Thanks for that. That's a silly mistake
CamperBot
@camperbot
Aug 01 2017 13:57
:cookie: 439 | @marianissimus |http://www.freecodecamp.com/marianissimus
jonandrepedersen sends brownie points to @marianissimus :sparkles: :thumbsup: :sparkles:
caneno
@caneno
Aug 01 2017 13:57

function rot13(str) { // LBH QVQ VG!
var str1 = "";
for(var i = 0; i < str.length; i++){
if(str.charCodeAt(i) >= 78){
str1 += String.fromCharCode(str.charCodeAt(i) - 13) ;

}else if(str.charCodeAt(i) < 78){
  str1 += String.fromCharCode(str.charCodeAt(i) + 13) ;
}

}
console.log(str1);
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

´´´
Diego Mayer
@Chrono79
Aug 01 2017 13:58
@caneno you're shifting also any other char beside capital letters
caneno
@caneno
Aug 01 2017 13:58
hoe do i fix that
Diego Mayer
@Chrono79
Aug 01 2017 13:59
add conditions or nest an if
Jon
@jonandrepedersen
Aug 01 2017 13:59
@Marianissimus how did you deal with "thousands"? Obviously you did the whole challenge a different way, but did you have to make some special case for thousands?
Marianissimus
@Marianissimus
Aug 01 2017 13:59
don't worry, think of the logic of it a bit more, write some pseudocode before actually coding. it will come to you. hint: think of the romans as using different bases :)
caneno
@caneno
Aug 01 2017 13:59
My output is FREE-CODE-CAMP. And it supposed to be FREE CODE CAMP
Diego Mayer
@Chrono79
Aug 01 2017 13:59
that's because you also shifted spaces
Jon
@jonandrepedersen
Aug 01 2017 13:59
@Marianissimus I will, thanks.
CamperBot
@camperbot
Aug 01 2017 13:59
jonandrepedersen sends brownie points to @marianissimus :sparkles: :thumbsup: :sparkles:
:warning: jonandrepedersen already gave marianissimus points
Diego Mayer
@Chrono79
Aug 01 2017 14:00
capital letter's codes go from 65 to 90 both inclusive
Darth Skywalker
@AdiSkywalker
Aug 01 2017 14:00
@caneno just do str1 = str1.split('-').join(' ');
Diego Mayer
@Chrono79
Aug 01 2017 14:00
@AdiSkywalker that's a hacky solution that won't work on all cases, he'll still shift numbers and punctuation symbols
Darth Skywalker
@AdiSkywalker
Aug 01 2017 14:01
Right... I haven't really checked the code @Chrono79
Marianissimus
@Marianissimus
Aug 01 2017 14:01
@jonandrepedersen not really, the same as i dealt with hundreds. actually, i have a roman numeral converter that goes up to 399.999 (cant find symbols for higher numbers). the logic is the same, it doesn't matter if it's a hundred or a thousand
Diego Mayer
@Chrono79
Aug 01 2017 14:02
@caneno only shift capital letters, pass the other chars as they are
Tomasz
@Tgralak
Aug 01 2017 14:08
  for (var i=0;i<str.length;i++) {
    if (str[0] !== vowels[i]) {
      res = str.slice(1,str.length) + str.slice(0,1) + "ay";
    }
}
How do I execute my code after every "i" iteration is finished?
because now it only checks the first one, and then doing the "res = str,slice..."
caneno
@caneno
Aug 01 2017 14:09
@Chrono79 how do o j
@Chrono79 how do i change only caps? Without changing spaces or symbols?
Marianissimus
@Marianissimus
Aug 01 2017 14:11
@Tgralak can u give more of the code? i don't want to type str or vowels
Tomasz
@Tgralak
Aug 01 2017 14:12
@Marianissimus
function translatePigLatin(str) {
  var vowels = ["a","e","i","o","u"];
  var res;
  for (var i=0;i<str.length;i++) {
    if (str[0] !== vowels[i]) {
      res = str.slice(1,str.length) + str.slice(0,1) + "ay";
    }
    else {
      res = str + "way";
    }
    return res;
  }  
}

translatePigLatin("california");
Tiago Correia
@tiagocorreiaalmeida
Aug 01 2017 14:12
@Chrono79 I know about that bug aswell was asking about help on how to stop the setinterval and return the time I still have left so I can resume later :D
dont check it yet might have solved it thanks anyway mate
Diego Mayer
@Chrono79
Aug 01 2017 14:17
:+1:
Marianissimus
@Marianissimus
Aug 01 2017 14:18
@Tgralak I actually think your slice is wrong, since it has a fixed start => str.slice (1, str.length) // what if it's still a consonant there?
Diego Mayer
@Chrono79
Aug 01 2017 14:18
@caneno
if the char code of the current letter is not in the range of caps
  pass it to the new string as it is
  else do what you did
Jon
@jonandrepedersen
Aug 01 2017 14:18
@Marianissimus Hmm, so I assume I should use parseInt in my loop then?
To return those strings of mine into numbers?
Tomasz
@Tgralak
Aug 01 2017 14:19
@Marianissimus consonant returns good string
@Marianissimus my problem is, I want to check every letter in array, and then execute code, because it only checks "a" and then executes it
caneno
@caneno
Aug 01 2017 14:20
@Chrono79 thanks
CamperBot
@camperbot
Aug 01 2017 14:20
caneno sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4505 | @chrono79 |http://www.freecodecamp.com/chrono79
Marianissimus
@Marianissimus
Aug 01 2017 14:20
@jonandrepedersen yeah, I used parseInt. I don't know, if you ask me, we'll arrive at the same solution :)
Joseph
@Big-jo
Aug 01 2017 14:21
<!DOCTYPE html>
<html>
<head>
    <title>Explorer</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
   <link rel="stylesheet" type="text/css" href="Style.css">
    <script type="text/javascript"src = href="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
   <script type="text/javascript"scr= href="JavascriptFile.js"></script>
</head>
<body >
   <div class=".container-fluid firstPage">
   <div class="forms-container">
       <div class="form-group">
           <label for="First-Name">First Name:</label>
           <input type="text" class="form-control" id="usr-firstName">
       </div>
       <div class="form-group">
           <label for="Second-Name">Second Name:</label>
           <input type="text" class="form-control" id="usr-secondName">
       </div>
       <!--Get the user's current location--> 
           <div class="form-group" class="CurrentLocation">
           <label for="Current-Location">Current Location:</label>
           <input type="text" class="form-control" id="usr-secondName">
           <button type="button" class="btn btn-primary disabled">Submit</button>
       </div>
   </div>
   </div>
</body>
</html>
please i have this form and is it possible to save the data from the form to a javascipt object so i can manipulate it later
Marianissimus
@Marianissimus
Aug 01 2017 14:21
you want to check every letter in the vowels array? but the for loop reffers to the str array, so that's what it will loop
@Tgralak
if you want to do a double loop, you could, but i don't really see the logic
Jon
@jonandrepedersen
Aug 01 2017 14:25
@Marianissimus omg, almost got it. I get 47 (in Roman letters) instead of 36 though, so must be something wrong with my increments/numbering
Marianissimus
@Marianissimus
Aug 01 2017 14:25
you'll get it. soon. i believe in you :) @jonandrepedersen
Jon
@jonandrepedersen
Aug 01 2017 14:26
@Marianissimus haha cheers mate
Marianissimus
@Marianissimus
Aug 01 2017 14:29
@Big-jo you can use a DOM selector, but if you are not there yet... however, it goes something like this: // var name = document.querySelector('input').value;
Tiago Correia
@tiagocorreiaalmeida
Aug 01 2017 14:30
@Chrono79 you have 1min?:D
function timercountdown() {
    var int = setInterval(function() {
        }, 1000); }
I got this
how can I do this from outside the function
clearInterval(int);
Diego Mayer
@Chrono79
Aug 01 2017 14:32
@tiagocorreiaalmeida defining int as a global?
Tiago Correia
@tiagocorreiaalmeida
Aug 01 2017 14:33
solved thanks and yeah taht was pretty much dumb
:D
Kelechi Chinaka
@ke1echi
Aug 01 2017 14:33
where are you taking your react course @Chrono79
Diego Mayer
@Chrono79
Aug 01 2017 14:34
@kelechy I'm doing the Udemy Course of Andrew Mead
Kelechi Chinaka
@ke1echi
Aug 01 2017 14:36
free or paid? @Chrono79
Diego Mayer
@Chrono79
Aug 01 2017 14:37
paid, $10
Kelechi Chinaka
@ke1echi
Aug 01 2017 14:37
am slowly going to pick the lib @Chrono79
Jon
@jonandrepedersen
Aug 01 2017 14:45

function convertToRoman(num) {
  var rom = [
    ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'],
    ['X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'],
    ['C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM'],
    ['M', 'MM', 'MMM'] 
  ];

  var dig = num.toString().split("").reverse();

  var romNum = "";
  for(var i =0;i<dig.length;i++){
    romNum = rom[i][parseInt(dig[i])] + romNum;
  }
 return romNum;
}

convertToRoman(36);

With this current version I get 47 (in Roman letters), not 36. If I do romNum = rom[i][parseInt(dig[i]) -1] + romNum; then I get 36 and a lot of the other tests but not all.

I understand indexing clearly is the issue, and I pass the test if I place a single empty string first in all the arrays (but that's ugly).

So what am I missing for fixing the issue properly?

When I said 'indexing' I meant the fact that arrays are counted from zero. Not sure if 'indexing' is the correct term for that at all :p
cykins4good
@cykins4good
Aug 01 2017 14:47
Logical Order in If Else Statements   freeCodeCamp.jpg
Hi to you all.i have been stuck with this for a while.Any assistance will be appreciated.
Thayyeb salim
@Thayyebsalim
Aug 01 2017 14:48
check the second condition first
@cykins4good
Marianissimus
@Marianissimus
Aug 01 2017 14:49
@cykins4good if first condition returns true, the other will NOT apply. so if val is < 10, you will get <10, even if it's less than 5
Tiago Correia
@tiagocorreiaalmeida
Aug 01 2017 14:56
<button action="lessclock" disabled>-</button>
<button action="lessclock" disabled>-</button>
imagine I wanted to add disabled
with jquery how I could do that?
Thayyeb salim
@Thayyebsalim
Aug 01 2017 15:00
.html?
instead of double quotes use single quotes
I'm not sure if it works tho
Joel Y.
@zapcannon99
Aug 01 2017 15:02
single versus double quotes shouldn't matter for values assigned to action
Blauelf
@Blauelf
Aug 01 2017 15:04
@tiagocorreiaalmeida Would like $("button").prop("disabled", true) work?
Tiago Correia
@tiagocorreiaalmeida
Aug 01 2017 15:06
it will thanks :)
atually doesnt nm np thanks for you time :)
Joel Y.
@zapcannon99
Aug 01 2017 15:10
How about $("button").attr("disabled", true) ?
Blauelf
@Blauelf
Aug 01 2017 15:14
@tiagocorreiaalmeida I just tried, prop works fine for me in a minimal pen: https://codepen.io/Blauelf/pen/QMEWWm?editors=1010
@zapcannon99 I think "disabled", "checked", and a few similar things are properties, therefore require prop instead of attr in more recent jQuery.
Joel Y.
@zapcannon99
Aug 01 2017 15:17
@Blauelf True, but I read that for some, using attr works. Weird. Maybe it has to do with versions?
Blauelf
@Blauelf
Aug 01 2017 15:22

I changed prop to attr and it still works. Maybe it's different for another browser (tested on Firefox) or another jQuery version. But in my pen, both work, though prop seems the more logical.

There is one difference, though, as prop creates disabled with a value of "", while attr uses "disabled". This might cause different behaviour on different browsers.

Same on Chrome. So not sure what would cause either of them to not work at all.
Stephen James
@sjames1958gm
Aug 01 2017 15:24
@jonandrepedersen Your code doesn't work for zero values, either insert the "" or test for zero.
if (parseInt(dig[i]))
      romNum = rom[i][parseInt(dig[i]) - 1] + romNum;
Joel Y.
@zapcannon99
Aug 01 2017 15:25
Prop is definitely more logical, no arguing that @Blauelf. I'm just confused why it works to substitute with attr.
Jon
@jonandrepedersen
Aug 01 2017 15:26
@sjames1958gm thanks! I had gone for the double quotes, but I like your take, I'll change mine :)
CamperBot
@camperbot
Aug 01 2017 15:26
jonandrepedersen sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8216 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 01 2017 15:26
@jonandrepedersen :+1:
Blauelf
@Blauelf
Aug 01 2017 15:26
@zapcannon99 It works, I guess they made it compatible for those using it in the wrong way...
Joel Y.
@zapcannon99
Aug 01 2017 15:27
@Blauelf Lol. Idk man. It's weird.
Blauelf
@Blauelf
Aug 01 2017 15:29
@zapcannon99 When the disabled property is set, the disabled attribute will report a value of "disabled", not matter of its real value. Seems to be their workaround.
Joel Y.
@zapcannon99
Aug 01 2017 15:29
@Blauelf Huh. Interesting. Thanks for the info. Makes sense.
CamperBot
@camperbot
Aug 01 2017 15:29
zapcannon99 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4551 | @blauelf |http://www.freecodecamp.com/blauelf
hiteshthakur8888
@hiteshthakur8888
Aug 01 2017 15:56

question : in output of this code there is no space between the lines..when i used <br> it gave error <html>

<body>

<script>
var myString = "hitesh";
var myNumber = 99;
var myBoolean = true;

document.write("Name: " + myString );

document.write( "Lucky Number: " + myNumber);

document.write("Good joke? " + myBoolean);
</script>
</body>
</html>

Joel Y.
@zapcannon99
Aug 01 2017 15:57
don't put script in the body?
hiteshthakur8888
@hiteshthakur8888
Aug 01 2017 16:00
problem is also same in <head></head>
Christopher McCormack
@cmccormack
Aug 01 2017 16:00
@hiteshthakur8888 you're trying to use <br> in your script?
hiteshthakur8888
@hiteshthakur8888
Aug 01 2017 16:00
yes but not working
Christopher McCormack
@cmccormack
Aug 01 2017 16:01
@hiteshthakur8888 can you show an example of what isn't working?
document.write("Name: " + myString + '<br/>'); seems to work fine for me
hiteshthakur8888
@hiteshthakur8888
Aug 01 2017 16:04
thank you bro for + '<br/>' its working
Christopher McCormack
@cmccormack
Aug 01 2017 16:04
np
Jason Luboff
@JLuboff
Aug 01 2017 16:06
@cmccormack to the rescue!
Christopher McCormack
@cmccormack
Aug 01 2017 16:06
:bird: !
Joel Y.
@zapcannon99
Aug 01 2017 16:07
@JLuboff No kidding. Lol.
Jason Luboff
@JLuboff
Aug 01 2017 16:07
Courier pigeon?
Christopher McCormack
@cmccormack
Aug 01 2017 16:08
@JLuboff :wave: no idea why I used a bird - tried to find a superman icon to be ironic then just something that flew then realized a bird was fairly out of context
Joel Y.
@zapcannon99
Aug 01 2017 16:08
@cmccormack Those "googly eyes" is a bird?!?!?! O__o
Jason Luboff
@JLuboff
Aug 01 2017 16:10
Oh man. We're on high alert this week. Two different employee terminations...and yesterday we had to have a security guard here, today no security guard but all days locked (which is normal, except reception is usually unlocked)
Christopher McCormack
@cmccormack
Aug 01 2017 16:10
@zapcannon99 maybe we have different icons...
Joel Y.
@zapcannon99
Aug 01 2017 16:10
image.png
That's what I see.
Christopher McCormack
@cmccormack
Aug 01 2017 16:10
@JLuboff just from phishing?
@zapcannon99 it's a bird looking left
Joel Y.
@zapcannon99
Aug 01 2017 16:11
@JLuboff And wow. That's rough.
@cmccormack .... O__o
Christopher McCormack
@cmccormack
Aug 01 2017 16:12
@zapcannon99 Hey I didn't invent the :bird: icon
Markus Kiili
@Masd925
Aug 01 2017 16:12
@JLuboff What? :eyes:
Joel Y.
@zapcannon99
Aug 01 2017 16:12
@cmccormack I know, just... I'm confused. Maybe I didn't get enough sleep.
Christopher McCormack
@cmccormack
Aug 01 2017 16:14
That's usually the case
don't burn out! Sleep is important
Joel Y.
@zapcannon99
Aug 01 2017 16:14
Lol
Ankur sharma
@ankur1163
Aug 01 2017 16:14
i have photoshop question
trying to create ui
i got one plugin ink
i have latest version of photoshop
the plugin folder contain 3 folders
photoshop cc, photoshop cs6 , phtoshop cc 2015+
which one i need to install?
any idea?
Christopher McCormack
@cmccormack
Aug 01 2017 16:16
are you using CC? I would imagine CC 2015+ but I'm not really certain
Jason Luboff
@JLuboff
Aug 01 2017 16:17
@cmccormack Nah... I don't know why. These are guys who work in the field. I just deal with processing their AD account/email/computers
Christopher McCormack
@cmccormack
Aug 01 2017 16:17
this is a JavaScript help room, maybe the general or frontend room would be slightly more germane
Jason Luboff
@JLuboff
Aug 01 2017 16:17
@Masd925 Ya...I guess they're worried they'll go postal or something (albeit its more just to be safe)
Christopher McCormack
@cmccormack
Aug 01 2017 16:17
@JLuboff what kind of company is it, if you don't mind me asking
Jason Luboff
@JLuboff
Aug 01 2017 16:18
@cmccormack We're a small Oil company (~250-300? employees)
Christopher McCormack
@cmccormack
Aug 01 2017 16:19
oh ok for some reason I thought it was a tech company, I guess I linked CA with tech
I feel like I now need to make a There Will be Blood milkshake pun now...
Joel Y.
@zapcannon99
Aug 01 2017 16:20
lol
Christopher McCormack
@cmccormack
Aug 01 2017 16:22
Markus Kiili
@Masd925
Aug 01 2017 16:23
@JLuboff Are you like Homer behind all those screens doing important work controlling stuffs?
Christopher McCormack
@cmccormack
Aug 01 2017 16:24
Joel Y.
@zapcannon99
Aug 01 2017 16:25
This has turned into an entertainment thread for me. This is great.
Jason Luboff
@JLuboff
Aug 01 2017 16:26
@cmccormack I definitely feel thats relatable at times haha
@Masd925 Nahh... I don't work in operations. I do deal with computers going down or having issues though
@Masd925 But there is a seperate group who handles the computer systems for operations (that we're involved with to an extent)
Elektra NatchuSs
@ElektraNatchus
Aug 01 2017 16:29
Hello everyone, anyone can please explain to me why is my animate() method for a thumbnail slider NOT working? Here is Codepen
https://codepen.io/anon/pen/ayZbRN
Ankur sharma
@ankur1163
Aug 01 2017 16:33
@ElektraNatchus you have only created functions
i guess you have to call these functions as well
Christopher McCormack
@cmccormack
Aug 01 2017 16:37
@ElektraNatchus maybe try $(".c").animate({left: "-530px"});
@ElektraNatchus this is without bootstrap right? pretty impressive
@ElektraNatchus if you want it to keep working try something like $(".c").animate({left: "-=530px"});
Elektra NatchuSs
@ElektraNatchus
Aug 01 2017 16:42
Yes I just figured it out, haven't read the whole article on w3s about this function. Thanks
Nick Janne
@njanne19
Aug 01 2017 16:46
My D3 project is really screwey and I don't understand how the heights are being affected by the data can someone lend me a hand
Christopher McCormack
@cmccormack
Aug 01 2017 16:53
@njanne19 I don't see any data displayed in the columns - can you save your pen with the issue presented?
Moisés Man
@moigithub
Aug 01 2017 17:09
if u chekc ur dom element.. ur rect y attribute have -12313 value.. thats off screen <rect y="-179550" height="180000" width="177"></rect>
also ur height value is weird :D @njanne19 if ur screen resolution is 1000 x 1000 its obvious those values are not correct, soo u need to check ur scale
http://d3indepth.com/scales/
Nick Janne
@njanne19
Aug 01 2017 17:11
@cmccormack for me I see a few columns that are blue and wide but no data is displayed inside of them
I see that @moigithub thank you
CamperBot
@camperbot
Aug 01 2017 17:14
njanne19 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3548 | @moigithub |http://www.freecodecamp.com/moigithub
missing "domain" on ur scale definition
Moisés Man
@moigithub
Aug 01 2017 17:21
u can use min/max functions to get domain range values
var min = d3.min(motivation, function(d) { return d.value; })
var max = d3.max(motivation, function(d) { return d.value; })
then use like
.domain([min, max])
or.. use extent function which returns an array with min,max
var ex = d3.extent(motivation, function(d) { return d.value; })
.domain(ex)
Harut
@harut-g
Aug 01 2017 17:29
Write function sum that would work like this:
sum(1)(2) == 3 // true 
sum(5)(5) == 10 // true 
sum(1)(0) == 1 // true
Sergey
@zhukovsp
Aug 01 2017 17:38
Hi guys. Help me please. What am I doing wrong? Why only last element of array using? http://jsbin.com/nucafuwane/edit?js,console
let arrs = [
  {arr:[{name:'one',qty:301},{name:'two',qty:401}]},
  {arr:[{name:'one',qty:302},{name:'two',qty:402}]},
  {arr:[{name:'one',qty:303},{name:'two',qty:403}]}
];
let nArr = [{name:'one',qty:5},{name:'two',qty:6}];

arrs.forEach(x => {
  nArr.forEach(y => {
    y.qty = y.qty*10;
  });

  x.arr = nArr; // probably this is a problem point
});

arrs.forEach(x => console.log(x.arr));

// result what I expect:
// [
//   {arr:[{name:'one',qty:50},{name:'two',qty:60}]},
//   {arr:[{name:'one',qty:500},{name:'two',qty:600}]},
//   {arr:[{name:'one',qty:5000},{name:'two',qty:6000}]}
// ]

// but actual result is:
// [
//   {arr:[{name:'one',qty:5000},{name:'two',qty:6000}]},
//   {arr:[{name:'one',qty:5000},{name:'two',qty:6000}]},
//   {arr:[{name:'one',qty:5000},{name:'two',qty:6000}]}
// ]
Christopher McCormack
@cmccormack
Aug 01 2017 17:39
@harut-g do you have a question?
Siphils
@Siphils
Aug 01 2017 17:39

This is my code

$.ajax({
         type: "GET",
            url: "http://api.hitokoto.us/rand",
            dataType: "jsonp",
            jsonp: "callback",
            success: function(response) {
                var prop;
                for( prop in response){
                    document.write(prop+":"+response[prop]+"<br>");
                }
            },
            error: function() {
                document.write("Failed to get data!");
    }});

but it shows this error Uncaught SyntaxError: Unexpected token <what's the wrong?

Christopher McCormack
@cmccormack
Aug 01 2017 17:50
@Siphils does the api support jsonp?
Stephen James
@sjames1958gm
Aug 01 2017 18:00
@Siphils likely you are getting back a webpage and not json, check your devtools?
@zhukovsp Arrays are by reference, so when you do
x.arr = nArr;
you are changing x.arr to refer to nArr
Then in the end all three of the values in arrs all point (refer) to nArr.
try x.arr = nArr.slice(0); to get a copy
@harut-g
function sum(value) {
// returns a function that takes one parameter and adds it to value
}
Siphils
@Siphils
Aug 01 2017 18:07
This is the image of my devtools @sjames1958gm
KIm Ford
@kimfucious
Aug 01 2017 18:20
Hello all… I’ve drafted a quick solution for the random quote machine exercise, and have put it on CodePen here. All seems fine except for one bugaboo that I can’t figure out. In short, the share button appears after the first click of the get new quote button. Clicking the share button, results in a “good enough for this exercise” post of a tweet. My problem is that subsequent clicks on the share button will tweet the first quote retrieved. I am guessing this has to do with my variables not getting updated in the anonymous function that I have put under the click listener for share which is nested within the function for getting the quote. I’m not sure if this is closure related or what… any clues?
Marianissimus
@Marianissimus
Aug 01 2017 18:21
@kimfucious hey, why do you hide it? i can't even click it...
KIm Ford
@kimfucious
Aug 01 2017 18:22
@Marianissimus Hi… I hid it on purpose, because the initial quote is a dummy and not loaded from the api.
Stephen James
@sjames1958gm
Aug 01 2017 18:24
@kimfucious I ran it an it updated the tweet.
KIm Ford
@kimfucious
Aug 01 2017 18:25
@sjames1958gm Try it after the second click on the Get Quote button.
Marianissimus
@Marianissimus
Aug 01 2017 18:25
just a guess: it could be because of the ajax/asyncron nature of it. you update the quote in a function, but never update the share quote. try placing the share function as a callback in the ajax function
Stephen James
@sjames1958gm
Aug 01 2017 18:25
@kimfucious Yes, I did, I got the second quote, then the third quote.
James French
@JamesFrench30
Aug 01 2017 18:25
Can someone help me understand why I can't get the correct Stream Name to appear in my page?
Stephen James
@sjames1958gm
Aug 01 2017 18:25
@kimfucious Ah, you are registering more than one handler, so you get both quotes
James French
@JamesFrench30
Aug 01 2017 18:26
$(document).ready(function() {
  var twitchStreams = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];

  for (i = 0; i < twitchStreams.length; i++) {
    var stream = twitchStreams[i];
    var twitchUrl = "https://wind-bow.gomix.me/twitch-api/streams/" + stream + "?callback=?";

    $.getJSON(twitchUrl, function(json) {
      // console.log(json);
      var streamStatus = "";
      var html = "";

      if (json["stream"] == undefined) {
        streamStatus = "offline";
      } else {
        streamStatus = "online";
      }

      html += '<div class = "twitch"><p class ="description">' + stream + ' is ' + streamStatus + '</p></div>';

      $("div.twitchDetails").append(html);

    });
  }
});
Siphils
@Siphils
Aug 01 2017 18:26
error What should I do...
Stephen James
@sjames1958gm
Aug 01 2017 18:26
@JamesFrench30 Use let in your for loop
for (let i = 0;
Marianissimus
@Marianissimus
Aug 01 2017 18:26
@sjames1958gm why not get random when you load the page - so you don't have to wait for a second quote in order to tweet it?
Stephen James
@sjames1958gm
Aug 01 2017 18:26
@JamesFrench30 With let you get a new context in the for loop, without it you get a shared streamvariable which ends up with the last value
@Marianissimus Not me
Marianissimus
@Marianissimus
Aug 01 2017 18:27
@sjames1958gm sry
Stephen James
@sjames1958gm
Aug 01 2017 18:27
@Marianissimus np
James French
@JamesFrench30
Aug 01 2017 18:27
Hmmm added the Let but no change?
Marianissimus
@Marianissimus
Aug 01 2017 18:27
@kimfucious why not get random when you load the page - so you don't have to wait for a second quote in order to tweet it?
Stephen James
@sjames1958gm
Aug 01 2017 18:27
@kimfucious You are registering a new click handler each time you get a new quote, if you notice you get two tabs opened when you got to the second share
John
@AnonymousLords
Aug 01 2017 18:29
:point_up: July 31, 2017 10:41 PM It isn't a Myth. I know this because i am me. I cant sit down and read a book to learn code, i need to write it and see visuals.
Sergey
@zhukovsp
Aug 01 2017 18:31
@sjames1958gm Thank you for your answer! "x.arr = nArr.slice(0)" doesn't work in this case but I'll dig in this direction.
CamperBot
@camperbot
Aug 01 2017 18:31
zhukovsp sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8217 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 01 2017 18:31
@kimfucious - move this code to just below your hide() - then remove var from author/quote in the getJSON
  var author;
  var quote;
      $("#share").click(function () {
      //alert(data.quote);
      if (quote.length + author.length + 8 > 140) {
        var r = 140 - (author.length + 8);
        //alert(r * -1);
        quote = quote.slice(0, r) + '...';
      }
      window.open('https://twitter.com/intent/tweet?text="' + quote + '" ~ ' + author);
    });
@zhukovsp :+1:
KIm Ford
@kimfucious
Aug 01 2017 18:32
@sjames1958gm Hmm… I’ve got a click listener on the share button and another on the get quote button. If figured that since I put the share function within the get quote function, I could get access to it’s variables… I think that @Marianissimus has given me a clue by using share as a call back. I’ll need to look into how to do that. Thanks!
CamperBot
@camperbot
Aug 01 2017 18:32
kimfucious sends brownie points to @sjames1958gm and @marianissimus :sparkles: :thumbsup: :sparkles:
:cookie: 440 | @marianissimus |http://www.freecodecamp.com/marianissimus
:star2: 8218 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 01 2017 18:33
@kimfucious Every time you get a new quote - you add another handler to the share button.
By moving the variables and this handler outside your click new quote button it will not do that.
Marianissimus
@Marianissimus
Aug 01 2017 18:34
@kimfucious don't worry about it. either call the function into the first one, or just copy/paste its code of the 2nd function into the 1st
KIm Ford
@kimfucious
Aug 01 2017 18:34
@sjames1958gm Yes, I think I’m creating new scope each time…
FlashHero
@FlashHero
Aug 01 2017 18:40
I need help, this doesn't work without calling the this.setFirstName method and how can I make it work
var Person = function(firstAndLast) {
  this.names=firstAndLast.split(' ');
  this.name;
    this.setFirstName = function(first) {
      if(first!== undefined && first!==null){
          this.name=first;
      }else{
        this.name=this.names[0];
      }
    };
    this.getFirstName=function(){
      return this.name;
    };
};

var bob = new Person('hi hello');
bob.getFirstName();
KIm Ford
@kimfucious
Aug 01 2017 18:41
@sjames1958gm Hi Stephen, I did what you said, and that works… but I am puzzled as to how the “share” function has access to the values for the variables in the “get quote” function? Wouldn’t quote and author be private in the scope of the get quote function?
Stephen James
@sjames1958gm
Aug 01 2017 18:42
@kimfucious When you remove the var from the variables in the get quote function they access the more global variables defined above the share handler.
so the values are available to both the get quote and the share function
@FlashHero You need to set this.name just like you set this.names at the top so they are set in the object construction
KIm Ford
@kimfucious
Aug 01 2017 18:44
@sjames1958gm Aah… yes… thanks for that… this is what I was trying not to do, as I understand that this is not really a good practice (no offense). This is why I’d nested “share” into “get quote.” But I do think I need to use a call back function to do this “properly.”
CamperBot
@camperbot
Aug 01 2017 18:44
kimfucious sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: kimfucious already gave sjames1958gm points
FlashHero
@FlashHero
Aug 01 2017 18:45
@sjames1958gm sorry, i don't understand can you elaborate
Stephen James
@sjames1958gm
Aug 01 2017 18:46
@FlashHero this.name; you aren't setting this at the same time you set this.names
change the third line to this.name=this.names[0];
FlashHero
@FlashHero
Aug 01 2017 18:47
@sjames1958gm oh ok i get it thanks
CamperBot
@camperbot
Aug 01 2017 18:47
flashhero sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8219 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 01 2017 18:49
@kimfucious No offense taken. Good luck with the callback
KIm Ford
@kimfucious
Aug 01 2017 18:51
@sjames1958gm Thanks again for the help…
CamperBot
@camperbot
Aug 01 2017 18:51
kimfucious sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: kimfucious already gave sjames1958gm points
KIm Ford
@kimfucious
Aug 01 2017 18:52
@Marianissimus Hi there, I’ll sort out the quote on load after I figure out how to do the call back. Thanks for your help.
CamperBot
@camperbot
Aug 01 2017 18:52
kimfucious sends brownie points to @marianissimus :sparkles: :thumbsup: :sparkles:
:warning: kimfucious already gave marianissimus points
moshe18
@moshe18
Aug 01 2017 18:55
x
Eunice Park
@eunicode
Aug 01 2017 19:14
Okay, dumb question alert, but why isn't the Element.innerHTML property working? It's for the Weather app. I retrieved a city from an API and I'm trying to input that city into <div id="cityselector">. It's on line 25 in the JS section. (The API call works fine, so it's not that)
https://codepen.io/eunipa/pen/qXNEaP?editors=1010
Pieter Stokkink
@forkerino
Aug 01 2017 19:16
@eunipa "url" is not a valid url
The idea is to place the getJSON inside the geolocator callback
And use url instead of the string "url"
Guderian Raborg
@hypercuber
Aug 01 2017 19:23
How do I draw a rectangle in canvas again?
  this.draw = function() {
    c.beginPath();
    c.lineWidth = '5';
    c.strokeStyle = 'blue';
    c.rect(this.x, this.y, this.length, this.length);
    c.fillStyle = 'black';
    c.fill();
    c.stroke();
  }
Eunice Park
@eunicode
Aug 01 2017 19:23
@forkerino Thank you so much for answering my question! Why does the getJSON need to be inside the geolocator callback if I "return" the url?
CamperBot
@camperbot
Aug 01 2017 19:23
eunipa sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2907 | @forkerino |http://www.freecodecamp.com/forkerino
Guderian Raborg
@hypercuber
Aug 01 2017 19:23
and where do I put strokestyle and fillstyle
Pieter Stokkink
@forkerino
Aug 01 2017 19:26
@eunipa for 2 reasons. One: you don't store the return value anywhere. Two: it is an asynchronous operation, so you can't be sure the location is already determined by the time your getjson is triggered.
The only place where you are sure it has come back is in the callback
Eunice Park
@eunicode
Aug 01 2017 19:29
@forkerino Seriously thank you so much for your explanation. I think you're kinda famous around here, so I feel honored you replied :) Also, the code works after doing everything you suggested.
CamperBot
@camperbot
Aug 01 2017 19:29
eunipa sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: eunipa already gave forkerino points
Pieter Stokkink
@forkerino
Aug 01 2017 19:30
:+1:
Stephen James
@sjames1958gm
Aug 01 2017 19:31
@forkerino I like the "code works" as an afterthough :)
Pieter Stokkink
@forkerino
Aug 01 2017 19:35
Indeed!
Ronique Ricketts
@RoniqueRicketts
Aug 01 2017 19:52
I feel like I don't know what I am doing. I've worked my way to the intermediate algorithms and I have 6 left and I just feel st