These are chat archives for FreeCodeCamp/HelpJavaScript

17th
Jul 2017
Kevin
@kevinwr
Jul 17 2017 00:00
I don't know how to run my websites otherwise.
other than loading the html page directly from the explorer and doing the save and F5 dance
is that how developers normally do it? Like I've been wanting to use VS CODE, but can't figure out how to run my website
or same thing with the other editors
Stephen James
@sjames1958gm
Jul 17 2017 00:02
Does brackets render the HTML inside the editor?
Kevin
@kevinwr
Jul 17 2017 00:03
what do you mean by that?
Stephen James
@sjames1958gm
Jul 17 2017 00:04
@kevinwr does brackets open a browser to show the page, or shows the page in the editor
Kevin
@kevinwr
Jul 17 2017 00:04
opens a browser
with auto-update feature
Stephen James
@sjames1958gm
Jul 17 2017 00:05
@kevinwr Are the errors above from the browser window?
Kevin
@kevinwr
Jul 17 2017 00:05
I pulled up the devtools in brackets because I guess that's where I'm supposed to do it with brackets, but let me go to chrome
Stephen James
@sjames1958gm
Jul 17 2017 00:06
@kevinwr I believe, having no experience in brackets, that the XHR is running in chrome
Kevin
@kevinwr
Jul 17 2017 00:07
Ok. so I ran the query "Tony Hawk" through my form, and before I ran the query, it said "Failed to load resource: the server responded with a status of 404 (Not Found)", but then I pressed enter to submit the form and the error went away, but I got my message "Something went wrong..."
when I was trying to figure out why, I did alert(XHR.STATUS)
and found it's returning the status 0
God, I feel like such an idiot right now. I'm really sorry for my ignorance
image.png
//This function runs when the XHR readyState value changes. XHR.onreadystatechange = function(){ if (XHR.readyState === 4 && XHR.status === 200) { alert(XHR.responseXML); } else { // alert("Something went wrong. Please try again later"); alert(XHR.status) } }
Stephen James
@sjames1958gm
Jul 17 2017 00:11

@kevinwr The the XHR.STATUS of zero is the initial status.
The page is resetting before the XHR completes
I think that the form is submitting and refreshing the page

document.getElementById("wikiSearchForm").onsubmit = function (event) {
event.preventDefault()

This will prevent the form from submitting

Kevin
@kevinwr
Jul 17 2017 00:13
The page isn't refreshing, now, but still getting the same error
I never read about the preventDefault
that's interesting
Stephen James
@sjames1958gm
Jul 17 2017 00:14
Forms assume you have a backend to submit to. so if you are using JS with the form you generally need to use preventDefault
@kevinwr Are you seeing any thing that mentions cross origin in the chrome console?
Kevin
@kevinwr
Jul 17 2017 00:17
image.png
Stephen James
@sjames1958gm
Jul 17 2017 00:17
@kevinwr BTW, the status of 4 is not the first status you will get back from the XHR send
Kevin
@kevinwr
Jul 17 2017 00:17
also really confused about my background. The file is there, but my browser says the file isn't there, but when I use brackets live preview the background showsup
Stephen James
@sjames1958gm
Jul 17 2017 00:17
@kevinwr Ok. add the following "origin=*" to your URL
Kevin
@kevinwr
Jul 17 2017 00:18
I'mjust using what MDN said to use
or maybe it was w3SCHOOLS
one of those
Stephen James
@sjames1958gm
Jul 17 2017 00:18
api.php?origin=*&action=query add it like this before your first query parameter
It is probably something specific to brackets and file paths. Have not knowledge of how that works in brackets
Kevin
@kevinwr
Jul 17 2017 00:20
Still get the same error, but now it's alerting "null" in another alert box as well
korzo
@korzo
Jul 17 2017 00:21
@sjames1958gm @kevinwr I doubt it will work. It's missing header in response from server. And ajax request doesn't work, because wikipedia api doesn't support CORS
Long Nguyen
@longnt80
Jul 17 2017 00:21
hey guys, which book/resource is good to read about DOM API
I already tried MDN but it is not very clear/well written
Stephen James
@sjames1958gm
Jul 17 2017 00:22
@kevinwr null is because the data is in XHR.response
Kevin
@kevinwr
Jul 17 2017 00:24
ok I switched it to alert(XHR.responseText); and I get the same error, but then the final alert box shows the JSON data.
Stephen James
@sjames1958gm
Jul 17 2017 00:24
@korzo origin=* tells the API to supply the correct headers
Kevin
@kevinwr
Jul 17 2017 00:25
what are headers?
Stephen James
@sjames1958gm
Jul 17 2017 00:25
@kevinwr Those are not errors, those are different steps in the process, with different status codes.
That is why you are waiting for status of 4
@kevinwr They are part of the HTTP messages that contain information about the requests and responsees
Kevin
@kevinwr
Jul 17 2017 00:26
Yeah. Ok I guess I see what's going on
korzo
@korzo
Jul 17 2017 00:27
@sjames1958gm Sorry, you are right.
Stephen James
@sjames1958gm
Jul 17 2017 00:27
@kevinwr The error you posted above was because the response didn't have a specific header that is required
when you make an AJAX/API request from one domain to another.
@korzo They are nice that way to provide that.
Kevin
@kevinwr
Jul 17 2017 00:28
what do you mean "from one domain to another"?
I feel so fudging confused right now
Thank you for the help, @sjames1958gm I really appreciate it
CamperBot
@camperbot
Jul 17 2017 00:30
kevinwr sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8087 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 17 2017 00:30
IF you have a website www.kevinwr.com and you make a request to www.myapi.com
That is from one domain - yours to another supporting the API.
Kevin
@kevinwr
Jul 17 2017 00:31
I need to find a complete resource on AJAX and API calls...and one that doesn't confuse the hell out of me
Stephen James
@sjames1958gm
Jul 17 2017 00:32
@kevinwr You tube would be the resource I would go to - get a video explanation with examples.
BTW, you need to add format=json to your URL to make wikipedia send you json
Kevin
@kevinwr
Jul 17 2017 00:32
I didn't add that because that's the default behavior, I guess
Stephen James
@sjames1958gm
Jul 17 2017 00:33
I am getting an HTML page with HTML formatted to look like json
Kevin
@kevinwr
Jul 17 2017 00:33
yeah, you're right
UGH
Stephen James
@sjames1958gm
Jul 17 2017 00:33
Just add format=json to the URL and it will give you the json
Then the JSON (which is a string) has to be parsed to give you a js object:
var myObj = JSON.parse(XHR.response);
Try not to be discouraged. There are a lot of moving parts here, form submission, XHR, cross origin issues, json parsing, etc)
it is not surprising that you should get confused.
Kevin
@kevinwr
Jul 17 2017 00:38
still receiving the HTML code after adding that
Stephen James
@sjames1958gm
Jul 17 2017 00:38
@kevinwr Hmm, let me see the URL
Kevin
@kevinwr
Jul 17 2017 00:39
I know that the URL has some code at the top before the JSON data begins
That wikipedia adds itself
ok that one returned JSON
maybe it adds HTML in the alert?
Stephen James
@sjames1958gm
Jul 17 2017 00:42
Should be the same in both places. But now that you have the json, you should be able to work from there.
Kevin
@kevinwr
Jul 17 2017 00:45

Thank you, Stephen. Really appreciate it. Need to do more research so I can figure this stupid AJAX/API thing out. I've read so many stupid resources thus far, and it still doesn't make sense.

I also need to figure out how to run my websites, and about other development practices. It seems like webdev tools is used a lot, but I don't even know what they are. I don't know how to run my sites other than the whole live preview or by going to explorer and using refresh everytime

What do developers normally do?
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 00:47
good <time-of-day>
I'm on Map the debris and I have a question -- not about the problem itself, but I'm looking for remedial help on dealing with objects.
Can anyone point me to some help on .... how do I turn the passed parameter arr into key-value pairs and stuff?
Stephen James
@sjames1958gm
Jul 17 2017 00:51
@kevinwr There are so many ways to do it these days. I have been using cloud9 lately because you can spin up a new environment pretty quickly.
The editor is not as nice as say vscode or brackets, but you get a publicly available address (including https support).
I assume the live preview and the browser are common ways, maybe just needs some setup that you are missing.
@baseballpoetess Each element in the array is an object (your key-value pairs), this is similar to the profileLookup, just loop (or map) over the array to get each
object to be processed
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 00:52
it's one object.
an array of one object, I think.
for the first one anyway, oh, no it's the arguments object
but yeah.
Stephen James
@sjames1958gm
Jul 17 2017 00:53
@baseballpoetess One of the tests has multiple objects
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 00:53
okay, it's like profile?
gah, I had so much trouble with the record one .
Serenity
@qmikew1
Jul 17 2017 00:54
toshiro mifune :thumbsup:
Stephen James
@sjames1958gm
Jul 17 2017 00:55
@qmikew1 :)
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 00:55
okay. I live with a degreed AeroE so the orbital part doesn't bother me, it's the .... dealing with objects where I struggle.
Stephen James
@sjames1958gm
Jul 17 2017 00:55
@baseballpoetess I used .map to process the array.
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 00:56
:) That should work. I was thinking forEach but yeah.....
ty @sjames1958gm I feel less panicky now
CamperBot
@camperbot
Jul 17 2017 00:57
baseballpoetess sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8088 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 17 2017 00:57
@baseballpoetess Us fellow Texans have to help each other out.
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 00:58
:D
Long Nguyen
@longnt80
Jul 17 2017 01:04
@baseballpoetess @sjames1958gm you guys from Texas?
Stephen James
@sjames1958gm
Jul 17 2017 01:04
@longnt80 I am from N. Texas, McKinney to be exact.
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 01:05
@longnt80 not exactly. I live here now though. :D
Long Nguyen
@longnt80
Jul 17 2017 01:05
@sjames1958gm @baseballpoetess I was in Houston for 3 months about 9 years ago
I'm not from the US, btw
My brother in law is still living in Houston
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 01:08
I grew up on the Dakota prairie. I spent several years in Ohio married to my ex -- and then I got wise and kicked him to the curb.... when I wed my current Mister 26 years ago, we moved to Texas because Mister got a job here. Been here ever since. This is the nicest place, climatewise, that I've ever lived (despite Ike taking our roof)
Natalia C
@MountainGirl504
Jul 17 2017 01:11
Hi All, I'm starting DevMountain in Provo on September 25. Anyone else will be there?
Long Nguyen
@longnt80
Jul 17 2017 01:13
@baseballpoetess :thumbsup:
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 01:14
ty @longnt80
CamperBot
@camperbot
Jul 17 2017 01:14
baseballpoetess sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 445 | @longnt80 |http://www.freecodecamp.com/longnt80
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 01:21
YAYAYAY! I did it. Thank you again @sjames1958gm and if I remember in an hour, I'll do it then so you get a second sparkle.
CamperBot
@camperbot
Jul 17 2017 01:21
baseballpoetess sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: baseballpoetess already gave sjames1958gm points
Stephen James
@sjames1958gm
Jul 17 2017 01:21
@baseballpoetess Great!
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 01:24
Oh, I started a blog -- but this won't be in it because my big issue is weather.
Pagnito
@Pagnito
Jul 17 2017 01:32
ffffffck, my build build without any errors, but my react wont render to the dom
Margaret
@Margaret2
Jul 17 2017 01:35
@sjames1958gm whoa what, you're in McKinney!?
I'm in McKinney!
so weird lol :sweat_smile:
shivam gupta
@shivamg11000
Jul 17 2017 01:42
@Pagnito you want to deploy your react project
Bradley Sands
@sandsbe
Jul 17 2017 01:42
@baseballpoetess nice move on the blog. Writing about your work/learning is extremely helpful.
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 01:43
:) ty @sandsbe I'm also doing it to keep a record.
CamperBot
@camperbot
Jul 17 2017 01:43
baseballpoetess sends brownie points to @sandsbe :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @sandsbe |http://www.freecodecamp.com/sandsbe
Pagnito
@Pagnito
Jul 17 2017 01:44
@shivamg11000 im trying to render a simple hello for now, im still learning setting up the environment
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 01:45
dayum, I loathe these mathy challenges because they're slippery.
Pagnito
@Pagnito
Jul 17 2017 01:45
@shivamg11000 its building witohut any errors but wont render the <p>hello</p> into my <div id='app'></div>
Bradley Sands
@sandsbe
Jul 17 2017 01:46
Getting functions to fire in the right order is exploding my brain!
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 01:46
I thought I understood Pairwise but not at all. how do you get 1 from [1, 1, 1], 2 ?
Bradley Sands
@sandsbe
Jul 17 2017 01:46
window.onload = function() {
  navigator.geolocation.getCurrentPosition(getMyLocation);
  getWeather();
  displayData();
};
Stephen James
@sjames1958gm
Jul 17 2017 01:46
@Margaret2 lol - didn't think there were any others out here in the burbs
Pagnito
@Pagnito
Jul 17 2017 01:46
also when i try to render the component my image stops showin up in dom as well
let me know if u wanna look at the code
Bradley Sands
@sandsbe
Jul 17 2017 01:47
Should I make my three functions async? (did I state that Q right?). In the Weather app exercise, my displayData() function is beating my getWeather() to the punch.
Veronica Eulenberg
@HappyViki
Jul 17 2017 01:47
@HappyViki
I have an advanced JS question
Why does it print out 6 ababa’s instead of 12?
function perm(a, b, c) {
  return (a *= c + 1);
}

function permutations(letters, permNum) {
  var arr = [];
  var n1 = 0;
  var n2 = 1;
  for (var i = 1; i <= permNum; i++) {
    if (n1 === letters.length) n1 = 0;
    if (n2 > letters.length - 1) n2 = 0;
    var x = letters[n1];
    var y = letters[n2];
    letters[n1] = y;
    letters[n2] = x;

    arr.push(letters.join(""));
    n1++;
    n2++;
  }
  return arr;
}

// HELP HERE
function z(a, b, c, d) {
  for (var i = 0; i < b.length; i++) {
    if (b[i] === b[i - 1] && b[i] !== undefined && b[i-1] !== undefined){
      return a.concat();
    }
  }
  console.log(b)
  return a.concat(b);
}
// END HELP

function permAlone(str) {
  var letters = str.split("");
  var permNum = letters.reduce(perm, 1);
  var permutation = permutations(letters, permNum);
  var alone = permutation.reduce(z, []);
  return alone.length;
}
console.log("1", permAlone("aaabb"));
Bradley Sands
@sandsbe
Jul 17 2017 01:56
Anyone have a good asyn function example/tutorial besides MDN and Beau (https://www.youtube.com/watch?v=IGYxfTTpoFg)?
Guderian Raborg
@hypercuber
Jul 17 2017 01:59
Can someone help me make a prototype to rotate an array counter clockwise and j and i can be different values?
Array.prototype.cc = function() {
  let newArr = [];
  for (let i = this[0].length - 1; i >= 0; i--) { //TR corner
    newArr[i] = [];
    for (let j = 0; j < this.length; j++) {
      newArr[i][j] = this[i][j];
    }
  }
  return newArr;
}
Bradley Sands
@sandsbe
Jul 17 2017 02:02
@HappyViki that was hands down the hardest challenge IMO. It doesn't look like you'r using Heap's algo. I tried some original thinking for DAYS and was only able to have an algo solve for half of the answers. Stick with Heap, it does work.
Veronica Eulenberg
@HappyViki
Jul 17 2017 02:05
@sandsbe my thing solves all but 2 :(
shivam gupta
@shivamg11000
Jul 17 2017 02:05
@Pagnito code saved on local machine or hosted on github, send the files
Veronica Eulenberg
@HappyViki
Jul 17 2017 02:07
@sandsbe I thought I was using that algorythm. Why do most work though?
Bradley Sands
@sandsbe
Jul 17 2017 02:08
Wow, that is super close.
The Heap's algo from Wikipedia and the Heap's algo in JS are very very similar. Yours looks a little different. https://en.wikipedia.org/wiki/Heap%27s_algorithm
Veronica Eulenberg
@HappyViki
Jul 17 2017 02:08
ikr!!?? I wanna know what the problem is with my code :(
@sandsbe I don’t know how to translate wiki’s thing to js :(
Bradley Sands
@sandsbe
Jul 17 2017 02:09
Does it run in www.pythontutor.com?
https://github.com/sandsbe/free-Code-Camp/blob/master/No-repeats-please.js if you want to see an answer that worked. I have it fairly commented. Point being, the internet got me over the hump, I did NOT uniquely figure it out.
Veronica Eulenberg
@HappyViki
Jul 17 2017 02:13
I figured mine out myself :P Thanks for the link! @sandsbe
CamperBot
@camperbot
Jul 17 2017 02:13
happyviki sends brownie points to @sandsbe :sparkles: :thumbsup: :sparkles:
:cookie: 307 | @sandsbe |http://www.freecodecamp.com/sandsbe
Pagnito
@Pagnito
Jul 17 2017 02:13
@shivamg11000 its on my machine
Bradley Sands
@sandsbe
Jul 17 2017 02:13
You got the original to work? Congrats. That's huge.
Pagnito
@Pagnito
Jul 17 2017 02:14
@shivamg11000 how can i send u the files?
@shivamg11000 email?
Veronica Eulenberg
@HappyViki
Jul 17 2017 02:14
@sandsbe nah not yet. I want to see what the diference is between yours and mine and see what I can tweek to make mine work.
Bradley Sands
@sandsbe
Jul 17 2017 02:14
I'm about to fork this damn this and make it work but if someone could take a look and point me in the direction to make the functions asynch that'd be hue.
Just want my displayData() function to go last
Gulsvi
@gulsvi
Jul 17 2017 02:44
@sandsbe Call the functions you need when you have the data for them.
For example, add getWeather(requestURL); to the end of your getMyLcoation(position) function
Then change your getWeather() function to take a requestURL argument: function getWeather(requestURL) {
At the end of your ajax success function, display the data: displayData();
Bradley Sands
@sandsbe
Jul 17 2017 02:48
@SkyC0der exactly what I'm trying to do is "call the functions I need when I have the data". SO, you're saying the getWeather() won't "fire" until I have the data if I set up the 'requestURL' as the argument?
Gulsvi
@gulsvi
Jul 17 2017 02:49
@sandsbe getWeather() will fire, but it won't have requestURL defined
That variable is built in getMyLocation(), so at the end of that function, call your getWeather() function, but send the URL over with it
get location -> get weather + location details -> show weather + location details
Bradley Sands
@sandsbe
Jul 17 2017 02:53
Ok, need to find the fork with this most ready to go. Brb. ty @SkyC0der
CamperBot
@camperbot
Jul 17 2017 02:53
sandsbe sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2127 | @skyc0der |http://www.freecodecamp.com/skyc0der
Nick Janne
@njanne19
Jul 17 2017 02:54
Can someone help me understand that why my map method in my Cell component doesn't render the div cells in my program? https://codepen.io/njanne19/pen/WOPVZj
randomppl
@randomppl
Jul 17 2017 03:05
Hello, i have a question about flash game ,it can be made on js too ?
Bradley Sands
@sandsbe
Jul 17 2017 03:06
@SkyC0der , I have tried a bunch of different iterations but your suggestion worked. Is this "timing" thing I'm dealing with common? Is this like CSS where sometimes you write it "correctly", and then spend a bunch of time adjusting it to get it to work?
RakeshNerkar
@Rakesh18754
Jul 17 2017 03:17
is this mul(2)(3)(4) type of method called as a curry in Javascript?
kumquatfelafel
@kumquatfelafel
Jul 17 2017 04:11
@Rakesh18754 It is either an example of currying or an error waiting to be thrown, depending on what the mul function looks like. :p ;)
kumquatfelafel
@kumquatfelafel
Jul 17 2017 04:18
(yes)
Veronica Eulenberg
@HappyViki
Jul 17 2017 04:19
@sandsbe I can’t understand your code enough to change my code to make it work :(
kumquatfelafel
@kumquatfelafel
Jul 17 2017 04:20
@HappyViki can take a look at your cod if want, but slightly sloshed at the moment so can't guarantee anything :laughing:
Veronica Eulenberg
@HappyViki
Jul 17 2017 04:20
@sandsbe I’ll try to reformat your code until I understand it.
@kumquatfelafel Haha here’s what I’ve written:
function perm(a, b, c) {
  return (a *= c + 1);
}

function permutations(letters, permNum) {
  var arr = [];
  var n1 = 0;
  var n2 = 1;
  for (var i = 1; i <= permNum; i++) {
    console.log(letters.join("").match(/ababa/))
    if (n1 === letters.length) n1 = 0;
    if (n2 > letters.length - 1) n2 = 0;
    var x = letters[n1];
    var y = letters[n2];
    letters[n1] = y;
    letters[n2] = x;

    arr.push(letters.join(""));
    n1++;
    n2++;
  }
  return arr;
}

// HELP HERE
function z(a, b, c, d) {
  for (var i = 0; i < b.length; i++) {
    if (b[i] === b[i - 1] && b[i] !== undefined && b[i-1] !== undefined){
      return a.concat();
    }
  }
  console.log(b)
  return a.concat(b);
}
// END HELP

function permAloneVe(str) {
  var letters = str.split("");
  var permNum = letters.reduce(perm, 1);
  var permutation = permutations(letters, permNum);
  var alone = permutation.reduce(z, []);
console.log(alone.length);
  return alone.length;
}
console.log(permAlone("aaabb"));
kumquatfelafel
@kumquatfelafel
Jul 17 2017 04:21
I... would edit my last comment, but I just really want to see fish.
Veronica Eulenberg
@HappyViki
Jul 17 2017 04:22
@kumquatfelafel It’s supposed to log 12 instead of 6
You want to see fish? What does that mean?
kumquatfelafel
@kumquatfelafel
Jul 17 2017 04:22
@HappyViki misspelled code as cod
Veronica Eulenberg
@HappyViki
Jul 17 2017 04:23
oh right
kumquatfelafel
@kumquatfelafel
Jul 17 2017 04:23
@HappyViki was this FCC challenge? seems familiar but can't find it.
Veronica Eulenberg
@HappyViki
Jul 17 2017 04:23
@kumquatfelafel Advanced challenge in front end: No repeats please
kumquatfelafel
@kumquatfelafel
Jul 17 2017 04:24
ahhh
Veronica Eulenberg
@HappyViki
Jul 17 2017 04:28
@kumquatfelafel Is that an I think I know how to fix this ahhh?
kumquatfelafel
@kumquatfelafel
Jul 17 2017 04:28
still reading I'm afraid :p
console.log(permAlone("aaabb"));
Is this supposed to be permAloneVe or is not full code?
Veronica Eulenberg
@HappyViki
Jul 17 2017 04:35
@kumquatfelafel Yeh…console.log(permAloneVe("aaabb")); I was editing stuff and forgot to change back some things before submitting this here.
kumquatfelafel
@kumquatfelafel
Jul 17 2017 04:41

okay... so let's think of this in terms of 1, 2, 3 , 4, and 5 instead of a and b for a moment, since this is driving me insane.... a's can be 1, 2 and 3. b's can be 4 and 5.

14253
15243
14352
15342

okay... so 4 for each different a in starting position.

So 12 makes sense.

kumquatfelafel
@kumquatfelafel
Jul 17 2017 04:46
Thus yours appears not counting half, at least for this one. 3600 one works fine. 2640 one returns 3600 so no... 8 works fine. and so on... so approximately half the cases seem to work.
ooh... interesting.
@HappyViki Okay, so entering "ababa" instead of "aaabb" gives me 24.
Bradley Sands
@sandsbe
Jul 17 2017 04:50
@HappyViki I barely understand it. It took many many close readings of the Wiki and many other online sources to "understand" it at that time. Brain is too deep into async issues to think about perms.
Veronica Eulenberg
@HappyViki
Jul 17 2017 04:50
@kumquatfelafel :O
@sandsbe I want to just copy and paste your thing…but that would be cheating.
kumquatfelafel
@kumquatfelafel
Jul 17 2017 04:53
So the order of letters appears to alter results... question at this point is what's actually going on. I'm a bit too drunk to tell from just looking at code.
...
Let me alter your code a bit so instead of letters, we're actually passing key value pairs. :laughing:
actually, I might be too drunk for that too, but worth a shot. Well maybe not a shot...
Veronica Eulenberg
@HappyViki
Jul 17 2017 04:54
lol
worth a shot ;)
Kamal
@kpbro
Jul 17 2017 04:55
i have a question in local weather challenge
shivam gupta
@shivamg11000
Jul 17 2017 04:55
@kpbro yeah
M-C-Haker
@M-C-Haker
Jul 17 2017 04:56

why am i not looping?
```function rot13(str) { // LBH QVQ VG!

for (i = 0; i < str.length; i++) {
var coded = str.charCodeAt(i);
return String.fromCharCode(coded - 13);
}
}```

Kamal
@kpbro
Jul 17 2017 04:56
can i put a single button for C to F and F to C both conversion?
kumquatfelafel
@kumquatfelafel
Jul 17 2017 04:56
@M-C-Haker return statement in for loop.
M-C-Haker
@M-C-Haker
Jul 17 2017 04:57
@kumquatfelafel says it's being used out of scope when i take it past the next bracket..
Nick Janne
@njanne19
Jul 17 2017 04:57
@M-C-Haker You first need to declare i as var inside your loop statement, you also can't return in a for loop because it will only go through one iteration
@kpbro Yes you could have it in such a way where when you click an F it turns into a C and the temperature converts
M-C-Haker
@M-C-Haker
Jul 17 2017 04:58
@njanne19 i = 0 is the same as var i = 0 when you are initiating the loop from what i understand
Nick Janne
@njanne19
Jul 17 2017 05:00

@M-C-Haker It's not exactly the same

for (i = 0; i<10; i++)

will not work because you haven't defined i yet, and so therefore, you'll likely get an error message saying i is undefined
however if instead of i=0 you had var i = 0; or let i = 0 then it would work

Kamal
@kpbro
Jul 17 2017 05:00
@njanne19 how can i create same button for that?
Nick Janne
@njanne19
Jul 17 2017 05:00
@kpbro Well on the weather project I'm pretty sure you're using jquery so you could have a jquery function that changes the text value of F to C and C to F
and then likewise the conversion for the temperature
Veronica Eulenberg
@HappyViki
Jul 17 2017 05:01
@kumquatfelafel Yeaah, it doesn’t make sense. Why would it return twice as much if the thing is set, and half if it isn’t…wtf?
Kamal
@kpbro
Jul 17 2017 05:02
ok i will try
Ogundele Olumide
@Lumexralph
Jul 17 2017 05:02
@njanne19 i = 0 will work in non-strict mode but would not in strict mode
Nick Janne
@njanne19
Jul 17 2017 05:03
@kpbro see some documentation on .val()
@Lumexralph Strict mode? Are you talking about on FCC or what
Common practice is declaring it as a variable using var or let like if you plan to go farther you should get used to that
Ogundele Olumide
@Lumexralph
Jul 17 2017 05:04
@njanne19 in-non strict mode, i will be a global variable
M-C-Haker
@M-C-Haker
Jul 17 2017 05:04
@njanne19 it does work, and i've done all the algorithms thus far without defining i using a variable, but it appears that best practice says you should. So you are correct, it should be but that's not what is causing my issue. I thought i'd share : https://stackoverflow.com/questions/5717126/var-or-no-var-in-javascripts-for-in-loop
Nick Janne
@njanne19
Jul 17 2017 05:04
That's not exactly good practice when you move farther into javascript or other programming languages
Ogundele Olumide
@Lumexralph
Jul 17 2017 05:05
@njanne19 no argument about avoiding globals as much as possible, but if you make a code this way for (i = 0; i<10; i++) it'll work but I won't suggest it and it's not a good idea
Nick Janne
@njanne19
Jul 17 2017 05:05
@M-C-Haker @Lumexralph I see what you're both saying. I think your other issue was the return statement in your loop @M-C-Haker
M-C-Haker
@M-C-Haker
Jul 17 2017 05:06
@njanne19 yes, correct and when i move it out of the loop then my local variable is out of scope creating a gobal variable that i can refer to and it should work. fingers crossed @njanne19
Nick Janne
@njanne19
Jul 17 2017 05:06
Best of luck!
Ogundele Olumide
@Lumexralph
Jul 17 2017 05:06
@njanne19 i'm getting used to writing my code in strict mode , it doesn't allow such and helps with debugging too
@M-C-Haker yes, that's why you should avoid globals as much as possible, side-effects might not be cool for the program in the long run
@M-C-Haker and that's where I'll agree with @njanne19
kumquatfelafel
@kumquatfelafel
Jul 17 2017 05:09
@HappyViki well... it's looking like the problem arises even earlier than z. Looking at the elements in permutation, ababa appears only 6 times when use "aaabb" but 24ish(haven't legitimately counted) when use "ababa".
abraham anak agung
@padunk
Jul 17 2017 05:09

Hello, could i ask for some explanation?

Array.prototype.decimalfy = function() {
  for (let i = 0; i < this.length; i++) {
    this[i] = this[i].toFixed(2);
  }
};

const digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

for (const index in digits) {
  console.log(digits[index]);
}

why is the function print out? it don't ever belong to const digits anyway.

M-C-Haker
@M-C-Haker
Jul 17 2017 05:09
@Lumexralph
kumquatfelafel
@kumquatfelafel
Jul 17 2017 05:09
@HappyViki so z itself could actually be doing what it's supposed to.
M-C-Haker
@M-C-Haker
Jul 17 2017 05:10

function rot13(str) { // LBH QVQ VG!
   var decoded = "";
   for (var i = 0; i < str.length; i++) {
    var coded = str.charCodeAt(i);
    decoded = coded - 13;
   }
     return String.fromCharCode(decoded);
 }


// Change the inputs below to test
rot13("SERR PBQR PNZC");
now i'm not even getting the correct first letter. getting '6'
Veronica Eulenberg
@HappyViki
Jul 17 2017 05:11
@kumquatfelafel then what is wrong with my code? :(
abraham anak agung
@padunk
Jul 17 2017 05:11
@M-C-Haker you are not joining it. it return the last character. and remember space is still space
shivam gupta
@shivamg11000
Jul 17 2017 05:13
well why this.refs is giving empty object in this
https://codepen.io/hesmaili95/pen/wGzodM?editors=0010
kumquatfelafel
@kumquatfelafel
Jul 17 2017 05:14
@HappyViki Well, either your permutations function or related piece of permAloneVe
Veronica Eulenberg
@HappyViki
Jul 17 2017 05:15
@kumquatfelafel thanks for debugging for me :) I’m tired. I’ll work on this tomorrow. It’s time for this coder to netflix and sleep :P
CamperBot
@camperbot
Jul 17 2017 05:15
happyviki sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 478 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
kumquatfelafel
@kumquatfelafel
Jul 17 2017 05:16
@HappyViki and, permNum is fine... split shouldn't cause problems either. so your problem appears to be in permutations.
np. night.
Veronica Eulenberg
@HappyViki
Jul 17 2017 05:17
kay
Quinn Vinlove
@quin2
Jul 17 2017 05:17
Caeser's cipher is being weird for me
I'm pulling char codes out of the string and getting weird control characters
or the wrong letter
kumquatfelafel
@kumquatfelafel
Jul 17 2017 05:18
@quin2 post code :)
Quinn Vinlove
@quin2
Jul 17 2017 05:19
'''
CamperBot
@camperbot
Jul 17 2017 05:19
:bulb: to format code use backticks! ``` more info
Quinn Vinlove
@quin2
Jul 17 2017 05:19

```function rot13(str) { // LBH QVQ VG!
var result;

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

if(code >= 30) code += 13;
result += String.fromCharCode(code);

}

return result;
}```

kumquatfelafel
@kumquatfelafel
Jul 17 2017 05:20

@quin2 http://www.asciitable.com

30 is "record separator"

Quinn Vinlove
@quin2
Jul 17 2017 05:20
format isn't working haha
so it's ASCII an not UTF-8?
still isn't close to working :(
kumquatfelafel
@kumquatfelafel
Jul 17 2017 05:24

basically at moment, you're saying "for any character after group separator, add 13"

You want "for any character between A and Z, do ... something"
:point_down: this too

abraham anak agung
@padunk
Jul 17 2017 05:24
@quin2 you need to declare you var result as var result = '' first and then loop it per instructions
Quinn Vinlove
@quin2
Jul 17 2017 05:25
@padunk that's part of it...
kumquatfelafel
@kumquatfelafel
Jul 17 2017 05:28
@quin2 so something else to consider, if we add 13 to Z (90), we get g(103). Is this the value we want?
Kamal
@kpbro
Jul 17 2017 05:30
i want to change button text C to F when i click the button. But it is not working
<script>
$(document).ready(function(){
   // $("button").click(function(){
    if($("button").text() == "°C"){

    $("button").click(function(){
        $("button").text("°F"); 
         }

   });
});
</script>
need help
kumquatfelafel
@kumquatfelafel
Jul 17 2017 05:32
@kpbro what this basically does is it only defines the click function as such if button text is C. Otherwise, it will just be the default click response and there is no way of changing it. It's better to set it up so that when the button registers the click, depending on the text or some other value, it will change to the other.
Kamal
@kpbro
Jul 17 2017 05:36
<script>
$(document).ready(function(){
   // $("button").click(function(){
    if($("button").text() == "°C"){
     $("button").click(function(){
        $("button").text("°F"); 
         });
      }
});
</script>
i did this and now this is working. @kumquatfelafel
Stanley Su
@stanley-su
Jul 17 2017 05:36
@kpbro You shouldn’t do it this way. You should add an event listener to the button. When the button is clicked, you check the button’s value. If it’s currently ‘C’, change it to ‘F', else, change it to ‘C’.
Kamal
@kpbro
Jul 17 2017 05:37
@stanley-su How>
?
Stanley Su
@stanley-su
Jul 17 2017 05:37
@kpbro Add an event listener to the button for when it’s clicked. Read my previous message
Kamal
@kpbro
Jul 17 2017 05:38
@stanley-su i mean how can i add event listener?
so i can see about it on documentation
kumquatfelafel
@kumquatfelafel
Jul 17 2017 05:39
Agreed with @stanley-su
Stanley Su
@stanley-su
Jul 17 2017 05:41
@kpbro
let button = $(‘button’);
button.on(‘click’, /*your code here*/);
@kpbro It’s better to save every reference to a dom element rather than having jquery search it up everytime you want to do something with the element. This is called caching
Kamal
@kpbro
Jul 17 2017 05:42
@stanley-su got it. i thought button.on('click', ....) works same as $("button").click(function(){
Stanley Su
@stanley-su
Jul 17 2017 05:43
@kpbro They do work the same, I just prefer using on
Kamal
@kpbro
Jul 17 2017 05:43
ok
lemme try
@stanley-su listening to event wis better. i did it.
$(document).ready(function(){
    $("button").click(function(){
    if($("button").text() == "°C"){
     //$("button").click(function(){
        $("button").text("°F"); 
         }
         else{$("button").text("°C")}
      });

});
it is working both ways. C to F and F to C
kumquatfelafel
@kumquatfelafel
Jul 17 2017 05:45
:+1:
Stanley Su
@stanley-su
Jul 17 2017 05:45
@kpbro YES! That’s good
Kamal
@kpbro
Jul 17 2017 05:45
@stanley-su @kumquatfelafel thanks
CamperBot
@camperbot
Jul 17 2017 05:45
kpbro sends brownie points to @stanley-su and @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 31 | @stanley-su |http://www.freecodecamp.com/stanley-su
:cookie: 479 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
Ayush Bahuguna
@relentless-coder
Jul 17 2017 05:56

Hi, I need help with Promises

function returnMeetings(query) {
    console.log(query);
    return new Promise((reject, resolve) => {
        Meeting.find(query, (err, foundMeetings) => {
            if (err) {
                console.log(err);
                return reject(err)
            }
            return resolve(foundMeetings);
        })
    })
}

so this is the function

and this is how I am using it

returnMeetings(query).then((data) => {
        while (count < stopAt) {
            let localData = [];
            if (req.params.duration === 'monthly') {
                let {
                    date1,
                    date2
                } = twoDates(count, count);
                localData = data.filter((el) => {
                    let localDate = new Date(el.startDate);
                    if (localDate >= date1 && localDate <= date2) {
                        return el;
                    }
                })
                data.push({
                    data: localData,
                    month: count
                })
                if(count === stopAt - 1){
                    myEmitter.emit('found all meetings')
                } else {
                    count++;
                }
            }
        }
    }).catch((err)=>{
        res.status(500).json({message: err})
    })

but it always fall to the catch block.

Manish Giri
@Manish-Giri
Jul 17 2017 06:01
@relentless-coder try this
 return new Promise((reject, resolve) => {
        return Meeting.find(query, (err, foundMeetings) => {
            if (err) {
                console.log(err);
                reject(err)
            }
            resolve(foundMeetings);
        })
    })
M-C-Haker
@M-C-Haker
Jul 17 2017 06:01

function rot13(str) { // LBH QVQ VG!
  var decipher = null;
  for (var i = 0; i < str.length; i++) {
    var cipher = str.charCodeAt[i];
    return String.fromCharCode(cipher);
     }
  }


// Change the inputs below to test
rot13("SERR PBQR PNZC");
I am stuck i'm just trying to return the cipher to see if there's anything there at this point and all i'm getting is a red dot no matter what i do... any tips?
kumquatfelafel
@kumquatfelafel
Jul 17 2017 06:03
for (i = 0; i<10; i++)
@njanne19 This depends, actually. If you have'use strict', then yes, it will give you an error. However, if you don't, then it will make i a global variable. Which is potentially dangerous, but not in and of itself code breaking.
M-C-Haker
@M-C-Haker
Jul 17 2017 06:04

function rot13(str) { // LBH QVQ VG!
  var decipher = null;
  for (var i = 0; i < str.length; i++) {
    var cipher = str.charCodeAt[i];
    decipher = String.fromCharCode(decipher);

     }
   return decipher;
  }


// Change the inputs below to test
rot13("SERR PBQR PNZC");
seems like this should work but i'm getting nowhere
kumquatfelafel
@kumquatfelafel
Jul 17 2017 06:05
@M-C-Haker what is String.fromCharCode(null) supposed to do?
Ayush Bahuguna
@relentless-coder
Jul 17 2017 06:05
@Manish-Giri that didn't work
M-C-Haker
@M-C-Haker
Jul 17 2017 06:05
supposed to be decipher = String.fromCharCode(cipher); i changed it
still nothing @kumquatfelafel
kumquatfelafel
@kumquatfelafel
Jul 17 2017 06:06
@M-C-Haker yeah, because you're overwriting decipher in each iteration. You're also not actually modifying the character in any way at moment.
M-C-Haker
@M-C-Haker
Jul 17 2017 06:08
@kumquatfelafel right i forgot my - 13.. i was kind of frustrated and trying to get it to display the cipher for some indication i was heading in the right direction
kumquatfelafel
@kumquatfelafel
Jul 17 2017 06:08
var a = 5;
var b = 0;
for (var i = 0; i < 10; i++) {
    a = i;
    b += i;
}
At the end of this for loop, a will be 9.
b, on the other hand will be 0 + 1 + 2 + 3 ... + 8 + 9
M-C-Haker
@M-C-Haker
Jul 17 2017 06:10
@kumquatfelafel ok i understand that
just not sure what to do with it tbh
Pieter Stokkink
@forkerino
Jul 17 2017 06:15
@M-C-Haker .charCodeAt is a method, use ()
kumquatfelafel
@kumquatfelafel
Jul 17 2017 06:15
@forkerino good catch
M-C-Haker
@M-C-Haker
Jul 17 2017 06:15
@forkerino holy shit thank you
CamperBot
@camperbot
Jul 17 2017 06:15
m-c-haker sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2860 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jul 17 2017 06:16
:+1:
Ayush Bahuguna
@relentless-coder
Jul 17 2017 06:19
@forkerino hey can you help me with promises? It always throws an error

Hi, I need help with Promises

function returnMeetings(query) {
    console.log(query);
    return new Promise((reject, resolve) => {
        Meeting.find(query, (err, foundMeetings) => {
            if (err) {
                console.log(err);
                return reject(err)
            }
            return resolve(foundMeetings);
        })
    })
}

so this is the function

and this is how I am using it

returnMeetings(query).then((data) => {
        while (count < stopAt) {
            let localData = [];
            if (req.params.duration === 'monthly') {
                let {
                    date1,
                    date2
                } = twoDates(count, count);
                localData = data.filter((el) => {
                    let localDate = new Date(el.startDate);
                    if (localDate >= date1 && localDate <= date2) {
                        return el;
                    }
                })
                data.push({
                    data: localData,
                    month: count
                })
                if(count === stopAt - 1){
                    myEmitter.emit('found all meetings')
                } else {
                    count++;
                }
            }
        }
    }).catch((err)=>{
        res.status(500).json({message: err})
    })

but it always fall to the catch block.

Saahil Trivedi
@saahil777
Jul 17 2017 06:20
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a < 0 || b < 0);
  {
  return undefined;
  }

  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);
Challenge: Return Early Pattern for Functions.
why doesn't this work?
Manish Giri
@Manish-Giri
Jul 17 2017 06:21
@saahil777 remove ;
after if()
Saahil Trivedi
@saahil777
Jul 17 2017 06:23
@Manish-Giri thanks! that was stupid :laughing:
CamperBot
@camperbot
Jul 17 2017 06:23
saahil777 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6271 | @manish-giri |http://www.freecodecamp.com/manish-giri
Pieter Stokkink
@forkerino
Jul 17 2017 06:23
@relentless-coder I'm on my phone in the train and can only answer simple questions at the moment.
Manish Giri
@Manish-Giri
Jul 17 2017 06:23
:+1:
Ayush Bahuguna
@relentless-coder
Jul 17 2017 06:25
okay. could you think of scenarios in which the promise would always fall to the catch block? even though there is no error? @forkerino
Pieter Stokkink
@forkerino
Jul 17 2017 06:28
@relentless-coder did you already try @Manish-Giri s suggestion?
Ayush Bahuguna
@relentless-coder
Jul 17 2017 06:29
yes
I tried that too, although I can't figure how would that be a problem, since the the resolve takes care of returning the value, but anyways, it didn't help.
kumquatfelafel
@kumquatfelafel
Jul 17 2017 06:31

just not sure what to do with it tbh

So to build things with legos, you need more than one block, and you need a way to connect the blocks together.

This...

for ...
   decipher = String.fromCharCode(decipher);

is like if you take a block, then throw it away and take another block, then throw it away and take another block, then throw it away and take... over and over again (suppose we can only hold one lego "structure" in our hand at any time). At the end, you've got one lego in your hand, and a bunch of legos in the trash. If you want a more sophisticated/meaningful lego "structure", you need to do something here in order to actually connect your legos (characters in string), so that you don't have to keep throwing legos away.

Ayush Bahuguna
@relentless-coder
Jul 17 2017 06:31
also, with the help of console.log() I was able to find out that the the promise doesn't throw the error, but it still falls to the catch block
@forkerino @Manish-Giri
Pieter Stokkink
@forkerino
Jul 17 2017 06:32
@relentless-coder my train is here. Gotta go. Look at the console. I might be able to help later....
Ayush Bahuguna
@relentless-coder
Jul 17 2017 06:32
okay
Pieter Stokkink
@forkerino
Jul 17 2017 06:33
And what is the json that coms out?
Ayush Bahuguna
@relentless-coder
Jul 17 2017 06:35
function returnMeetings(query) {
    return new Promise((reject, resolve) => {
       return Meeting.find(query, (err, foundMeetings) => {
            if (err) {
                return reject(err)
            }
            console.log(`The resolved meetings are ${foundMeetings}`)
            return resolve(foundMeetings);
        })
    })
}
So, I placed the console.log after checking for the error, and it logged valid values, but then it still falls to catch block
Pieter Stokkink
@forkerino
Jul 17 2017 06:40
@relentless-coder there must be an error in your .then
kumquatfelafel
@kumquatfelafel
Jul 17 2017 06:40

@relentless-coder if you place console.log('Lemons are tasty') inside

if (err) {
  return reject(err);
}

does it pop up in console?

Can someone take a look at it? Don't know why console return undefined
Ayush Bahuguna
@relentless-coder
Jul 17 2017 06:43
@kumquatfelafel no it doesn't
Stanley Su
@stanley-su
Jul 17 2017 06:45
@MCTwoDigitZero I think it’s line 31, where you’re console.logging data.error
CallMeOrange
@EgnaroDev
Jul 17 2017 06:45
oh yeah
Ayush Bahuguna
@relentless-coder
Jul 17 2017 06:45

@forkerino how? none of the code inside the .then chain run

@relentless-coder there must be an error in your .then

CallMeOrange
@EgnaroDev
Jul 17 2017 06:46
error doesn't exist in stream...
@stanley-su thanks
CamperBot
@camperbot
Jul 17 2017 06:46
mctwodigitzero sends brownie points to @stanley-su :sparkles: :thumbsup: :sparkles:
:cookie: 33 | @stanley-su |http://www.freecodecamp.com/stanley-su
kumquatfelafel
@kumquatfelafel
Jul 17 2017 06:48
@relentless-coder remove catch? What is stack trace when you just let it fail
Pieter Stokkink
@forkerino
Jul 17 2017 06:48
@relentless-coder how are you sure about that? It will go to the catch if there is an error in the .then as well...
ParadoxStephen
@StephenLover
Jul 17 2017 06:49
Can someone help me to take a look at it?I am trying to find the longest word in a string,but the weird thing happened.The outcome always is "0"

function findLongestWord(str) {
// 请把你的代码写在这里
var arrayOfStr = str.split("");
var lengthOfCurrentWord = 0;
var lengthOfMaximunWord = 0;
var i = 0;
//console.log(arrayOfStr.length);
while(i <= arrayOfStr.length -1 ){
lengthOfCurrentWord = arrayOfStr[i];
if(lengthOfCurrentWord > lengthOfMaximunWord){
lengthOfMaximunWord = lengthOfCurrentWord;
}
i++;
}
return lengthOfMaximunWord;
}

findLongestWord("The quick brown fox jumped over the lazy dog");

M-C-Haker
@M-C-Haker
Jul 17 2017 06:51
man i am close but still having trouble with my loop... anyone?

function rot13(str) { // LBH QVQ VG!

  for (var i = 0; i < str.length; i++) {
   var dc = str.charCodeAt(i);
   if (dc < 65 || dc > 90) {
     return String.fromCharCode(dc);
   }
    else if (dc < 78) {
      return String.fromCharCode(dc + 13);
    }
    return String.fromCharCode(dc - 13);
  }
} 

// Change the inputs below to test
rot13("SERR PBQR PNZC");
ParadoxStephen
@StephenLover
Jul 17 2017 06:51
or how can i get the screenshot from my code?
kumquatfelafel
@kumquatfelafel
Jul 17 2017 06:51
@M-C-Haker You're returning a single character, not the entire string.
M-C-Haker
@M-C-Haker
Jul 17 2017 06:52
still only getting the first letter converted. If i change i to the element index via 1, 2, 3 etc.. it will give me the right thing
@kumquatfelafel right, that's my problem
Ayush Bahuguna
@relentless-coder
Jul 17 2017 06:53
@kumquatfelafel it gives unhandled rejection warning and dumps the data in the console
M-C-Haker
@M-C-Haker
Jul 17 2017 06:54
@kumquatfelafel i'm looking for a place to add a += or ++ but i'm not getting anywhere
Ayush Bahuguna
@relentless-coder
Jul 17 2017 06:54
@forkerino okay, I didn't know about that.
kumquatfelafel
@kumquatfelafel
Jul 17 2017 06:55
scroll up a little bit. You had the right idea with having a "decipher" variable that was visible and returnable outside for loop. But you were using a plain ol' assignment operator, which is a no-no.
@M-C-Haker Say I have two strings, "Hello " and "world". How can I get "Hello world" from these two strings?
M-C-Haker
@M-C-Haker
Jul 17 2017 06:56
string 1 + string 2
kumquatfelafel
@kumquatfelafel
Jul 17 2017 06:57
@M-C-Haker Now say I want that result in a variable hello. How would I put that value into hello?
M-C-Haker
@M-C-Haker
Jul 17 2017 06:58
var hello = "" + "";
kumquatfelafel
@kumquatfelafel
Jul 17 2017 07:01

More or less...
hello = "Hello " + "world";

Now, let's suppose hello already holds the value "Hello " (assume we've initialized it earlier in code). Could we instead say hello = hello + "world"; ?

M-C-Haker
@M-C-Haker
Jul 17 2017 07:03
yeah for sure
kumquatfelafel
@kumquatfelafel
Jul 17 2017 07:05

So from here, let's suppose we have a for loop.

var hello = "Hello ";
for (var i = 0; i < 3; i++) {
  hello = hello + "world ";
}
console.log(hello);

What would show up in console?

fdemaa
@fdemaa
Jul 17 2017 07:08
@kumquatfelafel hey can you give me a hand with my codepen man ?
im having an issue with my quotes generator
M-C-Haker
@M-C-Haker
Jul 17 2017 07:09
i want to say Hell World but i don't think that's right. Is it going to repeart the whole thing? 3x
kumquatfelafel
@kumquatfelafel
Jul 17 2017 07:10
@fdemaa possibly?
M-C-Haker
@M-C-Haker
Jul 17 2017 07:11
i'm not sure why though to be honest, in my addimittedly limited experience with loops I've used mainly array. I think this may be the fring loop purley with a string...
kumquatfelafel
@kumquatfelafel
Jul 17 2017 07:11
still slightly ... not sober... and less familiar with html/jquery/api type stuff
M-C-Haker
@M-C-Haker
Jul 17 2017 07:11
bit of a learning curve here right now. ok so it just repeats world 3x
kumquatfelafel
@kumquatfelafel
Jul 17 2017 07:13
@M-C-Haker yup.
First iteration hello becomes Hello world, then becomes Hello world world, then Hello world world world
M-C-Haker
@M-C-Haker
Jul 17 2017 07:14
how does it just do that to world though? why doesn't it affect the hello variable at all?
kumquatfelafel
@kumquatfelafel
Jul 17 2017 07:15
@fdemaa what is secondMax? Or rather, why is it 5?
fdemaa
@fdemaa
Jul 17 2017 07:16
i have 5 quotes
on every object
thats why i use 5 on the max
@kumquatfelafel
kumquatfelafel
@kumquatfelafel
Jul 17 2017 07:20
@fdemaa just making sure. I would avoid saying 5 directly here, since what if this changes, and instead base it on the length of quotes for a given character.
fdemaa
@fdemaa
Jul 17 2017 07:21
@kumquatfelafel :+1: you are the mvp! thanks
CamperBot
@camperbot
Jul 17 2017 07:21
fdemaa sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 480 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
fdemaa
@fdemaa
Jul 17 2017 07:21
i forgot to think about that
lol
yofri
@yofriadi
Jul 17 2017 07:21

can anyone help me with recursion, i have a question like this

function pow(x, y) {
  if (y == 0) {
    return 1;
  } else {
    return x * pow(x, y-1);
  }
}

console.log( (pow(2, 1000000000000000) );
console.log( (pow(2, 9831050005000007) );

it has too many recursion, which is exceed call stack. how to manage this?

kumquatfelafel
@kumquatfelafel
Jul 17 2017 07:23
@fdemaa there are other things you could maybe do or not do, but like said not as familiar with this and pretty tired so... :p
Randy Goldsmith
@Dueldrawer8
Jul 17 2017 07:23
does anyone know how to use the getAttribute method in plain javascript to fetch the icon so that i can render it to the page?
fdemaa
@fdemaa
Jul 17 2017 07:23
@kumquatfelafel thanks! now im trying to use an api to collect url images for each character, lol, hope i can make it
CamperBot
@camperbot
Jul 17 2017 07:23
fdemaa sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:warning: fdemaa already gave kumquatfelafel points
kumquatfelafel
@kumquatfelafel
Jul 17 2017 07:29
@Yofri 9831050005000007 is reaaaally large. What's happening is it's calling pow function over and over and over again and eventually crashes. If you wanted to do it like this, one thing you could try is to do it in manageable pieces so it doesn't overload the stack. So, like, instead of multiplying by x 90 times, multiply by x 30 times and 30 times and 30 times.
Markus Kiili
@Masd925
Jul 17 2017 07:31
@Yofri Maybe you should divide the exponent by two so it doesn't get so deep:
function pow(x, y) {
  if (y === 0) return 1;
  if (y%2===0) {
    return pow(x*x,y/2);
  }
  else {
    return x*pow(x,y-1);
  }
}
yofri
@yofriadi
Jul 17 2017 07:31
@kumquatfelafel @Masd925 wait i try
Randy Goldsmith
@Dueldrawer8
Jul 17 2017 07:33
nvm suppose to use setattribute instead of getattribute
kumquatfelafel
@kumquatfelafel
Jul 17 2017 07:33
gonna go back to sleep :laughing:
night
yofri
@yofriadi
Jul 17 2017 07:39
@Masd925 it log Infinity, is it the answer?
Markus Kiili
@Masd925
Jul 17 2017 07:40
@Yofri Yeah, the number is too large to be represented in 64bit float.
Number.MAX_VALUE; // 1.7976931348623157e+308
Siphils
@Siphils
Jul 17 2017 07:41
What does this mean?
return arr.filter(v => v)
yofri
@yofriadi
Jul 17 2017 07:42
@Masd925 ok thanks man, you're really helping
CamperBot
@camperbot
Jul 17 2017 07:42
yofri sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4299 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jul 17 2017 07:42
@Siphils Filter keeps those elements that return a truthy value when passed into the callback function. Passing v=>v thus makes filter keep truthy elements.
Siphils
@Siphils
Jul 17 2017 07:44
Oh, I see.
@Masd925 Thank you.
CamperBot
@camperbot
Jul 17 2017 07:45
siphils sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4300 | @masd925 |http://www.freecodecamp.com/masd925
Theofanis Despoudis
@theodesp
Jul 17 2017 08:57
Hey guys I just want to ask when the beta is going to roll out?
Markus Kiili
@Masd925
Jul 17 2017 08:57
@theodesp This intsernez is dead. Try the general channel.
Johnny
@JohnnyBizzel
Jul 17 2017 08:59
@theodesp I think Quincy has discussed this in the forum
abraham anak agung
@padunk
Jul 17 2017 09:04
Hi guys, why is this function print out?
Array.prototype.decimalfy = function() {
  for (let i = 0; i < this.length; i++) {
    this[i] = this[i].toFixed(2);
  }
};

const digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

for (const index in digits) {
  console.log(digits[index]);
}
Markus Kiili
@Masd925
Jul 17 2017 09:06
@padunk One property key that for...in loop loops over is that "decimalify"
That is one reason why for...in loop is not to be used for looping over array indices.
Marianissimus
@Marianissimus
Jul 17 2017 09:07
@padunk I don't see the connection between the decimalfy function and the for loop.
abraham anak agung
@padunk
Jul 17 2017 09:09
@Masd925 still don't get it. it completely no connection between the two
jeremyztang
@jeremyztang
Jul 17 2017 09:09
help
how to output a single \
abraham anak agung
@padunk
Jul 17 2017 09:10
@Marianissimus yes, but i you run it, the console print out the Function after 9. That is why i ask this kind of weird thing
Markus Kiili
@Masd925
Jul 17 2017 09:11
@padunk For...in loop loops over the enumerable property keys of the object and also the prototype chain. That decimalify is an enumerable property key of the Array.prototype and that for...in loop finds it as one index.
alpox
@alpox
Jul 17 2017 09:11
@padunk There is. You add a function to the prototype of array - the prototype gets added to every array instance (Like digits) so the array in digits holds the function decimalfy
@padunk console.log(digits.decimalfy);
Markus Kiili
@Masd925
Jul 17 2017 09:12
@padunk Make that property non-enumerable if you don't wan't that to happen. Or use for loop or array iterators as you should.
korzo
@korzo
Jul 17 2017 09:12
@jeremyztang '\\'
jeremyztang
@jeremyztang
Jul 17 2017 09:13
var myStr ='\ \t \b \n';
doesn't work
QAQ
abraham anak agung
@padunk
Jul 17 2017 09:13
@alpox @Masd925 ahh...ok. i got it. thanks.
CamperBot
@camperbot
Jul 17 2017 09:13
padunk sends brownie points to @alpox and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1262 | @alpox |http://www.freecodecamp.com/alpox
:star2: 4301 | @masd925 |http://www.freecodecamp.com/masd925
abraham anak agung
@padunk
Jul 17 2017 09:14
so it is better use for...of then?
Markus Kiili
@Masd925
Jul 17 2017 09:15
@padunk Yes, or a simple for loop or some array iterator.
abraham anak agung
@padunk
Jul 17 2017 09:15
@Masd925 :+1:
RakeshNerkar
@Rakesh18754
Jul 17 2017 09:15

a function returns a object but at any random time interval

i want to monitor that function that whenever it returns the value the screen should get updated

how can i achieve this?

makalohri
@makalohri
Jul 17 2017 09:16
@knrt10 thank you
CamperBot
@camperbot
Jul 17 2017 09:16
makalohri sends brownie points to @knrt10 :sparkles: :thumbsup: :sparkles:
:cookie: 460 | @knrt10 |http://www.freecodecamp.com/knrt10
Markus Kiili
@Masd925
Jul 17 2017 09:17
@Rakesh18754 Can you edit that setInterval call or that function that returns the object?
RakeshNerkar
@Rakesh18754
Jul 17 2017 09:18
@Masd925 no...that is just a function which return object at any random time i want a mechanism which will keep checkinng it and once the value is returned i will update the screen
like in a chat app...
@Masd925 can this be achieved using event listner?
@Masd925 can you give a example ..i mean how to achieve this?
teevik
@teevik
Jul 17 2017 09:21
Might be easier to just run the screen updating code in the callback function?
Markus Kiili
@Masd925
Jul 17 2017 09:22
@Rakesh18754 I don't think there are such events. You have to do it in some other way.
Thomas
@sjurs1
Jul 17 2017 09:31
@forkerino I was looking at your pomodoro clock and nearly had a stroke when the gong sound went off @ 00:00
:smile:
Pieter Stokkink
@forkerino
Jul 17 2017 09:38
:P
That means it works!
You can take a break now
Theofanis Despoudis
@theodesp
Jul 17 2017 10:02
Hey Pieter I heard that you found a Job as A web Developer!
Congrats!
Welcome to the geek club!
Jonathan Meier
@jntme
Jul 17 2017 10:02
how do I find out which functions I have on a html-element I get with a JS querySelector?
Markus Kiili
@Masd925
Jul 17 2017 10:04
@jntme Do you mean event listeners?
Jonathan Meier
@jntme
Jul 17 2017 10:04
@Masd925 for example yes
Markus Kiili
@Masd925
Jul 17 2017 10:09
@jntme I don't think that it is possible in general to find out the event listeners of given element. If a function is bound to an event using traditional DOM even handler like element.onclick = function(){...}, you can then get it by element.onclick
Blauelf
@Blauelf
Jul 17 2017 10:10
That's how we did it in the good old days :P
Markus Kiili
@Masd925
Jul 17 2017 10:11
@Blauelf Yeah, and when adding a handler, you needed to check if there was already a handler there etc.
Pieter Stokkink
@forkerino
Jul 17 2017 10:14
@theodesp thanks
CamperBot
@camperbot
Jul 17 2017 10:14
forkerino sends brownie points to @theodesp :sparkles: :thumbsup: :sparkles:
:cookie: 380 | @theodesp |http://www.freecodecamp.com/theodesp
Theofanis Despoudis
@theodesp
Jul 17 2017 10:22
@forkerino thanks
CamperBot
@camperbot
Jul 17 2017 10:22
theodesp sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2861 | @forkerino |http://www.freecodecamp.com/forkerino
Theofanis Despoudis
@theodesp
Jul 17 2017 10:22
what are you workin on at the moment?
Pieter Stokkink
@forkerino
Jul 17 2017 10:29
@theodesp we're making software for installers of solar panels to help them with designing systems and calculating expected yields, based on maps, 3d data and so on. I'm working mostly on frontend which is build with Angular/Redux
Chris Juchtmans
@kjuchtmans
Jul 17 2017 10:33
afternoon, you fine folk of coders! :wave:
@forkerino cool thang, quite the sustainable job. where I live, govt shot itself in foot handing out way too much solar subsidies though :zap:
shivam gupta
@shivamg11000
Jul 17 2017 10:40
any react guy up
abraham anak agung
@padunk
Jul 17 2017 10:44
@shivamg11000 Still learning React here :smile:
shivam gupta
@shivamg11000
Jul 17 2017 10:45
where to put the ajax call if I want to be executed after every submit event
Markus Kiili
@Masd925
Jul 17 2017 10:47
@shivamg11000 Inside form submit event handler?
Chris Juchtmans
@kjuchtmans
Jul 17 2017 10:48

Arrow function question: why is below code returning "TypeError: a.concat is not a function"?

flattened = arr.reduce((a, b) => a.concat(b));
    return flattened;

I'm trying to use arrow function to replace function expression in this code:
flattened arr.reduce(function(a, b){
return a.concat(b);
});
return flattened;

cheers! k

teevik
@teevik
Jul 17 2017 10:49
Make sure you give the reduce a starting arr
An initialValue
abraham anak agung
@padunk
Jul 17 2017 10:49
@shivamg11000 setState on event handler?
Markus Kiili
@Masd925
Jul 17 2017 10:51
@kjuchtmans As @teevik said, initialize the accumulator if all arr elements are not arrays.
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 10:51
Can someone help / explain the proxy thing for CORS? I had to take my weather down becuase my API was showing and that's against TOS.... any help would be appreciated.
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 10:54
Hey guys, I'm using .load() to display different HTML files to a div within my index.html - It does work but it slows the the website overtime and crashes the session making the site unresponsive. Do we have an alternative method for this?
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 10:55
Is there a reason you have to do that and can't simply import the HTML?
I mean, is this dynamic or soemthing?
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 10:57
@baseballpoetess Well, I'm thinking if I use a single page HTML it would make my index file really big as I'm planning to add hundreds of divs on the page.
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 10:57
ah, okay
the user experience will still be a huge slow pig of a page then. Can you paginate it?
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 10:58
@baseballpoetess So I decided to try to make multiple html files to separate the items i.e. on one html it would only contain lets says shirts, on another page it would only contain jeans. something like that.
Markus Kiili
@Masd925
Jul 17 2017 10:59
@ChoiYoungdo I think many frameworks handle those things well.
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 10:59
@baseballpoetess I'm really not familiar with pagination, how does one do that?
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 10:59
This, folks, is why ghod invented databases. and why people usually can pick how many items to view.
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 10:59
@Masd925 Which framework?? hmm..
@baseballpoetess Well, I'm staying away from database as I'm not familiar with it and or with backend stuff.
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:00
oh, I see.
Chris Juchtmans
@kjuchtmans
Jul 17 2017 11:01
@teevik @Masd925 right! a.concat(b), [ ] ) there we go. thanks folks
CamperBot
@camperbot
Jul 17 2017 11:01
kjuchtmans sends brownie points to @teevik and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 202 | @teevik |http://www.freecodecamp.com/teevik
:star2: 4302 | @masd925 |http://www.freecodecamp.com/masd925
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:01
Can you store it in arrays then? and only display some of it ata time?
or don't you know any javascript either?
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 11:02
@baseballpoetess Well, originally I'm using data-filters to hide the rest of the items then only show it on a click of a button.
@baseballpoetess I do, I'm purely relying on js right now as I don't know any backend lang.
Markus Kiili
@Masd925
Jul 17 2017 11:03
@baseballpoetess God invented Relational theory, and SQL people screwed it up.
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 11:03
@baseballpoetess But I'm thinking that using data-filters in the long run would make the site slower since I'm planning to regularly add items to the site. Am I wrong?
I'm working on an online clothing shop by the way
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:04
Well, did you do any free code camp projects? The wiki viewer does ten items to view and if you've done that, you know how to display ten items. If you've done the twitch.tv , you know how to do variable number of items. And you can apply that knowlege to your data.
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 11:04
So basically, the idea is to add items/collections on a regular basis..
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:05
Yes. But you only want to see some of it at a time.
Really.
I mean there are some customers with cable internet who want to see it all, but on my phone, I can't do that.
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 11:06
@baseballpoetess Right now, it only displays several items at a time unless you click on 'All' then it would display every item on the list
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:06
And if you did random quotes with an array, you know how to do that part, too. :) It's about .... technique.
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 11:07
@baseballpoetess What I'm worried about this method is that it would make the index file really big overtime. Would that be an issue?
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:07
if you .load() them in at runtime, it's the same size.
as far as the browser is concerned.
it takes longer though because it uses multiple .... connection requests.
so you're slowing it down that way.
(that's the point behind minification -- to have fewere requests)
or a point
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 11:10
@baseballpoetess Right, plus it seems to crash the website if I click the buttons that has .load() on it.
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:11
that does not sound good -- what does the console say?
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 11:11
@baseballpoetess No errors on the console, it just crashes if I click those buttons back and forth.
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:12
joy, I hate when it won't tell you what it doesn't like.
do they all crash or only certain ones?
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 11:14
@baseballpoetess Nope, just the tab for my website, other tabs seems to be working fine
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:14
one HTML file crashes? Have you tried loading that HTML file in its own tab? is it error-free?
Michiel
@MichielHuijse
Jul 17 2017 11:14

for this challenge, do I need all the methods:

Array.prototype.slice()
Array.prototype.filter()
Array.prototype.indexOf()
Array.prototype.concat()

or is it possible to solve in multiple ways?
https://www.freecodecamp.com/challenges/diff-two-arrays

J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:15
diff two arrays, lemme look how I solved it..... @MichielHuijse .... one moment
ChoiYoungdo
@ChoiYoungdo
Jul 17 2017 11:15
@baseballpoetess Yup, did that too. It does the same thing it just hangs? stops loading or something. In any case, it makes the site unresponsive
Markus Kiili
@Masd925
Jul 17 2017 11:15
@MichielHuijse Those are just good suggestions. There are many ways.
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:16
There are options. There is no One Right Way ....
Michiel
@MichielHuijse
Jul 17 2017 11:16
@Masd925 aah, probably it is possible to do it without the filter method
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:16
Okay, so maybe you need to look at that HTML file and find the error.
Markus Kiili
@Masd925
Jul 17 2017 11:17
@MichielHuijse Sure, but filter is handy here.
Michiel
@MichielHuijse
Jul 17 2017 11:18
In case I use filter, I would say it is possible to skip the other methods right?
Markus Kiili
@Masd925
Jul 17 2017 11:19
@MichielHuijse Sure, but methods make the solution more compact and elegant.
Theofanis Despoudis
@theodesp
Jul 17 2017 11:19
@forkerino wow man that amazing
Michiel
@MichielHuijse
Jul 17 2017 11:21
@Masd925 ok, thanks, the filter() method is kind of confusing for me since it uses a callback function.
CamperBot
@camperbot
Jul 17 2017 11:21
michielhuijse sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4303 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jul 17 2017 11:22
@theodesp He googled How to save the world by coding and now he is doing it while holding orphan badger babies on his backpack.
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:24
@MichielHuijse filter is pretty basic. newArray = oldArray.filter(function(item){return <condition item should pass>;});
Pieter Stokkink
@forkerino
Jul 17 2017 11:25
:joy:
Michiel
@MichielHuijse
Jul 17 2017 11:25
@baseballpoetess ok thanks, makes sence.
CamperBot
@camperbot
Jul 17 2017 11:25
michielhuijse sends brownie points to @baseballpoetess :sparkles: :thumbsup: :sparkles:
:cookie: 794 | @baseballpoetess |http://www.freecodecamp.com/baseballpoetess
J-Mag Guthrie
@baseballpoetess
Jul 17 2017 11:26
ghods, trying to type at 6:30am local ....
anyway, I need to go start my crock pot -- I'm smoking a huge hunk of beast for dinner.
KinderPreet Singh
@kindercappy
Jul 17 2017 11:33
Please check out my calculator app. Do report any bugs you find.
https://codepen.io/kindercappy/full/mwgaGN/
Markus Kiili
@Masd925
Jul 17 2017 11:38
@kindercappy 2= results in -2
How do you type negative numbers?
-5 gives 5
.1+.2 gives 0.30000000000000004
KinderPreet Singh
@kindercappy
Jul 17 2017 11:41
I totally forgot about negtives.
and should ia round it? @Masd925
Markus Kiili
@Masd925
Jul 17 2017 11:42
= shrinks the input area.
wonder
@wonder2991
Jul 17 2017 11:42
@kindercappy also doesn't reset
Markus Kiili
@Masd925
Jul 17 2017 11:42
@kindercappy You need to find a way to handle negatives.
KinderPreet Singh
@kindercappy
Jul 17 2017 11:42
@Masd925 yes im on it
@wonder2991 what?
@Masd925 thanks
CamperBot
@camperbot
Jul 17 2017 11:43
kindercappy sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4304 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jul 17 2017 11:43
@kindercappy Maybe the input area should reset to the result when you press =
KinderPreet Singh
@kindercappy
Jul 17 2017 11:45
@Masd925 they both reset with ce. do i need to reset with =?
wonder
@wonder2991
Jul 17 2017 11:46
yes, if the next input is a digit
Tomoru
@tomoru
Jul 17 2017 11:49
can anyone explain apply(obj,args)?I don't understand it though I've read some documents
tundeiness
@tundeiness
Jul 17 2017 11:55
hello everyone. is there a way to get local time
Ragnorak
@Rrak
Jul 17 2017 11:57
@tundeiness Use Date();
var Now = new Date();
Stephen James
@sjames1958gm
Jul 17 2017 11:57
@tundeiness new Date() will give you a date object
Stephen James
@sjames1958gm
Jul 17 2017 12:02
@tomoru From MDN
func.apply(thisArg, argsArray)
apply will unpack the argsArray and call the function func on the object thisArg
Math.max.apply(null, [1, 2, 3])
results in
Math.max(1, 2, 3)
Math.max doesn't use the thisArg so you can set to null here.
You can imagine that apply results in
thisArg.func(p1, p2, p3, ...)
where pN is taken from the argsArray
wenchaoWu
@wenchaoWu
Jul 17 2017 12:08
"Cannot read property 'substr' of undefined",what should i do?
Blauelf
@Blauelf
Jul 17 2017 12:08
@wenchaoWu Use substr on a string.
@wenchaoWu Maybe you use something like arr[i].substr() with an i that's out of range (non-existent properties read as undefined)
EpicTriffid
@EpicTriffid
Jul 17 2017 12:13
Can anyone tell me why my API call isn't working? Its meant to work when you type a term into the search box, but im not getting any errors or anything. Its just that nothing is happening https://codepen.io/EpicTriffid/pen/WOYrzg
wenchaoWu
@wenchaoWu
Jul 17 2017 12:14
@Blauelf yep, i use "myarr[i].substr(0,1).toUpperCase()"
Blauelf
@Blauelf
Jul 17 2017 12:14
@wenchaoWu Then are you sure i is in range 0..myarr.length-1, and myarr[i] actually contains a string?
Nick Janne
@njanne19
Jul 17 2017 12:29
I'm trying to make an algorithm that generates walls for my roguelike game, but needless to say something is astray...
https://codepen.io/njanne19/pen/WOPVZj
tundeiness
@tundeiness
Jul 17 2017 12:30
so if coordinates of a location can be derived, how do i get to display the name of the city/location?
Nick Janne
@njanne19
Jul 17 2017 12:31
@tundeiness You're gonna need to use a weather API
tundeiness
@tundeiness
Jul 17 2017 12:34
@njanne19 well i have a simpleWeather.js API but I don't think it will display the name of the city/location? My belief is that it will only show the weather of the location. But as a matter of fact as an aside I'd like to be able to get some few weather parameters like temperature, pressure from that API and I don't know how to go about it.
Stephen James
@sjames1958gm
Jul 17 2017 12:40
@tundeiness google has geolocation API I believe.
tundeiness
@tundeiness
Jul 17 2017 12:40
@sjames1958gm yes they do...I understand that it is not free?
Nick Janne
@njanne19
Jul 17 2017 12:41
@sjames1958gm when you get the chance can you take a look at my map generation and see if you can figure out why my walls are so wonky? (Blank space, double thickness and other random stuff)
Stephen James
@sjames1958gm
Jul 17 2017 12:42
@tundeiness Yeah, I guess its free up to a point, but they probably require billing information :(
tundeiness
@tundeiness
Jul 17 2017 12:43
@sjames1958gm well i'm not willing to give that for now. The task isn't productive yet so that's why i'm opting for simpleWeather.js API
Stephen James
@sjames1958gm
Jul 17 2017 12:44
@tundeiness I wouldn't either.
tundeiness
@tundeiness
Jul 17 2017 12:47
@sjames1958gm why are we been told to use this https://fcc-weather-api.glitch.me/ ? and how do i use it..i'm a bit confused on retrieving the weather icon also.
Stephen James
@sjames1958gm
Jul 17 2017 12:48
@tundeiness I guess it simplifies the API. Never mind I see the icon
@tundeiness Looks like they provide a URL for an icon image
tundeiness
@tundeiness
Jul 17 2017 12:50
@sjames1958gm okay...URL for icon image? how will I use it...still not clear...
Adnan Karšić
@adokce
Jul 17 2017 12:51
thanks @cmccormack
CamperBot
@camperbot
Jul 17 2017 12:51
adokce sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1032 | @cmccormack |http://www.freecodecamp.com/cmccormack
Stephen James
@sjames1958gm
Jul 17 2017 12:51
@tundeiness You can use it as the src attribute of a img tag
tundeiness
@tundeiness
Jul 17 2017 12:54
@sjames1958gm okay but I do not have the name of the images involved ...
@sjames1958gm assuming the weather is bright ...i know I have to use clear sky image. How would I call that?
Stephen James
@sjames1958gm
Jul 17 2017 12:55
You mean background image?
Kamal
@kpbro
Jul 17 2017 12:57
why C to F conversion is not working?
oh shit
spotted a big mistake
Stephen James
@sjames1958gm
Jul 17 2017 12:58
@kpbro Not updating the DOM on click?
Kamal
@kpbro
Jul 17 2017 13:00
yeah. temperature is not changing. i checked console logging but it works fine
this is updated link
check it
Stephen James
@sjames1958gm
Jul 17 2017 13:12
@kpbro This is your entire click handler - you don't change the page contents when you click
      $("button").click(function(){
    if($("button").text() == "°C"){
        $("button").text("°F"); 
        tmp = (9/5)*tmp+32;
      tmpMin = (9/5)*tmpMin+32;
      tmpMax = (9/5)*tmpMax+32;
    }
         else{
           $("button").text("°C");
           tmp = (tmp-32)*5/9;
           tmpMin = (tmpMin-32)*5/9;
           tmpMax = (tmpMax-32)*5/9;
             }

      });
Kamal
@kpbro
Jul 17 2017 13:12
@sjames1958gm then what should i do?
Stephen James
@sjames1958gm
Jul 17 2017 13:13
@sjames1958gm The code below this handler has to also run when you click on the button, not just when you load the data.
tundeiness
@tundeiness
Jul 17 2017 13:13
any heads up on how to use this API ---> https://fcc-weather-api.glitch.me/
can anyone help..I'm still not clear despite the explanation that it is an icon API..the issue is how do I connect to it? at least I need to know the parameters that was used.
Diego Mayer
@Chrono79
Jul 17 2017 13:28
@tundeiness you could use jQuery and getJSON http://api.jquery.com/jquery.getjson/
lat and lon you get them as seen here: https://www.freecodecamp.com/challenges/get-geolocation-data
tundeiness
@tundeiness
Jul 17 2017 13:32
@Chrono79 okay..will try that
Diego Mayer
@Chrono79
Jul 17 2017 13:33
note that lat and lon are only defined inside the callback function of getCurrentPosition, so for this case, the simplest way of doing it is to call getJSON there too
J.Zhou
@Leftscenery
Jul 17 2017 13:35
Hello
Nick Janne
@njanne19
Jul 17 2017 13:42
@alexandrupintilei your url variable is not in the correct scope
Stephen James
@sjames1958gm
Jul 17 2017 13:52
@Leftscenery Hi
Wadie
@wadie
Jul 17 2017 13:54
Best resource to learn React Native ?
stil dosent work
Nick Janne
@njanne19
Jul 17 2017 13:59
This video is quite helpful and of course the React Native Documentation @wadie
@alexandrupintilei change your datatype to "jsonp" and your "success" function is spelled "succes"
^which is a typo
Alex
@alexandrupintilei
Jul 17 2017 14:02
why jsonp?
its worked now
@njanne19 thx
CamperBot
@camperbot
Jul 17 2017 14:02
alexandrupintilei sends brownie points to @njanne19 :sparkles: :thumbsup: :sparkles:
:cookie: 332 | @njanne19 |http://www.freecodecamp.com/njanne19
Nick Janne
@njanne19
Jul 17 2017 14:03
@alexandrupintilei Simply for browser compatibility. What is the difference between JSON and JSONP
James Barrett
@jamesbarrett95
Jul 17 2017 14:05
Hi guys, I have a quick question about objects
function handleOptions () {
  function resetAll () {
    console.log('resetAll has been called')
  }

  function playAgain () {
    console.log('playAgain has been called!')
  }

  const optionText = "resetAll"
  const buttonFunctions = {
    resetAll: resetAll(),
    playAgain: playAgain()
  }
  buttonFunctions[optionText]
}
When handleOptions is run, why are both resetAll and playAgain functions being called, when I specifically call 'resetAll' in this line of code: buttonFunctions[optionText]
Wadie
@wadie
Jul 17 2017 14:06
@njanne19 looks good..
James Barrett
@jamesbarrett95
Jul 17 2017 14:07
Im only expecting 'resetAll has been called' to be in the console
Diego Mayer
@Chrono79
Jul 17 2017 14:07
@jamesbarrett95 resetAll() and playAgain() call both functions
James Barrett
@jamesbarrett95
Jul 17 2017 14:08
@Chrono79 what do you mean? Sorry, slightly confused
Diego Mayer
@Chrono79
Jul 17 2017 14:09
when you write a function name with the () after it, you're calling that function
@jamesbarrett95 https://repl.it/J5Vr/0
  const buttonFunctions = {
    resetAll: resetAll(),  // here you called resetAll
    playAgain: playAgain() // here you called playAgain
  }
Rajat
@rajataudichya
Jul 17 2017 14:13
guys i am not understanding this problemo...

// Setup
function abTest(a, b) {
  // Only change code below this line




  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);
Diego Mayer
@Chrono79
Jul 17 2017 14:13
@rajataudichya you have to use an if
Blauelf
@Blauelf
Jul 17 2017 14:13
@rajataudichya If either number is negative, return undefined.
Rajat
@rajataudichya
Jul 17 2017 14:14
image.png
Diego Mayer
@Chrono79
Jul 17 2017 14:14
:wave: @Blauelf
Blauelf
@Blauelf
Jul 17 2017 14:14
@rajataudichya If both are non-negative, don't do anything in the code you add. So you'll need an if.
@Chrono79 :wave:
Rajat
@rajataudichya
Jul 17 2017 14:15
i got it but tell me is there another way to do it

// Setup
function abTest(a, b) {
  // Only change code below this line

 if (0>a || 0>b){
   return ;
 }  


  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);
James Barrett
@jamesbarrett95
Jul 17 2017 14:16
@Chrono79 Thanks! Still slightly confused though... If I am just calling the object key (in my case, 'resetAll'), how does JavaScript go 'oh okay, im just going to run the function associated with 'playAgain' as well?
CamperBot
@camperbot
Jul 17 2017 14:16
jamesbarrett95 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4488 | @chrono79 |http://www.freecodecamp.com/chrono79
zathura4240
@zathura4240
Jul 17 2017 14:16
@forkerino you on ?
Diego Mayer
@Chrono79
Jul 17 2017 14:17
@jamesbarrett95 when you did buttonFunctions[optionText] it didn't call your function, you can see that if you comment that line
Dan Couper
@DanCouper
Jul 17 2017 14:18
@jamesbarrett95 it is just evaluating the code that is there - in this case, you're saying "evaluate the values of buttonFunctions.resetAll() and buttonFunctions.playAgain()", they get evaluated to their values, which are console.log statements, so the console spits them out
function handleOptions() {
  function resetAll() {
    console.log('resetAll has been called')
  }
  function playAgain() {
    console.log('playAgain has been called!')
  }
  const optionText = 'resetAll'
  const buttonFunctions = {
    resetAll,
    playAgain
  }
  buttonFunctions[optionText]()
}
:point_up: with that you'd just be putting the function identifiers/names/whatev into the object, then actually calling the right function when you do buttonFunctions[optionText]()
Blauelf
@Blauelf
Jul 17 2017 14:18
@rajataudichya return; is an implicit form of return undefined;. You could also if (a>=0 && b>=0) without anything behind, making the existing return happen only if both numbers are non-negative. You then would return undefined even more implicitly, by reaching the function end without having returned.
Alex
@alexandrupintilei
Jul 17 2017 14:24
image.png
image.png
James Barrett
@jamesbarrett95
Jul 17 2017 14:25
@DanCouper Ah I think I understand, so when the handleOptions() function was invoked, it is essentially taking the object and declaring and initializing everything inside of it?
Stephen James
@sjames1958gm
Jul 17 2017 14:25
@alexandrupintilei That red circle with a ! says there is an error in your code.
James Barrett
@jamesbarrett95
Jul 17 2017 14:26
It wasn't what I THOUGHT it would be, whereby everything would be initialized when the variable buttonFunctions is accessed
If that makes sense...
Blauelf
@Blauelf
Jul 17 2017 14:28
@alexandrupintilei I think you missed something in ">"data[1][i], maybe a +?
Joel Y.
@zapcannon99
Jul 17 2017 14:28
@EpicTriffid
Did you get your api call working? It looks like you did.
Alex
@alexandrupintilei
Jul 17 2017 14:29
@Blauelf thanks!
CamperBot
@camperbot
Jul 17 2017 14:29
alexandrupintilei sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4495 | @blauelf |http://www.freecodecamp.com/blauelf
Dan Couper
@DanCouper
Jul 17 2017 14:31
@jamesbarrett95 Yup. You actually seeing a result is partly down to the fact you used console.log(), so it will print all the logs as side-effects to the console. If you use return instead, it just doesn't return anything
James Barrett
@jamesbarrett95
Jul 17 2017 14:36
@DanCouper yeah I noticed! Good stuff, thanks
CamperBot
@camperbot
Jul 17 2017 14:36
jamesbarrett95 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 842 | @dancouper |http://www.freecodecamp.com/dancouper
Rajat
@rajataudichya
Jul 17 2017 14:40

var count = 0;

function cc(card) {
  // Only change code below this line


   if (2,3,4,5,6){
     return"5 Bet";

   }

     else if (7,8,9){
       return"0 Hold";
   }

  else if (10,"J","Q","K","A"){
    return "-5 Hold";
  }

  else if (3,7,"Q",8,"A"){
    return"-1 Hold";
  }

   else if (2,2,10){
    return"1 Bet";
  }
   else if (3,2,"A",10,"K"){
    return"-1 Hold";
  }

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
what am i doing wrong?
Guderian Raborg
@hypercuber
Jul 17 2017 14:40
I am not passing one hidden test and Idk what is wrong with my code:
https://codefights.com/arcade/intro/level-5/veW5xJednTy4qcjso
let ip = '.254.255.0';
function isIPv4Address(str) {
  let arr = str.split('.').filter(s => s.length !== 0).map(n => Number(n));
  return arr.length === 4 && arr.every(n => n >= 0 && n <= 255);
}
console.log(isIPv4Address(ip));
Joshua Friedman
@jsf2008
Jul 17 2017 14:40
Good morning everyone!
Is anyone free to help me with a push function? I'm not sure why it's not working
Guderian Raborg
@hypercuber
Jul 17 2017 14:41
@jsf2008 Let me see
yofri
@yofriadi
Jul 17 2017 14:41

help me to solve this interview task please

function g(str) {
  let i = 0;
  let newStr = '';

  while (i < str.length - 1) {
    newStr += str[i + 1];
    i = i + 1;
  }

  return newStr;
}

function f(str) {
  if (str.length == 0) {
    return '';
  } else if (str.length == 1) {
    return str;
  } else {
    return f( g(str) ) + str[0];
  }
}

function h(n, str) {
  while (n != 1) {
    if (n % 2 == 0) {
      n /= 2;
    } else {
      n = 3 * n + 1;
    }

    str = f(str);
  }

  return str;
}

function pow(x, y) {
  if (y == 0) {
    return 1;
  } else {
    return x * pow(x, y - 1);
  }
}

console.log( h(1, 'fruits') );
console.log( h(2, 'fruits') );
console.log( h(5, 'fruits') );
console.log( h(pow(2, 1000000000000000), 'fruits') );
console.log( h(pow(2, 9831050005000007), 'fruits') );

the last two console.log didnt working. how to break it down it. i know it is recursion, but i have no idea to deal with it.

Guderian Raborg
@hypercuber
Jul 17 2017 14:42
@Yofri Some one told me to not name functions with one letter.
yofri
@yofriadi
Jul 17 2017 14:44
@hypercuber ohh man that didnt helping, it is interview task anyway
Guderian Raborg
@hypercuber
Jul 17 2017 14:44
@jsf2008 Can you give me array and tell me what you want to do with array? I like to work with algorithms that deals with numbers/ math
Joshua Friedman
@jsf2008
Jul 17 2017 14:44
OK
Guderian Raborg
@hypercuber
Jul 17 2017 14:45
@Yofri what is going in the code
Joshua Friedman
@jsf2008
Jul 17 2017 14:45
I want to push this array. And I'm not sure why It's not pushing
 var id = data.weather[0].id, 
        bgIndex,
        backgroundId = [299,499,599,699,799,800];

    backgroundId.push(id);
    bgIndex = backgroundId.sort().indexOf(id);
    console.log(backgroundId);
yofri
@yofriadi
Jul 17 2017 14:46
@hypercuber idk, the 1 console.log is outputing the string as it is, the next two outputing string in reverse. the last two is why i am here
Joshua Friedman
@jsf2008
Jul 17 2017 14:46
The array is to correspond to this array.
backgroundImg = [
    "https://s22.postimg.org/5o3q5v9r5/Thunder.jpg",
    "https://s1.postimg.org/fzu02frin/Drizzle.jpg",
    "https://s2.postimg.org/5kmdduivd/Rain.jpg",
    "https://s22.postimg.org/xop8oo5td/Snow.jpg",
    "https://s21.postimg.org/v53flul3b/Fog.jpg",
    "https://s24.postimg.org/67tkxm945/Clear.jpg",
    "Coudy https://s9.postimg.org/57b9834lr/Cloudy.jpg",   
  ]
When the number is to be called upon it's to be pushed along with this array so it can become the background image to my weather app
Guderian Raborg
@hypercuber
Jul 17 2017 14:48
@Yofri Idk what is data.weather[0].id like number, string, etc.
Blauelf
@Blauelf
Jul 17 2017 14:52

@rajataudichya if (2,3,4,5,6) uses the comma operator (which you did not intend to use), so is same as if (6), and tests whether 6 is truthy. I can tell you, it is.

The function cc is called with one card at any given time. you should

  1. For certain values of card, increment or decrement global variable count
  2. Return a string built from count and either Bet or Hold (depending on count), with one space between number and word.

Do not mix those two. Especially Bet/Hold does not at all depend on card.

Guderian Raborg
@hypercuber
Jul 17 2017 14:52

With:

    var id = data.weather[0].id, 
        bgIndex,
        backgroundId = [299,499,599,699,799,800];

    backgroundId.push(id);
    bgIndex = backgroundId.sort().indexOf(id);
    console.log(backgroundId);

I am getting [299, 499, 599, 699, 799, 800, 802]

You fixed it?
I tried to help.
Joshua Friedman
@jsf2008
Jul 17 2017 14:57
Sorry
You were pinging the wrong person and didn't check over
That's what I'm also getting in my console but I want to push the code to the beginning so I can get the picture I've assigned to the background to my page
Guderian Raborg
@hypercuber
Jul 17 2017 14:58
@Yofri to reverse a string you can do this:
function reverse(str) {
  return str.split('').reverse().join('');
}
console.log(reverse('fruits'));
@Yofri I would like the world problem. I might be able to help.
Joshua Friedman
@jsf2008
Jul 17 2017 15:05
@hypercuber I want to push that 802 to the beginning of my array
IDK why it's not
James Barrett
@jamesbarrett95
Jul 17 2017 15:06
Linter question for any experts out there:
Guderian Raborg
@hypercuber
Jul 17 2017 15:07
@jsf2008
let arr = [1,2,3];
arr.unshift(0); //adds to first
console.log(arr); //0, 1, 2, 3
James Barrett
@jamesbarrett95
Jul 17 2017 15:07
  function playAgain () {
    tiles.forEach(tile => tile.innerHTML = '')
  }
I get a warning of 'Arrow function should not return assignment'
Why is this dangerous? And what is the workaround for something like this?
Victor Popescu
@VicPopescu
Jul 17 2017 15:08
@jsf2008 array.unshift(element)?
Guderian Raborg
@hypercuber
Jul 17 2017 15:08
@jamesbarrett95 What is you try .map?
Joshua Friedman
@jsf2008
Jul 17 2017 15:09
unshift doesn't work either
Victor Popescu
@VicPopescu
Jul 17 2017 15:09
@jsf2008 so let me see if I understand after a fast read, you need to put an element at the beginning of an array?
Guderian Raborg
@hypercuber
Jul 17 2017 15:09
@jsf2008 It should work. Another way to do it is like this:
let arr = [1,2,3];
let newArr = [0, ...arr];
console.log(newArr); //0, 1, 2, 3
James Barrett
@jamesbarrett95
Jul 17 2017 15:10
@hypercuber same thing happens
Joshua Friedman
@jsf2008
Jul 17 2017 15:10
yes that's what I need to do
teevik
@teevik
Jul 17 2017 15:10
Show your fubction with .map?
function
Victor Popescu
@VicPopescu
Jul 17 2017 15:11
Joshua Friedman
@jsf2008
Jul 17 2017 15:12
I agre it should but it's not
Guderian Raborg
@hypercuber
Jul 17 2017 15:15
or
let arr = [1,2,3];
arr = [0, ...arr];
console.log(arr); //0, 1, 2, 3
Can someone help me? One of the hidden tests dont pass:
https://codefights.com/arcade/intro/level-5/veW5xJednTy4qcjso
function isIPv4Address(str) {
  let arr = str.split('.').filter(s => s.length !== 0).map(n => Number(n));
  return arr.length === 4 && arr.every(n => n >= 0 && n <= 255);
}
Blauelf
@Blauelf
Jul 17 2017 15:25
@hypercuber So " .. .. .. " is a valid IP address? I could build a few more examples where your logic fails in multiple ways (here ".." to make filter fail, and space to make Number fail)
Guderian Raborg
@hypercuber
Jul 17 2017 15:26
@Blauelf so you are saying 000......254.255.0?
@Blauelf I think you are right. Thanks. Will check it out.
CamperBot
@camperbot
Jul 17 2017 15:27
hypercuber sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4496 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Jul 17 2017 15:28
Maybe something like
function isIPv4Address(str) {
  let arr = str.split('.');
  return arr.length === 4 && arr.every(n => n >= 0 && n <= 255 && Number.parseInt(n, 10).toString() === n);
}
Guderian Raborg
@hypercuber
Jul 17 2017 15:30
@Blauelf Thanks. It works. I will try and check regex too.
CamperBot
@camperbot
Jul 17 2017 15:30
hypercuber sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: hypercuber already gave blauelf points
Pieter Stokkink
@forkerino
Jul 17 2017 15:31
:wave:
Blauelf
@Blauelf
Jul 17 2017 15:32
I once built a regular expression for that one. It was ugly. There may be nicer ways, though.
Pieter Stokkink
@forkerino
Jul 17 2017 15:33
How would one match a number from 0 to 255 with a RegExp?
ParadoxStephen
@StephenLover
Jul 17 2017 15:33
return String.fromCharCode(70,82,69,69,32,67,79,68,69,32,67,65,77,80);
return String.fromCharCode(newStr);
Hi guys i am confused on the second one,why it returns a red point but the correct answer?
the newStr is "70,82,69,69,32,67,79,68,69,32,67,65,77,80"
Joel Y.
@zapcannon99
Jul 17 2017 15:34
@StephenLover What's newStr? A random number?
oh nvm, you posted
ParadoxStephen
@StephenLover
Jul 17 2017 15:35
yep
Joel Y.
@zapcannon99
Jul 17 2017 15:35
I'm new, but what's a red point? Test failed?
Jason Luboff
@JLuboff
Jul 17 2017 15:35
:wave:
ParadoxStephen
@StephenLover
Jul 17 2017 15:35
how can i screencut
i wanna post the screenshot on this chatroom
Joel Y.
@zapcannon99
Jul 17 2017 15:36
image.png
image.png
use the snipping tool and copy paste
if you're on windows xp
ParadoxStephen
@StephenLover
Jul 17 2017 15:37
ok wait a second
Joel Y.
@zapcannon99
Jul 17 2017 15:37
There's probably a better way, the senior people can enlighten us
Jason Luboff
@JLuboff
Jul 17 2017 15:37
I sure hope no one is on Windows XP still..
Joel Y.
@zapcannon99
Jul 17 2017 15:38
true....
Then it'll be print screen, paste
Blauelf
@Blauelf
Jul 17 2017 15:38
@StephenLover If you want to String.fromCharCode an array of numbers (not a string), you could use like String.fromCharCode.apply(null, array)
Guderian Raborg
@hypercuber
Jul 17 2017 15:41
I need help here. My code say 'missing variable name':
https://codefights.com/arcade/intro/level-6/mCkmbxdMsMTjBc3Bm
let arr = [1, 2, 1],
// elemToReplace = 1
// substitutionElem = 3
function arrayReplace(arr, replace, substitute) {
  for (let i = 0; i < arr.length; i++) {
    if (arr[i] === replace) arr[i] = substitute;
  }
  return arr;
}
console.log(arrayReplace(arr,1,3));
Blauelf
@Blauelf
Jul 17 2017 15:41
@JLuboff In German railway systems, I assume many displays are, if not worse (a week ago I saw a failed boot claiming "copyright 1985-1993"). Most of them should never see the internet, though. A few fell victim to one of the latest ransomware, so we know they were probably on WindowsXP or up.
Joel Y.
@zapcannon99
Jul 17 2017 15:41
@Blauelf Interesting. Does MDN actually tell you this, or is this something you have to dig for.
@hypercuber I think it's var i, not let i
Edit: nvm, I'm a noob. But i mean "let" does weird things to scope right?
Blauelf
@Blauelf
Jul 17 2017 15:42
@zapcannon99 You mean the apply stuff? It's Function.prototype.apply and works for any function. I passed null for thisArg as String.fromCharCode does not care.
Jason Luboff
@JLuboff
Jul 17 2017 15:42
@Blauelf Oh ya, I know. My company still runs several critical systems on Windows XP, and even one facility on DOS! They have the hardware to replace them, but haven't. It's extremely frustrating from an IT perspective (its not our departments systems)
Joel Y.
@zapcannon99
Jul 17 2017 15:43
Yeah the apply thing. I see what you mean @Blauelf .
@Blauelf Thanks.
CamperBot
@camperbot
Jul 17 2017 15:43
zapcannon99 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4497 | @blauelf |http://www.freecodecamp.com/blauelf
IsmailHusseinCR
@IsmailHusseinCR
Jul 17 2017 15:43

function Dog(name) {
  this.name = name; 
}
var snoop = new Dog("Lion");
Dog.prototype = {
  // Add your code below this line
  numLegs: 4,
  eat: () => {
    console.log("shoof shoof");
  },
  describe: () => {
    console.log("My name is " + this.name);
  }
};
Blauelf
@Blauelf
Jul 17 2017 15:44
@JLuboff DOS does not have many vulnerable services running in the background ;)
IsmailHusseinCR
@IsmailHusseinCR
Jul 17 2017 15:44
hi all when i console.log the describe object i dont get the this.name
Jason Luboff
@JLuboff
Jul 17 2017 15:44
@Blauelf True. But they're running it on a 20 year old laptop...
Blauelf
@Blauelf
Jul 17 2017 15:44
@IsmailHusseinCR Change the prototype before calling the constructor.
IsmailHusseinCR
@IsmailHusseinCR
Jul 17 2017 15:45
alright
tommy
@tommygebru
Jul 17 2017 15:46

is var optional, for a challenge to pass?

for example - when using a for loop

for(var i=0;

or

for( i=0;
Blauelf
@Blauelf
Jul 17 2017 15:46
@JLuboff Somewhat scary. But I would not want to touch the running system.
Jason Luboff
@JLuboff
Jul 17 2017 15:47
@tommygebru Yes, but you can experience some unwanted results
Blauelf
@Blauelf
Jul 17 2017 15:47
@tommygebru If you don't declare a variable you assign to, it's implicitly global.
Joel Y.
@zapcannon99
Jul 17 2017 15:47
@tommygebru I think it's optional, but of course bad practice.
tommy
@tommygebru
Jul 17 2017 15:47
@Blauelf @zapcannon99 thanks @JLuboff that makes sense!
CamperBot
@camperbot
Jul 17 2017 15:47
tommygebru sends brownie points to @blauelf and @zapcannon99 and @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 298 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
:star2: 2071 | @jluboff |http://www.freecodecamp.com/jluboff
:star2: 4498 | @blauelf |http://www.freecodecamp.com/blauelf
Guderian Raborg
@hypercuber
Jul 17 2017 15:48
@zapcannon99 let me check. Thanks anyways
CamperBot
@camperbot
Jul 17 2017 15:48
hypercuber sends brownie points to @zapcannon99 :sparkles: :thumbsup: :sparkles:
:cookie: 299 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
Blauelf
@Blauelf
Jul 17 2017 15:48
@tommygebru global by default is a major design flaw in JavaScript (worse than typeof null === "object"), but is kept for compatibility. Strict mode would complain in that case.
Joel Y.
@zapcannon99
Jul 17 2017 15:49
@hypercuber
Btw, in case you didn't see it already, that comma on the first line
@hypercuber I think that's your headache.
tommy
@tommygebru
Jul 17 2017 15:49
yes :smile:
Guderian Raborg
@hypercuber
Jul 17 2017 15:49
@zapcannon99 That works!
Joseph
@revisualize
Jul 17 2017 15:49
@Blauelf @zapcannon99 thanks
CamperBot
@camperbot
Jul 17 2017 15:49
:cookie: 300 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
revisualize sends brownie points to @blauelf and @zapcannon99 :sparkles: :thumbsup: :sparkles:
:star2: 4499 | @blauelf |http://www.freecodecamp.com/blauelf
Joseph
@revisualize
Jul 17 2017 15:50
@zapcannon99 gratz on 300.
:D
Jason Luboff
@JLuboff
Jul 17 2017 15:50
@revisualize I saw someone was reporting you for posting your daily free e-book :joy:
Joel Y.
@zapcannon99
Jul 17 2017 15:50
@revisualize Thanks.
CamperBot
@camperbot
Jul 17 2017 15:50
zapcannon99 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4354 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jul 17 2017 15:51
@JLuboff I know. I like their commentary.
Jason Luboff
@JLuboff
Jul 17 2017 15:51
@revisualize Bro. Just stop spamming you know? Anything off the current topic at hand is spamming!
Joseph
@revisualize
Jul 17 2017 15:52
@JLuboff "user has negative reaction" ... All I said to the guy was. "You have your opinion."
Pieter Stokkink
@forkerino
Jul 17 2017 15:52
People are asking questions! Don't distract them with your knowledge.
Joseph
@revisualize
Jul 17 2017 15:52
Or .. Books.
Jason Luboff
@JLuboff
Jul 17 2017 15:52
Especially not you @forkerino your knowledge is questionable at best! :joy:
Pieter Stokkink
@forkerino
Jul 17 2017 15:53
I felt a bit like that today at work
:smile:
Jason Luboff
@JLuboff
Jul 17 2017 15:53
The senior devs put you in your place? lol
Pieter Stokkink
@forkerino
Jul 17 2017 15:54
They let me figure stuff out on my own.
Jason Luboff
@JLuboff
Jul 17 2017 15:55
Even better. Make you struggle. But, thats a good way to learn things. Forces you to use troubleshooting skills
Pieter Stokkink
@forkerino
Jul 17 2017 15:56
For sure. It was troubling but good
ParadoxStephen
@StephenLover
Jul 17 2017 15:56
@Blauelf sorry for interrupting you, i tried to transfer the string to a new array,but it still doesn't work

function rot13(str) { // LBH QVQ VG!

var ascCharCodeArray = [];
var newStr = "";

for(var i = 0;i<str.length;i++){ if(str[i].charCodeAt()>=65 && str[i].charCodeAt()<=77)
{
ascCharCodeArray.push(str[i].charCodeAt() + 13);
}
else if(str[i].charCodeAt()>77 && str[i].charCodeAt() <=90)
{
ascCharCodeArray.push(str[i].charCodeAt() - 13);
}else
{
ascCharCodeArray.push(str[i].charCodeAt());
}

}
//return ascCharCodeArray;

var outPutStr = String.fromCharCode(null,ascCharCodeArray);
//return String.fromCharCode(70,82,69,69,32,67,79,68,69,32,67,65,77,80);
return outPutStr;
}

rot13("SERR PBQR PNZC");

could you mind to help me to look at it?
Blauelf
@Blauelf
Jul 17 2017 15:56
@StephenLover You forgot the .apply
Jason Luboff
@JLuboff
Jul 17 2017 15:57
@revisualize Well thats illegal!!!!
ParadoxStephen
@StephenLover
Jul 17 2017 15:57
awesome!it works,thanks bro :+1: @Blauelf
CamperBot
@camperbot
Jul 17 2017 15:57
stephenlover sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4500 | @blauelf |http://www.freecodecamp.com/blauelf
Pieter Stokkink
@forkerino
Jul 17 2017 15:58
4.5k! :tada:
Blauelf
@Blauelf
Jul 17 2017 15:58
about @forkerino
CamperBot
@camperbot
Jul 17 2017 15:58
:star2: 2861 | @forkerino |http://www.freecodecamp.com/forkerino
Joseph
@revisualize
Jul 17 2017 15:58
@Blauelf Grats. :D
Jason Luboff
@JLuboff
Jul 17 2017 15:59
@Blauelf You look good in 4500
Pieter Stokkink
@forkerino
Jul 17 2017 15:59
I slowed down considerably since starting work
ParadoxStephen
@StephenLover
Jul 17 2017 16:04
Grats. @Blauelf :smile:
Jason Luboff
@JLuboff
Jul 17 2017 16:06
@forkerino I've slowed down considerably since the chat room is considerably slower now
Pieter Stokkink
@forkerino
Jul 17 2017 16:07
That too
I think it's because the link has disappeared from the exercise pages.
EpicTriffid
@EpicTriffid
Jul 17 2017 16:08
@zapcannon99 I did thankyou! Finally!
CamperBot
@camperbot
Jul 17 2017 16:08
epictriffid sends brownie points to @zapcannon99 :sparkles: :thumbsup: :sparkles:
:cookie: 301 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
Jason Luboff
@JLuboff
Jul 17 2017 16:09
Ya thats my understanding. Which sucks becuase this place used to be busy. I can't stand the Help room either
kumquatfelafel
@kumquatfelafel
Jul 17 2017 16:16
@StephenLover For future: if you write it in a code block, it makes it easier to read and allows you to do some formatting. To write it in a code block...
for one line :point_right: ``` code goes here ```
or for multiple lines :point_down:
```js
code goes here (on separate line)
```
You can also edit your post if you make a mistake by clicking the … that appears when you hover your mouse over your comment
Pieter Stokkink
@forkerino
Jul 17 2017 16:17
@kumquatfelafel you can use single `s for one liners
kumquatfelafel
@kumquatfelafel
Jul 17 2017 16:17
blah
:o
Well I'll be!
@forkerino thanks
CamperBot
@camperbot
Jul 17 2017 16:17
kumquatfelafel sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2862 | @forkerino |http://www.freecodecamp.com/forkerino
kumquatfelafel
@kumquatfelafel
Jul 17 2017 16:17
will have to modify that
Pieter Stokkink
@forkerino
Jul 17 2017 16:18
:+1:
zathura4240
@zathura4240
Jul 17 2017 16:19
@forkerino how was the switch from freelance to job ?
I mean freelance gives more freedom , so why choose job ?
Pieter Stokkink
@forkerino
Jul 17 2017 16:22
@zathura4240 I wanted to learn more quickly. And I can work remote about half the time, so I still feel free. Plus I don't really like looking for customers. Prefer to let others handle that.
Jason Luboff
@JLuboff
Jul 17 2017 16:23
@forkerino That was my biggest plus for when I got my current job, I no longer had customers. I just have to deal with people I work with. I don't have to call random people about their computers
zathura4240
@zathura4240
Jul 17 2017 16:23
fair point guys :) , best of luck for the job (s).
Pieter Stokkink
@forkerino
Jul 17 2017 16:23
@zathura4240 thanks
CamperBot
@camperbot
Jul 17 2017 16:23
forkerino sends brownie points to @zathura4240 :sparkles: :thumbsup: :sparkles:
:cookie: 11 | @zathura4240 |http://www.freecodecamp.com/zathura4240
Pieter Stokkink
@forkerino
Jul 17 2017 16:24
I'll be back later. Train arrived.
Jason Luboff
@JLuboff
Jul 17 2017 16:24
See ya
zathura4240
@zathura4240
Jul 17 2017 16:24
cya
:joy:
Oleh
@Lufter
Jul 17 2017 16:25
:D
Ronique Ricketts
@RoniqueRicketts
Jul 17 2017 16:29
@JLuboff missing a ; :smirk:
Jason Luboff
@JLuboff
Jul 17 2017 16:29
@RoniqueRicketts Technically I believe its Swift instead of JS, but oh well
Ronique Ricketts
@RoniqueRicketts
Jul 17 2017 16:30
@JLuboff ES6 in my mind :)
Nick Janne
@njanne19
Jul 17 2017 16:34
Does anyone see what is going on with my walls https://codepen.io/njanne19/pen/WOPVZj?editors=0010
I can't seem to figure it out
Stephen James
@sjames1958gm
Jul 17 2017 16:39
@njanne19 So you have a wall around the outside and a wall at j == 10?
@njanne19 Does that wallSetup code do anything? Seems like none of the data is used.
Abhinav Mishra
@abhinav-m
Jul 17 2017 16:41
Anyone know some site for free mp3 sounds to use with my pen
@sjames1958gm :wave:
Stephen James
@sjames1958gm
Jul 17 2017 16:42
@abhinav-thinktank :wave:
Abhinav Mishra
@abhinav-m
Jul 17 2017 16:42
you know some site from where i can use sample mp3
Nick Janne
@njanne19
Jul 17 2017 16:42
@sjames1958gm I was trying to just see if I could have a wall at position 10, and then I was gonna use the wall setup code
Abhinav Mishra
@abhinav-m
Jul 17 2017 16:42
I need to use one for "error" in my simon game @sjames1958gm
Stephen James
@sjames1958gm
Jul 17 2017 16:42
no, I have looked in the past, but haven't found anything
Abhinav Mishra
@abhinav-m
Jul 17 2017 16:42
oh , ok
The one by freecodecamp uses frequencies..
I guess i can look into how that works..
Nick Janne
@njanne19
Jul 17 2017 16:43
@sjames1958gm what I'm trying to accomplish is a box structure with every edge being labeled as "wall" and then a vertical line down on position 10, but there's weird spacing issues and stuff and I don't undersatnd why
Stephen James
@sjames1958gm
Jul 17 2017 16:44
@njanne19 You mispelled status in one of the else's
I just noticed it
@njanne19 The line after j == 10
Abhinav Mishra
@abhinav-m
Jul 17 2017 16:45
@sjames1958gm Thanks!
CamperBot
@camperbot
Jul 17 2017 16:45
abhinav-thinktank sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8091 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Nick Janne
@njanne19
Jul 17 2017 16:46
@sjames1958gm omg that's so stupid thank you
CamperBot
@camperbot
Jul 17 2017 16:46
njanne19 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8092 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 17 2017 16:46
@abhinav-thinktank :+1:
@njanne19 Been there done that, got the T-shrit
hung up on typos that is
Christopher McCormack
@cmccormack
Jul 17 2017 16:47
:wave:
Stephen James
@sjames1958gm
Jul 17 2017 16:47
:wave:
Jason Luboff
@JLuboff
Jul 17 2017 16:47
@cmccormack :wave: