These are chat archives for FreeCodeCamp/HelpJavaScript

6th
Aug 2016
LaurenCodes
@LaurenCodes
Aug 06 2016 00:02
Hey guys
Having some trouble with this function
export let createFish = (name, price, desc, image, status) => {
    convertPrice = () => {
        return 'hey';
    }
    return {
        key : keyGen++,
        name : name,
        price : this.convertPrice(),
        desc : desc,
        image : image,
        status : status,
        quantity : 0
    }
}
Error message says 'convertPrice is not defined’, what am I doing wrong here?
Stephen James
@sjames1958gm
Aug 06 2016 00:05
@LaurenCodes Is this all the code?
Diego Mayer
@Chrono79
Aug 06 2016 00:05
@LaurenCodes did you try to not use arrow notation and use this.convertPrice when you declare the method?
Stephen James
@sjames1958gm
Aug 06 2016 00:06
@LaurenCodes When you call this code?
LaurenCodes
@LaurenCodes
Aug 06 2016 00:07
I call createFish in another file, but there isn’t a problem unti l add the subfunction convertprice
Stephen James
@sjames1958gm
Aug 06 2016 00:08
@LaurenCodes Do you call it on an object? Is this the correct value?
LaurenCodes
@LaurenCodes
Aug 06 2016 00:09
@Chrono79 I tried it without arrow notation, is that what you’re asking? I don’t see why it would make a difference though
@sjames1958gm No object, I just pass in string values
Stephen James
@sjames1958gm
Aug 06 2016 00:09
@LaurenCodes Did you try with out this. ?
LaurenCodes
@LaurenCodes
Aug 06 2016 00:09
Here is the call
var Fish1 = createFish(‘lobster','2900’,'freshest’,'lobster.jpg','fresh');
Diego Mayer
@Chrono79
Aug 06 2016 00:10
@LaurenCodes
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
An arrow function expression has a shorter syntax compared to function expressions and lexically binds the this value (does not bind its own this, arguments, super, or new.target). Arrow functions are always anonymous. These function expressions are best suited for non-method functions and they can not be used as constructors.
Stephen James
@sjames1958gm
Aug 06 2016 00:11
@LaurenCodes I believe that this will be the global object and does not have a convertPrice function.
Joseph
@revisualize
Aug 06 2016 00:12
Okay .. hmmmm.
James Hall
@James-H33
Aug 06 2016 00:13
Yea, I am with @sjames1958gm I think those arrow functions allow this to grab the global object.
thinkC
@thinkC
Aug 06 2016 00:15
guys..pls need help here
https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%20%222548%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%222468%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%221999%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%221245%22%3A%20%7B%0A%20%20%20%20%20%20%22artist%22%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%225439%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords(id%2C%20prop%2C%20value)%20%7B%0A%20%20if%20(prop%20!%3D%3D%20%22tracks%22%20%26%26%20value%20!%3D%3D%20%22%22)%7B%0A%20%20%20%20collection%5Bid%5D%5Bprop%5D%20%3D%20value%3B%0A%20%20%7Delse%20if(prop%20%3D%3D%3D%22tracks%22)%7B%0A%20%20%20%20collection%5Bid%5D%5Bprop%5D.push(value)%3B%0A%20%20%7Delse%20if(value%20%3D%3D%3D%22%22)%20%7B%0A%20%20%20%20delete%20collection%5Bid%5D%5Bprop%5D%3B%0A%20%20%7Delse%7B%0A%20%20%20%20delete%20collection%5Bid%5D%5Bprop%5D%3B%0A%20%20%7D%0A%20%20%20%20%0A%20%20%0A%20%20%20%20%0A%20%20%0A%20%20return%20collection%3B%0A%7D%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords(5439%2C%20%22artist%22%2C%20%22ABBA%22)%3B%0A%0A
BeefHazard
@BeefHazard
Aug 06 2016 00:15
@thinkC might as well just paste the code with proper formatting
help formatting
CamperBot
@camperbot
Aug 06 2016 00:15

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

thinkC
@thinkC
Aug 06 2016 00:16
ok
LaurenCodes
@LaurenCodes
Aug 06 2016 00:16
hmm I’m not sure I understood. So if I don’t use an arrow function, the subfunction convertPrice() will be bound to this?
Stephen James
@sjames1958gm
Aug 06 2016 00:16
@thinkC If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property. Your prop === "tracks" if needs to nest and if checking for this.
thinkC
@thinkC
Aug 06 2016 00:16

// Setup
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (prop !== "tracks" && value !== ""){
collection[id][prop] = value;
}else if(prop ==="tracks"){
collection[id][prop].push(value);
}else if(value ==="") {
delete collection[id][prop];
}else{
delete collection[id][prop];
}

return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

BeefHazard
@BeefHazard
Aug 06 2016 00:17
@thinkC you didn't read a word of the formatting help, did you?
Stephen James
@sjames1958gm
Aug 06 2016 00:17
@thinkC put three backquotes on their own line before and after the code for formatting.
Also, no need to include the collection object.
BeefHazard
@BeefHazard
Aug 06 2016 00:17
help formatting
CamperBot
@camperbot
Aug 06 2016 00:17

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

LaurenCodes
@LaurenCodes
Aug 06 2016 00:18
@sjames1958gm @Chrono79 I changed it to non-arrow functions but I don’t see a difference
export function createFish (name, price, desc, image, status) {
    function convertPrice () {
        return 'hey';
    }
    return {
        key : keyGen++,
        name : name,
        price : this.convertPrice(),
        desc : desc,
        image : image,
        status : status,
        quantity : 0
    }
}
Stephen James
@sjames1958gm
Aug 06 2016 00:18
@LaurenCodes There is nothing to provide this other than the global object.
thinkC
@thinkC
Aug 06 2016 00:18
@BeefHazard , no I did not sorry
LaurenCodes
@LaurenCodes
Aug 06 2016 00:19
ahhh OK I see
So I need to bind this to the function?
thinkC
@thinkC
Aug 06 2016 00:19
@sjames1958gm ...ok
Stephen James
@sjames1958gm
Aug 06 2016 00:19
@LaurenCodes Will it work without this
Joseph
@revisualize
Aug 06 2016 00:19
Okay, all you smarty farties. I just asked a question in https://gitter.im/freecodecamp/CodingJobs Maybe someone could help. .. Thanks.
Abhisek Pattnaik
@abhisekp
Aug 06 2016 00:19
@LaurenCodes you don't need this binding for lexical context. It is already available to you for using directly :D
LaurenCodes
@LaurenCodes
Aug 06 2016 00:20
@sjames1958gm @abhisekp Thank you!
CamperBot
@camperbot
Aug 06 2016 00:20
laurencodes sends brownie points to @sjames1958gm and @abhisekp :sparkles: :thumbsup: :sparkles:
:star2: 2372 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 2838 | @abhisekp |http://www.freecodecamp.com/abhisekp
LaurenCodes
@LaurenCodes
Aug 06 2016 00:20
I didn’t know that
John Magee
@jemagee
Aug 06 2016 00:21
Quick question on the open weather api - is it really in degrees kelvin?
dimitrije12
@dimitrije12
Aug 06 2016 00:22
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var searchfor = Object.keys(source);
  var ch = true;
  collection.forEach(function(data){
    searchfor.forEach(function(element){
      if (!(data.hasOwnProperty(element)) || (data[element] !== source[element])){
        ch=false;
      }
    });
    if (ch) {
      arr.push(data);
    }
  });

  // Only change code above this line
  return arr;
}
WHATS WRONG WITH THIS
Diego Mayer
@Chrono79
Aug 06 2016 00:22
@jemagee yes, if you don't ask for another unit
dimitrije12
@dimitrije12
Aug 06 2016 00:22
sorry for caps
Stephen James
@sjames1958gm
Aug 06 2016 00:22
@jemagee Yes, but you can ask for other units.
dimitrije12
@dimitrije12
Aug 06 2016 00:22
challange name is Wherefore art thou
John Magee
@jemagee
Aug 06 2016 00:22
Ok - gotcha - i don't mind kelvin i just have to remember the conversion number from grad school :)
Stephen James
@sjames1958gm
Aug 06 2016 00:22
@dimitrije12 Does ch need to be reset for each collection?
dimitrije12
@dimitrije12
Aug 06 2016 00:23
@sjames1958gm thanks you solved the problem in 2 seconds
CamperBot
@camperbot
Aug 06 2016 00:23
dimitrije12 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2373 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
dimitrije12
@dimitrije12
Aug 06 2016 00:23
i was looking at it for 15 minutes
Stephen James
@sjames1958gm
Aug 06 2016 00:24
@revisualize @revisualize What kind of dev are you wanting to be ready for. Front-end, back-end, other? I would think that doing the projects or doing some projects would be useful if not essential to establish your "readiness" I think these challenges are ok, but they are somewhat contrived.
Joseph
@revisualize
Aug 06 2016 00:24
I was thinking a mix of front end with back end.
I've done a good bit of backend stuff with PHP
Joel Santos
@St3ps
Aug 06 2016 00:25
format help
Joseph
@revisualize
Aug 06 2016 00:25
help format
CamperBot
@camperbot
Aug 06 2016 00:25

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Stephen James
@sjames1958gm
Aug 06 2016 00:25
@dimitrije12 With practice you will learn to look for certain patterns first and often those are the common ones.
Joel Santos
@St3ps
Aug 06 2016 00:25
lol @revisualize thanks
CamperBot
@camperbot
Aug 06 2016 00:25
st3ps sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1554 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 06 2016 00:25
```js [SHIFT+ENTER]
// your code here
```[CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
Diego Mayer
@Chrono79
Aug 06 2016 00:26
@revisualize find some project you would like to do, keep it simple and develop it. That'll show you how ready you are
Joel Santos
@St3ps
Aug 06 2016 00:28
Error: cannot call methods on slider prior to initialization; attempted to call method 'value'
I'm getting this error. I'm working with Jquery UI, and the code i've got is...well, it's a bit lengthy. So, i mean, is there anything I can do to assure that a Jquery UI initializes in the right order? I was thinking $(document).ready but it's not working proper
RobinAnderssonCode
@RobinAnderssonCode
Aug 06 2016 00:30

Hey guys. I need a little help here. My function is returning exactly what is asked, but it still doesn't pass the test.

function largestOfFour(arr) {
  var tmp = 0;
  var index = -3;
  var index2 = 0;
  var array = [];
  var abort = false;

  for (var i = 0; i < arr.length-index && !abort; i++){
    for(var j = 0; j < arr[i].length && !abort; j++){
      if (arr[i][j] > tmp){
        tmp = arr[i][j];

        if (index > 4) {
          abort = true;

        }
      }
      array[index2] = [tmp];
    }
    index++;
    index2++;
  }  

  return array;
}

largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]);

This returns: [[9], [35], [97], [1000000]]) which is what is asked by one of the tests. Any ideas?

Return Largest Numbers in Arrays is the name of the test
Stephen James
@sjames1958gm
Aug 06 2016 00:31
@RobinAnderssonCode Does it fail the second test?
RobinAnderssonCode
@RobinAnderssonCode
Aug 06 2016 00:31
Yeah
Stephen James
@sjames1958gm
Aug 06 2016 00:31
@RobinAnderssonCode Your tmp needs to be reset between loops.
RobinAnderssonCode
@RobinAnderssonCode
Aug 06 2016 00:31
gives null on the second array for some reason. Haven't figured it out yet
@sjames1958gm ok thanks!
CamperBot
@camperbot
Aug 06 2016 00:32
robinanderssoncode sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2374 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
RobinAnderssonCode
@RobinAnderssonCode
Aug 06 2016 00:32
How come? I dont see the difference
Stephen James
@sjames1958gm
Aug 06 2016 00:33
@RobinAnderssonCode If tmp is not reset then nothing in the inner array may be larger.
tylerprosper
@removed~tylerprosper
Aug 06 2016 00:34
Hey guys, I have a question about a pretty minor detail in my code.
What is the difference, in the second line of my code, between adding a space between the quotation marks in the .split() and not. The code does not execute properly while there is no space between the quotations yet works while there is. Can anybody explain?
function findLongestWord(str) {
  var longestStr =str.split(' ');  /*<--- this is the "space" I'm referring to */

  newArray = longestStr.sort(function (a, b){
  return b.length - a.length; });

  return newArray[0].length;
}


findLongestWord("The quick brown fox jumped over the lazy dog");
RobinAnderssonCode
@RobinAnderssonCode
Aug 06 2016 00:37
@sjames1958gm That worked. Fixed the null value on test 2. Test 2 is now returning what is asked for, but Im still not passing it
````js
Phil
@mremotoo
Aug 06 2016 00:39
question,
regarding this code;
function findLongestWord(str) {
  var a = str.split(' ');
  var b = 0;

  for (var i = 0; i < a.length; i++) {
    if (a[i].length > b) {
      b = a[i].length;
    }
  }

  return b;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
RobinAnderssonCode
@RobinAnderssonCode
Aug 06 2016 00:40

function largestOfFour(arr) {
  var tmp = 0;
  var index = -3;
  var index2 = 0;
  var array = [];
  var abort = false;

  for (var i = 0; i < arr.length-index && !abort; i++){

    for(var j = 0; j < arr[i].length && !abort; j++){
      if (arr[i][j] > tmp){
        tmp = arr[i][j];

        if (index > 4) {
          abort = true;

        }
      }
      array[index2] = [tmp];
    }
    index++;
    index2++;
    tmp = 0;
  }  

  return array;
}

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
For reference. returning everything accordning to the checks. still not passing though. Am I missing something?
Phil
@mremotoo
Aug 06 2016 00:41
I have a question regarding a code pls
BeefHazard
@BeefHazard
Aug 06 2016 00:41
@RobinAnderssonCode your code is a slaughterhouse. You're thinking waaayyy too complicated
thinkC
@thinkC
Aug 06 2016 00:42

Diego Mayer
@Chrono79
Aug 06 2016 00:42
@RobinAnderssonCode are you sure it should return [[9], [35], [97], [1000000]] and not [9, 35, 97, 1000000]?
bitgrower
@bitgrower
Aug 06 2016 00:42
@RobinAnderssonCode agree with @BeefHazard
thinkC
@thinkC
Aug 06 2016 00:43
pls help
// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if (prop !== "tracks" && value !== ""){
    collection[id][prop] = value;
  }else if(prop ==="tracks"){
    collection[id][prop].push(value);
  }else if(value ==="") {
    delete collection[id][prop];
  }else{
    delete collection[id][prop];
  }




  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
bitgrower
@bitgrower
Aug 06 2016 00:43
@thinkC let me guess, it's passing everything but test case #2 ?
thinkC
@thinkC
Aug 06 2016 00:44
@bitgrower case 2 and the last
Diego Mayer
@Chrono79
Aug 06 2016 00:44
@RobinAnderssonCode Look: largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]) should return [9, 35, 97, 1000000]
Not [[9], [35], [97], [1000000]]
RobinAnderssonCode
@RobinAnderssonCode
Aug 06 2016 00:45
Ah, thanks
bitgrower
@bitgrower
Aug 06 2016 00:46
okay ... let's tackle test case #2 ... for test case #2, look at the data structure ... you'll see it does not have a tracks property, so you need to add one ... and, in order to add a tracks property, you need to give it a value ... in this case, you want the value to be an array ... so there are a couple of ways to go from there after that ...
thinkC
@thinkC
Aug 06 2016 00:47
ok
Abhisek Pattnaik
@abhisekp
Aug 06 2016 00:48
.
bitgrower
@bitgrower
Aug 06 2016 00:48
take that, get test case #2 to pass, and you may get an insight into what you need to do to pass the last test case ...
Diego Mayer
@Chrono79
Aug 06 2016 00:51
@thinkC Someone could want to delete tracks, but your code won't do that
thinkC
@thinkC
Aug 06 2016 00:54
ok @Chrono79 , @bitgrower ..thanks
bitgrower
@bitgrower
Aug 06 2016 00:56
@camperbot appears to be sleeping ...
Diego Mayer
@Chrono79
Aug 06 2016 00:56
I think it was because the dots
Alexander Køpke
@alexanderkopke
Aug 06 2016 00:56
or the .. caused it
bitgrower
@bitgrower
Aug 06 2016 00:56
oh yeah, probably so ...
Alexander Køpke
@alexanderkopke
Aug 06 2016 00:57
..thanks @Chrono79 @bitgrower
CamperBot
@camperbot
Aug 06 2016 00:57
alexanderkopke sends brownie points to @chrono79 and @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1168 | @bitgrower |http://www.freecodecamp.com/bitgrower
:star2: 1768 | @chrono79 |http://www.freecodecamp.com/chrono79
bitgrower
@bitgrower
Aug 06 2016 00:57
good catch ... :) tx @Chrono79
CamperBot
@camperbot
Aug 06 2016 00:57
bitgrower sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1769 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Aug 06 2016 00:57
np ;)
Alexander Køpke
@alexanderkopke
Aug 06 2016 00:57
worked for me oO
bitgrower
@bitgrower
Aug 06 2016 00:57
:)
thanks @alexanderkopke
CamperBot
@camperbot
Aug 06 2016 00:57
bitgrower sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:cookie: 706 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Diego Mayer
@Chrono79
Aug 06 2016 00:57
@alexanderkopke ..thanks
Alexander Køpke
@alexanderkopke
Aug 06 2016 00:57
we has da powa :)
bitgrower
@bitgrower
Aug 06 2016 00:57
LOL ...
Diego Mayer
@Chrono79
Aug 06 2016 00:58
..thanks @alexanderkopke
CamperBot
@camperbot
Aug 06 2016 00:58
chrono79 sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:cookie: 707 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Diego Mayer
@Chrono79
Aug 06 2016 00:59
camperbot needs a code revision and a change of oil
Abhisek Pattnaik
@abhisekp
Aug 06 2016 01:00
.
Alexander Køpke
@alexanderkopke
Aug 06 2016 01:00
This message was deleted
This message was deleted
Alexander Køpke
@alexanderkopke
Aug 06 2016 01:06
https://youtu.be/WFR3lOm_xhE watson rules. Is it real? oO
Eddie
@Ndaraya
Aug 06 2016 01:07
hey guys How I need some help with JavaScript escape sequences...exercise 143
Abhisek Pattnaik
@abhisekp
Aug 06 2016 01:09
@Ndaraya you need to use backslash to use the escape sequences i.e. to give unusual meaning to the usual letters
@Ndaraya e.g. n is a normal lower case letter n
but when used with a backslash, i.e. \n, it has a special meaning i.e. it represents a newline character
@Ndaraya So when the string is processed later, then computer knows that when it sees this special thing, it will insert a line break :D
Eddie
@Ndaraya
Aug 06 2016 01:13
@abhisekp heres my code...
var myStr="FirstLine\nSecondLine\rThirdLine";
I'm getting errors on the first and fourth task.
Moisés Man
@moigithub
Aug 06 2016 01:14
i think it should have some escaped backslashes too @Ndaraya
Abhisek Pattnaik
@abhisekp
Aug 06 2016 01:17
Eddie
@Ndaraya
Aug 06 2016 01:18
FirstLinenewline\n\SecondLine\rThirdLine
Abhisek Pattnaik
@abhisekp
Aug 06 2016 01:19
@Ndaraya \n represents newline
@Ndaraya and how do you represent backslash? backslash in the string must be special because it is used to mark other characters special.
So it is also special and must be used preceded by a backslash
@Ndaraya and you need two backslashes
one backslash after the newline character
another before carriage return
Usman
@halohah
Aug 06 2016 01:23
Hey guys! Does any one know why this:
var myStr = "FirstLine\n\SecondLine\\nThirdLine"
doesn't work?
Abhisek Pattnaik
@abhisekp
Aug 06 2016 01:24
@halohah :point_up: August 6, 2016 6:49 AM
Usman
@halohah
Aug 06 2016 01:26
\n doesn't seem to work for me anyhow
like it wont make a new line
Shreya Pujari
@pujarishreya
Aug 06 2016 01:27
Try this: "FirstLine\n\SecondLine\\rThirdLine"
Two backslash before SecondLine and three backslash after SecondLine.... Not able to add it like that here. It Auto corrects in that way!!... :eyes:
Coy Sanders
@coymeetsworld
Aug 06 2016 01:29
try using gitter formatting
help format
CamperBot
@camperbot
Aug 06 2016 01:29

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Usman
@halohah
Aug 06 2016 01:29
Alright thanks!
Coy Sanders
@coymeetsworld
Aug 06 2016 01:29
@halohah might be because you're missing a semi-colon at the end too
Usman
@halohah
Aug 06 2016 01:30
How do I send browne points again?
Shreya Pujari
@pujarishreya
Aug 06 2016 01:32
@coymeetsworld Thanks..
CamperBot
@camperbot
Aug 06 2016 01:32
pujarishreya sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1295 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Eddie
@Ndaraya
Aug 06 2016 01:38
<"FirstLine\n\SecondLine\\rThirdLine">
Brandon Bowers
@Bowers96
Aug 06 2016 01:38
function isEqual(a,b) {
  return a === b;

}
// Change these values to test
isLess(10, 15);
Anybody know what code I am missing?
Fix the function isLess to remove the if/else statements.
Eddie
@Ndaraya
Aug 06 2016 01:39
None of the suggestions are working for me.
var myStr="FirstLine\n\SecondLine\\rThirdLine";
Brandon Bowers
@Bowers96
Aug 06 2016 01:39
?
@Ndaraya Question name?
Anybody know what I'm missing in my code?
Shreya Pujari
@pujarishreya
Aug 06 2016 01:47
'FirstLine
Eddie
@Ndaraya
Aug 06 2016 01:48
Escape sequences in strings @Bowers96
Moisés Man
@moigithub
Aug 06 2016 01:48
@Ndaraya this is a escaped backslash \\
and this is a escaped newline \n
if ur string requires.. 2 backslash followed by 2 newlines it should be like this \\\\\n\n
Shreya Pujari
@pujarishreya
Aug 06 2016 01:48
'FirstLine\n\SecondLine\\rThirdLine';
@Ndaraya ```
Brandon Bowers
@Bowers96
Aug 06 2016 01:48
I think you got everything right, you just need single quotes instead of double @Ndaraya
.*
Shreya Pujari
@pujarishreya
Aug 06 2016 01:49
Before SecondLine add two \ and after SecondLine add three \
that should solve the problem. Everything else looks fine!
Brandon Bowers
@Bowers96
Aug 06 2016 01:50
Can anyone help me?

function isLess(a, b) {
  // Fix this code
   return a === b;

}

// Change these values to test
isLess(15, 10);
Moisés Man
@moigithub
Aug 06 2016 01:50
@Bowers96 === mean equal to
the function name is isLess <-- hint ??
Shreya Pujari
@pujarishreya
Aug 06 2016 01:51
check for less than instead of equal to ..... @Bowers96
Brandon Bowers
@Bowers96
Aug 06 2016 01:52
Perfect thank you guys. @pujarishreya @moigithub
CamperBot
@camperbot
Aug 06 2016 01:52
bowers96 sends brownie points to @pujarishreya and @moigithub :sparkles: :thumbsup: :sparkles:
:cookie: 179 | @pujarishreya |http://www.freecodecamp.com/pujarishreya
:star2: 1814 | @moigithub |http://www.freecodecamp.com/moigithub
Eddie
@Ndaraya
Aug 06 2016 01:53
@pujarishreya that worked! Thank you so much!
CamperBot
@camperbot
Aug 06 2016 01:53
ndaraya sends brownie points to @pujarishreya :sparkles: :thumbsup: :sparkles:
:cookie: 180 | @pujarishreya |http://www.freecodecamp.com/pujarishreya
Shreya Pujari
@pujarishreya
Aug 06 2016 01:53
Sure! Welcome.. :smile:
has anyone finished teh Golf Code?
i am not understanding what we need to do
this is my code
Brandon Bowers
@Bowers96
Aug 06 2016 02:00
@quemando Yes.
edgarmontes
@edgarmontes
Aug 06 2016 02:01

function golfScore(par, strokes) {
// Only change code below this line
switch(par, strokes){
case (strokes == 1):
return "Hole-in-one!";
break;
case strokes <= par-2:
return "Eagle";
break;
case strokes == par-1:
return "Birdie";
break;
case strokes==par:
return "Par";
break;
case strokes==par+1:
return "Bogey";
break;
case strokes==par+2:
return "Double Bogey";
break;
case strokes >= par + 3:
return "Go Home!";
break;
}

return "Change Me";
// Only change code above this line
}

// Change these values to test
golfScore(4, 1);

Brandon Bowers
@Bowers96
Aug 06 2016 02:02
Yeah you have a lot of errors on your text editor you need to address first but the code is almost there. @quemando
edgarmontes
@edgarmontes
Aug 06 2016 02:02
any hints?
Brandon Bowers
@Bowers96
Aug 06 2016 02:04
@quemando Your if statement is wrong....
edgarmontes
@edgarmontes
Aug 06 2016 02:04
thanks
Coy Sanders
@coymeetsworld
Aug 06 2016 02:04
are you supposed to be using case/switch for that challenge?
thought it was if/else if statements
but yeah syntax has some issues
edgarmontes
@edgarmontes
Aug 06 2016 02:05
i am guessing
Brandon Bowers
@Bowers96
Aug 06 2016 02:05
if /else. @coymeetsworld
Coy Sanders
@coymeetsworld
Aug 06 2016 02:05
yeah
Moisés Man
@moigithub
Aug 06 2016 02:05
switch only use 1 expression or variable..
not multiples var comma separated
Brandon Bowers
@Bowers96
Aug 06 2016 02:05
He/She has the right idea. @coymeetsworld
edgarmontes
@edgarmontes
Aug 06 2016 02:05
ok, will try to redo it with if/else
thansk you
Coy Sanders
@coymeetsworld
Aug 06 2016 02:06
prev 3 lessons cover if/else statements, so idea is to use those
then after that it covers switch statements
Moisés Man
@moigithub
Aug 06 2016 02:06
u can write
switch(true){
//...cases
}
Coy Sanders
@coymeetsworld
Aug 06 2016 02:06
should be if/else statements at that point @moigithub, makes sense to use that based on the challenge too
Moisés Man
@moigithub
Aug 06 2016 02:06
yea.. just saying.. kinda boored hehe
Coy Sanders
@coymeetsworld
Aug 06 2016 02:07
all finished with FCC? got all 3 certs? :)
Moisés Man
@moigithub
Aug 06 2016 02:07
yep
Coy Sanders
@coymeetsworld
Aug 06 2016 02:07
oh lol
nice
Moisés Man
@moigithub
Aug 06 2016 02:07
like 1 month ago.. think im forgetting stuff.. looking something to do
Coy Sanders
@coymeetsworld
Aug 06 2016 02:08
are you going to work on any of the nonprofit projects? do they seek you out for that?
edgarmontes
@edgarmontes
Aug 06 2016 02:08
@coymeetsworld are you working as programmer?
Coy Sanders
@coymeetsworld
Aug 06 2016 02:09
nope, sysadmin @quemando. Been doing FCC since start of year just got FrontEnd cert maybe few weeks ago
want to get back into it though, been on and off of it since college
Moisés Man
@moigithub
Aug 06 2016 02:09
...i think they (the person who manage the NP) are busy atm.. so its taking a bit
there are few others who finished the 3certs before me who still waiting too
...probably i should go job hunting
Coy Sanders
@coymeetsworld
Aug 06 2016 02:10
lol that's interesting @moigithub, guess they need more PMs than devs at this point
yeah or work on your own projects
edgarmontes
@edgarmontes
Aug 06 2016 02:10
so you go to a waiting list to work in the non-profit projects?
Howl
@karst10607
Aug 06 2016 02:24
That's because I learn javascript in an broken schedule on FCC. Does anyone here do so too? So I forgot push command that I learned two weeks ago.
Is is alright to learn Javascript while still learning html knowledge on FCC.
?
Coy Sanders
@coymeetsworld
Aug 06 2016 02:26
html/css section is fairly short @karst10607, if you haven't finished those tracks i would do that first as they're much easier than JS
Adithya Reddy
@tallpants
Aug 06 2016 02:28
Hey guys, I'm coming across some code that has something like ``` if (+values[index] <= .... ````
what does that mean?
the + before the variable name
Kevin Murphy
@kaym0
Aug 06 2016 02:28
Finally got around to building a business card style page. Checkout kaymo.org! Super excited about it. Haha
It's basically like i++ but backwards
Coy Sanders
@coymeetsworld
Aug 06 2016 02:29
its only one plus @kaym0
Kevin Murphy
@kaym0
Aug 06 2016 02:29
It still works the same
Adithya Reddy
@tallpants
Aug 06 2016 02:29
so like ++i in C?
Kevin Murphy
@kaym0
Aug 06 2016 02:29
Yeah
Adithya Reddy
@tallpants
Aug 06 2016 02:30
Does it increaes the value first and then check?
Kevin Murphy
@kaym0
Aug 06 2016 02:30
Actually I may be wrong. I think I'm thinking of ++. What is the exact code
Coy Sanders
@coymeetsworld
Aug 06 2016 02:30
yes, its not the increment operator, which is two pluses
i don't think that does anything
Moisés Man
@moigithub
Aug 06 2016 02:31
if u have "1" + 1 u will get "11"
prepending +"1" +1 u will get 2
Kevin Murphy
@kaym0
Aug 06 2016 02:32
Unless it wss like an output like console.log("the answer is " +value[index])
Coy Sanders
@coymeetsworld
Aug 06 2016 02:32
@moigithub :thumbsup:
Moisés Man
@moigithub
Aug 06 2016 02:32
soo prepending that + is like using parseInt(variable)
Adithya Reddy
@tallpants
Aug 06 2016 02:33
just turns it into a number?
Moisés Man
@moigithub
Aug 06 2016 02:33
ye :)
Adithya Reddy
@tallpants
Aug 06 2016 02:33
that seems kinda stupid
Moisés Man
@moigithub
Aug 06 2016 02:33
"a shorthand"
Howl
@karst10607
Aug 06 2016 02:33
@coymeetsworld I Got it, Thanks. This is a useful suggestion for me. Very fair in my case. That;s a more step to step and practical way for me.
CamperBot
@camperbot
Aug 06 2016 02:33
karst10607 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1298 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Aug 06 2016 02:34
yeah, also retaining information easier if you try to be consistent @karst10607, try not to take too much time off
at least when you're starting to learn, try to do a little bit each day, can skip one or two days a week but key is consistency
Howl
@karst10607
Aug 06 2016 02:34
Got this. This is like in the school when learning algebra or harder math in high school.
silver537
@silver537
Aug 06 2016 02:36
Not even close
.
Moisés Man
@moigithub
Aug 06 2016 02:37
@adithyakreddy well.. if u try to get values from input boxes (html) values usually are strings....
so a convertion needed if u wanna work with numbers
xzho2604
@xzho2604
Aug 06 2016 02:49
Hi Guys, I am currently working on a pset on Google map API, I dont quite understand the difference between $getjason(data, textstatus,jqxhr), so what is the difference between data and jqxhr? they all seems to be the data that returned from the server right?
Also when you create a new google map : new google.maps.Map(canvas, options);
so google is the class, maps is the subclass of google, and then Map is another subclass of maps?
just started object class orientated programming ,try to get myself familiar with object and class. ..
thanks in advance!
1p2r3a
@1p2r3a
Aug 06 2016 03:11

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Abhisek Pattnaik
@abhisekp
Aug 06 2016 03:11
@xzho2604 data is the actual response data and jqXHR is the XHR object added with some jQ soup
1p2r3a
@1p2r3a
Aug 06 2016 03:12
how i want to fill in the blanks
Cole Logan
@CocaWinkle
Aug 06 2016 03:12
can someone explain to me what json is
1p2r3a
@1p2r3a
Aug 06 2016 03:13
json is structure
Cole Logan
@CocaWinkle
Aug 06 2016 03:13
keep going @1p2r3a
1p2r3a
@1p2r3a
Aug 06 2016 03:15
wordBlanks("","","","") should return a string.
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
can u anyone explain me
bradulz
@bradulz
Aug 06 2016 03:17
@1p2r3a you gotta seperate the words with a space
1p2r3a
@1p2r3a
Aug 06 2016 03:19
i didnt understand this can u send me a code i will learn
Vikrant Singh
@VikrantSingh13
Aug 06 2016 03:20
@1p2r3a just return all the words with space added in between them
Abhisek Pattnaik
@abhisekp
Aug 06 2016 03:20
@1p2r3a how are you concatenating the words?
1p2r3a
@1p2r3a
Aug 06 2016 03:20
"dog "+ " "cat"
Abhisek Pattnaik
@abhisekp
Aug 06 2016 03:21
@CocaWinkle JSON is a data exchange format.
A pretty basic format. You can read the specification here :point_right: http://json.org
Vikrant Singh
@VikrantSingh13
Aug 06 2016 03:21
return a + " " + b + " " + c  + " " + d;
just replace a,b,c,d with the variable names
1p2r3a
@1p2r3a
Aug 06 2016 03:21
oh ok
Abhisek Pattnaik
@abhisekp
Aug 06 2016 03:22
@1p2r3a you need to concat the variables as @VikrantSingh13 says but also don't forget to fill in some words in the sentence ;)
Nupur Gorian
@NupurGorian
Aug 06 2016 03:24
can anyone tell why the following code is not working
switch (val) {
case a:
answer = "apple";
break;
case b:
answer = "bird";
break;
case c:
answer = "cat";
break;
default:
answer = "stuff";
}
AzeddineDev
@AzeddineDev
Aug 06 2016 03:25
@NupurGorian which language is this?
Abhisek Pattnaik
@abhisekp
Aug 06 2016 03:25
@NupurGorian cases only accept an expression.
Here a, b, and c are variables which probably don't exist
1p2r3a
@1p2r3a
Aug 06 2016 03:25
wordBlanks("dog", "big", "ran", "quickly");
return("A"+""+"is"+""+"and"+""+"very"+"");
whether it is correct @abhisekp
Abhisek Pattnaik
@abhisekp
Aug 06 2016 03:25
@AzeddineDev JS? ;)
Nupur Gorian
@NupurGorian
Aug 06 2016 03:26
the full code is @AzeddineDev

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = "apple";
break;
case b:
answer = "bird";
break;
case c:
answer = "cat";
break;
default:
answer = "stuff";
}

// Only change code above this line
return answer;
}

// Change this value to test
switchOfStuff("a");

pietrosparks
@pietrosparks
Aug 06 2016 03:26
Hi guys
please i need help in "Counting Cards"
Abhisek Pattnaik
@abhisekp
Aug 06 2016 03:27
@1p2r3a you need to return from INSIDE the function because a function is a closed block which takes some input, processes them and gives an output
INPUT -> PROCESS -> OUTPUT
Nupur Gorian
@NupurGorian
Aug 06 2016 03:27
@abhisekp yes it is js
AzeddineDev
@AzeddineDev
Aug 06 2016 03:27
@NupurGorian sorry I have no idea
Norvin Burrus
@ndburrus
Aug 06 2016 03:27

@CocaWinkle
json

JSON
JSON (canonically pronounced /ˈdʒeɪsən/ jay-sən;1 sometimes JavaScript Object Notation) is an open-standard format that uses human-readable text to transmit data objects consisting of attribute–value pairs. It is the most common data format used for asynchronous browser/server communication (AJAJ), largely replacing XML which is used by AJAX.

Abhisek Pattnaik
@abhisekp
Aug 06 2016 03:27
@AzeddineDev what language are you comfortable with?
@ndburrus :eyes:
AzeddineDev
@AzeddineDev
Aug 06 2016 03:28
@abhisekp html - css / for the moment
Abhisek Pattnaik
@abhisekp
Aug 06 2016 03:28
@AzeddineDev ah! great :sparkles:
Norvin Burrus
@ndburrus
Aug 06 2016 03:28
@NupurGorian lesson?
AzeddineDev
@AzeddineDev
Aug 06 2016 03:29
@abhisekp finished a lot of projects
and still looking for more...
Abhisek Pattnaik
@abhisekp
Aug 06 2016 03:30
@AzeddineDev awesome! :D
can you please some of them?
pietrosparks
@pietrosparks
Aug 06 2016 03:30
anybody??
Norvin Burrus
@ndburrus
Aug 06 2016 03:30
@pietrosparks review/check the order of the return information
AzeddineDev
@AzeddineDev
Aug 06 2016 03:30
@abhisekp No! it's a lessons project..following lessons
Abhisek Pattnaik
@abhisekp
Aug 06 2016 03:31
@AzeddineDev ok. cool :sunglasses:
pietrosparks
@pietrosparks
Aug 06 2016 03:31
@ndburrus what should i be looking out for? it seems not to even read the count values
Norvin Burrus
@ndburrus
Aug 06 2016 03:32
@pietrosparks i would remove the returns from the if/else statement, and use a variable instead
pietrosparks
@pietrosparks
Aug 06 2016 03:39
@ndburrus please i dont understand
@ndburrus solved thanks
CamperBot
@camperbot
Aug 06 2016 03:43
pietrosparks sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 1368 | @ndburrus |http://www.freecodecamp.com/ndburrus
xzho2604
@xzho2604
Aug 06 2016 03:43
thanks @abhisekp! so what is the application of jqXHR? It looks like most of the time ,we include it in the function argument without using it and all we need is the data from the JASON that returned right?
CamperBot
@camperbot
Aug 06 2016 03:43
xzho2604 sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star2: 2840 | @abhisekp |http://www.freecodecamp.com/abhisekp
mossygr
@mossygr
Aug 06 2016 03:47

<script>
$(document).ready(function() {
$("#getMessage").on("click", function(){
$(".message").html("Here is the message");
// Only change code below this line.

// Only change code above this line.
});
});
</script>

<div class="container-fluid">
<div class = "row text-center">
<h2>Cat Photo Finder</h2>
</div>
<div class = "row text-center">
<div class = "col-xs-12 well message">
The message will go here
</div>
</div>
<div class = "row text-center">
<div class = "col-xs-12">
<button id = "getMessage" class = "btn btn-primary">
Get Message
</button>
</div>
</div>
</div>

To chane button message why we write $(".message").html("Here is the message");
Norvin Burrus
@ndburrus
Aug 06 2016 03:48
@mossygr lesson?
mossygr
@mossygr
Aug 06 2016 03:48
And not $(".message").button("Here is the message");
Change Text with Click Events
Norvin Burrus
@ndburrus
Aug 06 2016 03:49

@mossygr are we adhering to these?

// Only change code below this line.

// Only change code above this line.

this line: $(".message").html("Here is the message");
needs to be placed/positioned correctly :sparkles:

jinyukuang
@jinyukuang
Aug 06 2016 03:49

hi everyone, I am stuck with this accessing nested objects. help me please? // Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents = ""; // Change this line

Anna
@Anntol
Aug 06 2016 03:50
@jinyukuang you have example, what have you tried?
Norvin Burrus
@ndburrus
Aug 06 2016 03:52

@jinyukuang
we need to follow the example code format, here:

ourStorage.cabinet["top drawer"].folder2;  // "secrets"
ourStorage.desk.drawer; // "stapler"

this may be useful:

@mossygr how are we doing?
mossygr
@mossygr
Aug 06 2016 03:53
I passed but i dont understand why
We use .html instead of .button
Thanks
Vikrant Singh
@VikrantSingh13
Aug 06 2016 03:54
^oh and I was like what is .button now? lol
Anna
@Anntol
Aug 06 2016 03:56
@mossygr it is easy - there is no method "button" in jquery - just check documentation if you are unsure
mossygr
@mossygr
Aug 06 2016 03:56
Aaa ok thanks
jinyukuang
@jinyukuang
Aug 06 2016 04:02
@Anntol here is what I tried
0b4cL
@0b4cL
Aug 06 2016 04:02
on Iterate with JavaScript For Loops I passed with the code:

var myArray = [];

for (var i = 1; i < 6; i++) {
myArray.push(i);
}

Does var increase the starting point each time I raise it?
  • why does var
Anna
@Anntol
Aug 06 2016 04:05
@0b4cL you ask it by using condition i++
DJ
@qualitymanifest
Aug 06 2016 04:05
@0b4cL var i = 1 just initializes the variable i to 1. i < 6 tells the loop to run as long as i is lower than 6. i++ increases i by one with each run of the loop.
Anna
@Anntol
Aug 06 2016 04:06
@jinyukuang I do not see your code
0b4cL
@0b4cL
Aug 06 2016 04:07
Oh I see.
:smile: guys
@Anntol @qualitymanifest How do I put the text editor code in my help questions?
Anna
@Anntol
Aug 06 2016 04:10
help code
CamperBot
@camperbot
Aug 06 2016 04:10

:point_right: challenge comment your javascript code [wiki]

Challenge Comment your JavaScript Code

Comments are a great way to leave notes to yourself and to other people who will later need to figure out what it does. Any code in it will be ignored.

Let's take a look at the two ways you can write comments in JavaScript.

  • The double-slash comment will comment out the remainder of the text on the current line:

    // This is a comment.

  • The slash-star-star-slash comment will comment out everything between the /* and the */ characters:

    /* This is also a comment */

:pencil: read more about challenge comment your javascript code on the FCC Wiki

Anna
@Anntol
Aug 06 2016 04:11
 (shift+enter for line break)
var code = "formatted";
@0b4cL click M on right side of your input box
0b4cL
@0b4cL
Aug 06 2016 04:13
hmm....
Abhisek Pattnaik
@abhisekp
Aug 06 2016 04:16
@xzho2604 jqXHR has got some useful info which you might need in your journey ahead :car: but not just yet... have patience ;)
@qualitymanifest we've not chatted since a long time :D
hi :wave:
bradulz
@bradulz
Aug 06 2016 04:18
$(function(){

var main = [];
$("#submit").on("click",function(){
    $("table#sudoku tr").each(function(){
        var thisRow = [];
        var tableData = $(this).find('input');
        tableData.each(function(){ 
        thisRow.push($(this).val());

        });
        main.push(tableData);
        });
console.log(JSON.stringify(main));
    });
});
trying to get convert table data to a 2d array. each <td> has just one <input> inside it. Whats wrong here? Its giving me weird results
DJ
@qualitymanifest
Aug 06 2016 04:26
@abhisekp yeah it's been a while! what are you working on currently? and how are your 5 cats?? :cat2::cat2::cat2::cat2::cat2:
Sumit Rana
@sumitrana12
Aug 06 2016 04:30

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

Abhisek Pattnaik
@abhisekp
Aug 06 2016 04:30
@qualitymanifest working on something great ;P
5 cats have been restricted to come inside. :cat:
Sumit Rana
@sumitrana12
Aug 06 2016 04:30
var myStr="FirstLine\n SecondLine\r ThirdLine"; // Change this line
can anyone help in this?
Abhisek Pattnaik
@abhisekp
Aug 06 2016 04:30
@sumitrana12 no space
@sumitrana12 and 2 backslashes
Sabrina Ferguson
@itsacoyote
Aug 06 2016 04:30
@sumitrana12 you're close, you've added the new lines and carriage return, but you need to add in the backslashes
DJ
@qualitymanifest
Aug 06 2016 04:31
@abhisekp something great like...?
Abhisek Pattnaik
@abhisekp
Aug 06 2016 04:31
@qualitymanifest like a web design.... with some functionality ... FCC project
Sumit Rana
@sumitrana12
Aug 06 2016 04:33
@itsacoyote how ?
DJ
@qualitymanifest
Aug 06 2016 04:33
@abhisekp like a new "zipline" that focuses more on the design aspect?
(yes i know "zipline" is old terminology :wink: )
Sabrina Ferguson
@itsacoyote
Aug 06 2016 04:33
@sumitrana12 well you use a \ for things like \n and \r, so just one \ will be removed in the string. You'll need to escape it by adding another \ to keep it in the string. \
NixonRichard
@NixonRichard
Aug 06 2016 04:37
My father wonder what is this for ? any one have an answer
this may looks weird for him and he think it s very easy to make the simon game
DJ
@qualitymanifest
Aug 06 2016 04:38
@NixonRichard start a new pen on codepen, hand the computer to him and tell him to make a simon game
Sumit Rana
@sumitrana12
Aug 06 2016 04:39
@itsacoyote not worked
Abhisek Pattnaik
@abhisekp
Aug 06 2016 04:39
@qualitymanifest an old zipline which I ignored :pensive:
but yes you're right. I'm fixing my design aspects :dancer:
Sumit Rana
@sumitrana12
Aug 06 2016 04:39
@itsacoyote look at code
Sabrina Ferguson
@itsacoyote
Aug 06 2016 04:40
var sample = "\\Something with backslahses around it\\"
NixonRichard
@NixonRichard
Aug 06 2016 04:40
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArr = [];

  for (var i = 0 ; i <arr.length; i+=2) {
  return newArr.push(arr.slice(i,size));
}



}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
i wonder why this keep returning 1
Abhisek Pattnaik
@abhisekp
Aug 06 2016 04:41
@NixonRichard this is for changing the world around you one day
@NixonRichard in past people used to change the world by doing HARD work.
These days people change the world by doing SMART work
DJ
@qualitymanifest
Aug 06 2016 04:41
@abhisekp cool. yeah design is a weak point for me as well. i'm about to start the d3 challenges but i think i might skip ahead to node for a little bit, seems more interesting right now and i have no experience with node yet. i'd like to start helping with FCC github issues
Abhisek Pattnaik
@abhisekp
Aug 06 2016 04:42
@qualitymanifest go for D3 ... node is interesting but if you've lower designer brain like me, then better to go with design first.
I wish I had done that :pensive:
NixonRichard
@NixonRichard
Aug 06 2016 04:44
@abhisekp i read Elon Musk have been working 100 hours a week for 15 years
is that hard work ?
Abhisek Pattnaik
@abhisekp
Aug 06 2016 04:44
That is passion at work
NixonRichard
@NixonRichard
Aug 06 2016 04:44
wow
lol
silver537
@silver537
Aug 06 2016 04:45
@NixonRichard in your condition. i+=size
Abhisek Pattnaik
@abhisekp
Aug 06 2016 04:45
lol. weird :expressionless:
DJ
@qualitymanifest
Aug 06 2016 04:45
@abhisekp have you done anything with React yet?
Abhisek Pattnaik
@abhisekp
Aug 06 2016 04:45
Sidetracked with Angular2
NixonRichard
@NixonRichard
Aug 06 2016 04:45
it still returning 1
silver537
@silver537
Aug 06 2016 04:47
Dont return inside the loop.
NixonRichard
@NixonRichard
Aug 06 2016 04:47
okay
Abhisek Pattnaik
@abhisekp
Aug 06 2016 04:48
@qualitymanifest if you want something great, I can pm you something great ;)
NixonRichard
@NixonRichard
Aug 06 2016 04:48
i want to the best full stack developer
best of the best
DJ
@qualitymanifest
Aug 06 2016 04:48
@abhisekp do it!
Abhisek Pattnaik
@abhisekp
Aug 06 2016 04:48
I won't let you get on top of me @NixonRichard
I will be best :sunglasses:
:D
jk
Hesham Adel
@hellsinglord22
Aug 06 2016 04:49
u mean be the best,
Abhisek Pattnaik
@abhisekp
Aug 06 2016 04:49
one of the
NixonRichard
@NixonRichard
Aug 06 2016 04:50
nevermind lol
0b4cL
@0b4cL
Aug 06 2016 04:53
@Anntol Just saw the tip. Thank you.
CamperBot
@camperbot
Aug 06 2016 04:53
0b4cl sends brownie points to @anntol :sparkles: :thumbsup: :sparkles:
:cookie: 326 | @anntol |http://www.freecodecamp.com/anntol
xzho2604
@xzho2604
Aug 06 2016 05:08
ah , ha ! thanks @abhisekp ! I am looking forward to it :)
CamperBot
@camperbot
Aug 06 2016 05:08
xzho2604 sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star2: 2841 | @abhisekp |http://www.freecodecamp.com/abhisekp
Iuli
@IulianChirvasa
Aug 06 2016 05:15
hello
Abhisek Pattnaik
@abhisekp
Aug 06 2016 05:17
@IulianChirvasa **`FreeCodeCamp/CodeReview`**
jinyukuang
@jinyukuang
Aug 06 2016 05:17
@Anntol example: var ourStorage = {
"desk": {
"drawer": "stapler"
},
"cabinet": {
"top drawer": {
"folder1": "a file",
"folder2": "secrets"
},
"bottom drawer": "soda"
}
};
ourStorage.cabinet["top drawer"].folder2; // "secrets"
ourStorage.desk.drawer; // "stapler"

@Anntol so my code is // Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents = "maps"; // Change this line
myStorage.car.inside.["glove box"];

Abhisek Pattnaik
@abhisekp
Aug 06 2016 05:18
explain format
CamperBot
@camperbot
Aug 06 2016 05:18

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

NixonRichard
@NixonRichard
Aug 06 2016 05:19
im so bad at this chunky monkey challenge
aw
Anna
@Anntol
Aug 06 2016 05:21
@jinyukuang you are hardcoding "maps" - but should use your myStorage
jinyukuang
@jinyukuang
Aug 06 2016 05:21
Screen Shot 2016-08-05 at 10.20.52 PM.png
NixonRichard
@NixonRichard
Aug 06 2016 05:23
@Anntol did u pass te chunky monkey ?
Anna
@Anntol
Aug 06 2016 05:24
@jinyukuang besides you mix dot and bracket - it is incorrect
NixonRichard
@NixonRichard
Aug 06 2016 05:24
like this .inside["glove box"]
no dot before brackets
haha
Anna
@Anntol
Aug 06 2016 05:24
@NixonRichard yes
NixonRichard
@NixonRichard
Aug 06 2016 05:25
c mon
really ?
do u think it s easy ?
Anna
@Anntol
Aug 06 2016 05:27
@NixonRichard well not that easy, but not hard
Narendra Singh
@nakulrathore
Aug 06 2016 05:27

`var text = 1;
function factorialize(num) {
for (i = num; i > 0; i--) {
text = i*text;
}
return text;
}

factorialize(10);
`

:point_up: is this wrong | challenge - Factorialize a Number @all
Anna
@Anntol
Aug 06 2016 05:28
@nakulrathore do not use global variable
Narendra Singh
@nakulrathore
Aug 06 2016 05:29
but it didnt say that
Anna
@Anntol
Aug 06 2016 05:29
it is default option, it will say if you should
Narendra Singh
@nakulrathore
Aug 06 2016 05:29
This message was deleted
NixonRichard
@NixonRichard
Aug 06 2016 05:29
@nakulrathore can u pass with ur code ?
if not what did s the result ?
Narendra Singh
@nakulrathore
Aug 06 2016 05:30
@NixonRichard , nope but my code works
NixonRichard
@NixonRichard
Aug 06 2016 05:30
with all num ?
or just 10
Narendra Singh
@nakulrathore
Aug 06 2016 05:30
all
NixonRichard
@NixonRichard
Aug 06 2016 05:31
text shuold be declare inside the function
Narendra Singh
@nakulrathore
Aug 06 2016 05:32
@NixonRichard ty
CamperBot
@camperbot
Aug 06 2016 05:32
nakulrathore sends brownie points to @nixonrichard :sparkles: :thumbsup: :sparkles:
:cookie: 232 | @nixonrichard |http://www.freecodecamp.com/nixonrichard
Narendra Singh
@nakulrathore
Aug 06 2016 05:32
@Anntol ty
CamperBot
@camperbot
Aug 06 2016 05:32
nakulrathore sends brownie points to @anntol :sparkles: :thumbsup: :sparkles:
:cookie: 327 | @anntol |http://www.freecodecamp.com/anntol
Tilak Raj
@trdhiman
Aug 06 2016 05:37

hi friends , question in slasher flicker challenge :-
test :- slasher([1, 2, 3], 2);
case 1 . if i use "return arr.splice ( 0, howMany ) ;" , it gives result "[1,2]" .
case 2. but if I use "arr.splice ( 0, howMany ) ; & then call return arr ; " , it gives result "[3]"

why result varies ?????

Abhisek Pattnaik
@abhisekp
Aug 06 2016 05:37
.
jinyukuang
@jinyukuang
Aug 06 2016 05:38
@Anntol I figured it out. it should be gloveBoxContents = myStorage.car.inside["glove box"];
Anna
@Anntol
Aug 06 2016 05:38
@jinyukuang :+1:
jinyukuang
@jinyukuang
Aug 06 2016 05:38
thank you @Anntol :)
CamperBot
@camperbot
Aug 06 2016 05:38
jinyukuang sends brownie points to @anntol :sparkles: :thumbsup: :sparkles:
:cookie: 328 | @anntol |http://www.freecodecamp.com/anntol
NixonRichard
@NixonRichard
Aug 06 2016 05:38
hmm hmm
Anna
@Anntol
Aug 06 2016 05:39
@trdhiman splice function returns deleted part, while arr is what remains
NixonRichard
@NixonRichard
Aug 06 2016 05:40
 var chunked = [];
  while ( arr.length) {
    chunked.push(arr.splice(0,size));
  }
  return chunked;
}
anyone know why this worked with splice
but not with slice ?
kameswaran1795
@kameswaran1795
Aug 06 2016 05:41

I'm trying to create a Tumblr share button. When clicked it has to do this.
window.open('https://www.tumblr.com/widgets/share/tool?posttype=quote&content='+encodeURIComponent('this is quote')+'&caption='+encodeURIComponent('author goes here'),'')

But it's not working. Any idea why?

Anna
@Anntol
Aug 06 2016 05:43
@NixonRichard what you want it to do? 2 argument of slice = index at which to end extraction, but of splice Count of deleted items
Vikrant Singh
@VikrantSingh13
Aug 06 2016 05:43
Hello World!
CamperBot
@camperbot
Aug 06 2016 05:43

welcome to FreeCodeCamp @VikrantSingh13!

Vikrant Singh
@VikrantSingh13
Aug 06 2016 05:43
Hello World!
CamperBot
@camperbot
Aug 06 2016 05:43

welcome to FreeCodeCamp @VikrantSingh13!

Tilak Raj
@trdhiman
Aug 06 2016 05:58
@Anntol thanks for clarification ,,
CamperBot
@camperbot
Aug 06 2016 05:58
trdhiman sends brownie points to @anntol :sparkles: :thumbsup: :sparkles:
:cookie: 329 | @anntol |http://www.freecodecamp.com/anntol
NixonRichard
@NixonRichard
Aug 06 2016 06:01
hmm
stonefmagiecurata
@stonefmagiecurata
Aug 06 2016 06:16
@NixonRichard splice() mutates the array, so every iteration reduces your arrays length, slice does not
Narendra Singh
@nakulrathore
Aug 06 2016 06:17
passed all but this > palindrome("0_0 (: /-\ :) 0-0") should return true.

code:

function palindrome(str) {
  // Good luck!
  str1 = str.toLowerCase().replace(/[ _.,]/g,'').split('').reverse().join('');
  if(str.toLowerCase().replace(/[ _.,]/g,'') == str1){
    return true;
  }
  else{
    return false;
  }
}



palindrome("Eye");

:point_up: rough code @all

stonefmagiecurata
@stonefmagiecurata
Aug 06 2016 06:22
@nakulrathore (: /-\ :) are not included in your regex
Narendra Singh
@nakulrathore
Aug 06 2016 06:22
This message was deleted
@stonefmagiecurata ty
CamperBot
@camperbot
Aug 06 2016 06:24
nakulrathore sends brownie points to @stonefmagiecurata :sparkles: :thumbsup: :sparkles:
:cookie: 289 | @stonefmagiecurata |http://www.freecodecamp.com/stonefmagiecurata
Sumit Rana
@sumitrana12
Aug 06 2016 06:25
hey can anyone resolve this? Help>!
Joshua Sullivan
@jaesulli95
Aug 06 2016 06:25
@sumitrana12 i got you
Sumit Rana
@sumitrana12
Aug 06 2016 06:26
@jaesulli95 Please help me out.!!
stonefmagiecurata
@stonefmagiecurata
Aug 06 2016 06:26
@nakulrathore check what \W is, so you can make your regex shorter
Joshua Sullivan
@jaesulli95
Aug 06 2016 06:27
@sumitrana12 var myStr="FirstLine\n\SecondLine\\rThirdLine"
oh hell
the interpreters on these programs
Narendra Singh
@nakulrathore
Aug 06 2016 06:27
@stonefmagiecurata thanx
CamperBot
@camperbot
Aug 06 2016 06:27
nakulrathore sends brownie points to @stonefmagiecurata :sparkles: :thumbsup: :sparkles:
:warning: nakulrathore already gave stonefmagiecurata points
Joshua Sullivan
@jaesulli95
Aug 06 2016 06:27
kk so when you need to do a backslash you need to do \ because its an escape character
\\
that symbol, and basically place that where in the text
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
where it says backslash do \\
Manjot Singh
@msingh18
Aug 06 2016 06:30
Callback method executes after the earlier action has been completed, right?
I am talking about jQuery here
Sumit Rana
@sumitrana12
Aug 06 2016 06:32
@jaesulli95 not done :worried:
Joshua Sullivan
@jaesulli95
Aug 06 2016 06:32
link it to me one more time please
jsut needed to add another backslash on to the backslash characters to escape it
i didnt realize \\ -> \ when you put it into gitter
stonefmagiecurata
@stonefmagiecurata
Aug 06 2016 06:34
@msingh18 only if it's an effect or belongs to the fx object
Sumit Rana
@sumitrana12
Aug 06 2016 06:35
@jaesulli95 thanks buddy got that..!! :clap:
CamperBot
@camperbot
Aug 06 2016 06:35
sumitrana12 sends brownie points to @jaesulli95 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for jaesulli95
Manjot Singh
@msingh18
Aug 06 2016 06:35
@stonefmagiecurata can you please explain briefly what is an fx object?
stonefmagiecurata
@stonefmagiecurata
Aug 06 2016 06:38
@msingh18 the action you want completed, needs to be a method of the FX ( jquery effects object ). If it's an effect then the callback function will run only after the action/effect finished
@msingh18 what function are you using?
Manjot Singh
@msingh18
Aug 06 2016 06:40
@stonefmagiecurata not related to any specific function, was just looking into some jQuery stuff
@stonefmagiecurata thanks a lot
CamperBot
@camperbot
Aug 06 2016 06:40
msingh18 sends brownie points to @stonefmagiecurata :sparkles: :thumbsup: :sparkles:
:cookie: 290 | @stonefmagiecurata |http://www.freecodecamp.com/stonefmagiecurata
stonefmagiecurata
@stonefmagiecurata
Aug 06 2016 06:41
@msingh18 oh, I thought your callback function wans't firing at the needed time
@msingh18 so if you use any effects, the callback function will fire only after the effect is finished
Manjot Singh
@msingh18
Aug 06 2016 06:42
@stonefmagiecurata got it, and also came to know that something like fx objects also exist in jQuery
stonefmagiecurata
@stonefmagiecurata
Aug 06 2016 06:44
@msingh18 yeah, you can extend it and make your own effects
Manjot Singh
@msingh18
Aug 06 2016 06:45
@stonefmagiecurata okay, I have encountered some code snippet like jQuery.each. What is jQuery here, some kind of an object?
stonefmagiecurata
@stonefmagiecurata
Aug 06 2016 06:46
@msingh18 yeah jQuery is an object
Cedric Matalog
@cedricmatalog
Aug 06 2016 06:47
need help with golf
instructions not clear
Manjot Singh
@msingh18
Aug 06 2016 06:48
@stonefmagiecurata thanksi you again
stonefmagiecurata
@stonefmagiecurata
Aug 06 2016 06:48
@msingh18 :+1:
Evgueni
@Redoras
Aug 06 2016 07:01
Hello
Has anyone done the roman numerals challenge without using way too many if statements?
because there's so many different combinations...
Oleg
@designofhumanity
Aug 06 2016 07:03
Guys help. How can I realize waiting for JSONP (I know it is easier to use jQuery but I want to understand how it works inside)? This is wierdo...
var scriptTag = document.createElement("script");
scriptTag.type = "text/javascript";
scriptTag.src = url;
var addedScript =document.head.appendChild(scriptTag);
if (!globalData) {
setTimeout(function(){ }, 3000);
if (!globalData) {
setTimeout(function(){ }, 6000);
}
}
addedScript.remove();
Jaren Escueta
@jarenescueta731
Aug 06 2016 07:08
@Redoras yes it's possible, for mine I didn't use any if statements
Evgueni
@Redoras
Aug 06 2016 07:09
Oh really
that's impressive
Trying to figure out how to do it but ...
Joshua Sullivan
@jaesulli95
Aug 06 2016 07:09
modular arithmetic
Chandrahas P
@Chan11
Aug 06 2016 07:09

str="hello";
code:

function reverseString(str) {
  var str1=[];
  var pstr="";
  str1=str.split("");
  str1=str1.sort(function(a,b){if(a>b){return 1;} if(a<b){return -1;}});
  pstr=str1.join('');
  return pstr;
}

Output is ehllo, but why sort(function(a,b)) is unable to sort out entire string

Darth Skywalker
@adityaparab
Aug 06 2016 07:11
@Chan11 : You're sorting letters in you string alphabetically.
you're not reversing the string.
str1.sort(function(a,b){if(a>b){return 1;} if(a<b){return -1;}})
is equivalent to
str1.sort(function(a,b){ return a>b});
Steph
@tcapre01
Aug 06 2016 07:12
quick question- if i define a function within the scope of another function and want to return it, would I just type something like return function()?
Jaren Escueta
@jarenescueta731
Aug 06 2016 07:13
help closures
CamperBot
@camperbot
Aug 06 2016 07:13

:point_right: js closures [wiki]

JavaScript Closures

Closures are functions that refer to independent (free) variables (name), that have been returned by an enclosing function (makeFunc), and can still refer to those variables when they are called (myFunc()). As such, the closure (makeFunc()) 'remembers' the environment in which it was created.

function makeFunc() {
  var name = "Mozilla";
  function displayName() {
    alert(name);
  }
  return displayName;
}

var myFunc = makeFunc();
myFunc();

See MDN

tags: closure, javascript, js
:pencil: read more about js closures on the FCC Wiki

Darth Skywalker
@adityaparab
Aug 06 2016 07:13
@Chan11 If you want to reverse the string, do
str1 = str1.reverse();
Chandrahas P
@Chan11
Aug 06 2016 07:13
ohhh,lol i was not able to get diff between sorting and reversing ,thanks @adityaparab
Jaren Escueta
@jarenescueta731
Aug 06 2016 07:13
@tcapre01 closures^
Darth Skywalker
@adityaparab
Aug 06 2016 07:13
@tcapre01 Correct.
Steph
@tcapre01
Aug 06 2016 07:13
@jarenescueta731 @adityaparab thanks guys!
CamperBot
@camperbot
Aug 06 2016 07:13
tcapre01 sends brownie points to @jarenescueta731 and @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 498 | @adityaparab |http://www.freecodecamp.com/adityaparab
:cookie: 347 | @jarenescueta731 |http://www.freecodecamp.com/jarenescueta731
Oleg
@designofhumanity
Aug 06 2016 07:16
Maybe something like tha (wainting for JSONP)
while(!globalData) {
setTimeout(function() {}, 1000);
}
FM
@mafelix
Aug 06 2016 07:17
huehuehue
'why does my btn only work on this one page'
'forget the . for the class'
Manjot Singh
@msingh18
Aug 06 2016 07:19
"AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes."
What does asynchronous mean in this sentence?
孙伟
@mufengcoding
Aug 06 2016 07:20
blob
Raph
@captainrk1
Aug 06 2016 07:21
am body in china?
Sumit Rana
@sumitrana12
Aug 06 2016 07:31
hey any one help me
slidoooor
@slidoooor
Aug 06 2016 07:37
Who can give me an answer to the Basic Javascript : Counting Cards answer,about

var count = 0;

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

return "Change Me";
// Only change code above this line
}

// Add/remove calls to test your function.

cc(2); cc(3); cc(7); cc('K'); cc('A');

Muhammad Hasham
@MohammadHasham
Aug 06 2016 07:50
can anyone clarify me in fibonacci challenge:
sumFibs(4) should return 5.
how is that possible?
Chandrahas P
@Chan11
Aug 06 2016 07:52
how to filter out non-alphanumeric characters from array?
@MohammadHasham 1+1+3
Muhammad Hasham
@MohammadHasham
Aug 06 2016 07:54
@chaitanyaashtekar Thanks
CamperBot
@camperbot
Aug 06 2016 07:54
mohammadhasham sends brownie points to @chaitanyaashtekar :sparkles: :thumbsup: :sparkles:
:cookie: 410 | @chaitanyaashtekar |http://www.freecodecamp.com/chaitanyaashtekar
chaitanya ashtekar
@chaitanyaashtekar
Aug 06 2016 07:54
np
Chandrahas P
@Chan11
Aug 06 2016 08:00
This message was deleted
x981
@x981
Aug 06 2016 08:25
I'm at https://www.freecodecamp.com/challenges/exact-change challenge, how to count for the return array ? Anyone help me?
Chandrahas P
@Chan11
Aug 06 2016 08:25
Problem: palindrome("not a palindrome") should return false.
function palindrome(str) {
  // Good luck!
  var str0=str.replace(/\w/g,'');
  str0=str0.replace(' ','');
  var str1=str0.split('');
  var j=str1.length-1;
  for(i=0;i<str1.length;i++){
    if(str1[i]!=str1[j])
      {
        return false;
      }
    j--;
  }
    return true; 
}
Darth Skywalker
@adityaparab
Aug 06 2016 08:27

@Chan11 :smile:

var arr = [1,2,3,'a','b','c','asd','dsa',NaN,'@','!'];

how to filter out non-alphanumeric characters from array?

var arr = [1,2,3,'a','b','c','asd','dsa',null,undefined,'@','!',NaN];

var z = arr.filter(x=>x).filter(function(e){
    var _e = e.toString();
    return _e.match(/[A-Za-z0-9]/g);
});

console.log(z); // [1, 2, 3, "a", "b", "c", "asd", "dsa"]
Chandrahas P
@Chan11
Aug 06 2016 08:34
@adityaparab bro,pls check above code. function is no returning false for some non-palindrome strings. & can we use .replace(\w\/g,'') to replace no-alphanumeric characters from string
Darth Skywalker
@adityaparab
Aug 06 2016 08:35
@Chan11 : Okay, let me check
also \w\/g, is not a valid regex
Muhammad Hasham
@MohammadHasham
Aug 06 2016 08:36
why does my browser hangs when i try to run this code
var arr = [];
for (var i =1 ;i<=num;i++)
{
if (i%2==1)
{
arr.push(i);
}
}
return arr;
@adityaparab
@chaitanyaashtekar
Darth Skywalker
@adityaparab
Aug 06 2016 08:37
@MohammadHasham : What is the value of your num? It seems to be going into infinite loop
Muhammad Hasham
@MohammadHasham
Aug 06 2016 08:38
num is entered by the function
@adityaparab
it is no more than 10
Darth Skywalker
@adityaparab
Aug 06 2016 08:38
Share your full code. @MohammadHasham
Muhammad Hasham
@MohammadHasham
Aug 06 2016 08:39

function sumFibs(num) {

  var arr = [] ;
  for (var i=1;i<=num;i++)
    {
      if (i%2==1)
        {
          arr.push(i);
        }
    }
  return arr;

}

sumFibs(4);
@adityaparab
Darth Skywalker
@adityaparab
Aug 06 2016 08:41
@MohammadHasham : I don't see anything wrong with this code. From what I understand it should return [1,3]
May be you have some different error?
Muhammad Hasham
@MohammadHasham
Aug 06 2016 08:41
i don't know why it is keeping my bbrowser hanged
Darth Skywalker
@adityaparab
Aug 06 2016 08:55
@MohammadHasham may be try restarting your browser?
Muhammad Hasham
@MohammadHasham
Aug 06 2016 08:55
@adityaparab trying to figure that out!
Sarah Essex
@sarahessex
Aug 06 2016 09:01
@MohammadHasham try removing var i=1 and just make it i=1 in the for loop.
Darth Skywalker
@adityaparab
Aug 06 2016 09:05
@sarahessex : That won't make any difference AND, you risk making your code nonportable. (if you get rid of that var)
Brendan Kinahan
@BKinahan
Aug 06 2016 09:05
the code is quite simple and should run quickly even for the larger tests in that challenge.. I wonder what's going on
the problem is probably that you're trying to return a huge array
with sumFibs(4000000) you're forming an array with 2 million elements.
Darth Skywalker
@adityaparab
Aug 06 2016 09:07
@BKinahan : Since he's using for loop large array is not a problem. Had he been using prototype methods, then that might run into overflows and memory leaks
Brendan Kinahan
@BKinahan
Aug 06 2016 09:08
@adityaparab I mean returning the large value (long array) is the problem, not processing it. If you return arr.reduce(sumFunction) for example it works just fine.
fun math fact that the sum of all the odd numbers between one and four million is four trillion :D
Muhammad Hasham
@MohammadHasham
Aug 06 2016 09:10
@BKinahan @adityaparab Thanks
CamperBot
@camperbot
Aug 06 2016 09:10
:cookie: 500 | @adityaparab |http://www.freecodecamp.com/adityaparab
mohammadhasham sends brownie points to @bkinahan and @adityaparab :sparkles: :thumbsup: :sparkles:
:star2: 2198 | @bkinahan |http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Aug 06 2016 09:11
@adityaparab heyyy, 500 brownies, congrats!
Muhammad Hasham
@MohammadHasham
Aug 06 2016 09:11
i am doing fibonacci series challenge can anyone tell me that why is my code not working
function sumFibs(num) {



  var arr=0;
  var a=0;
  var sum=0;
  var b = 1;
  for (var j=2;j<num;j++)
    {
      sum = a+b;
      a= b;
      b =sum;
       if (sum%2!==0)
         {
           arr+=sum;
         }
    }
  return arr;
Darth Skywalker
@adityaparab
Aug 06 2016 09:11
@BKinahan : Lol ! Thanks! D:
CamperBot
@camperbot
Aug 06 2016 09:11
adityaparab sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 2199 | @bkinahan |http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Aug 06 2016 09:12
@MohammadHasham yeah you're lacking a closing } for your function
Muhammad Hasham
@MohammadHasham
Aug 06 2016 09:12
that is down at the end sorry! for not including that! @BKinahan
is my approach and logic okay!
Darth Skywalker
@adityaparab
Aug 06 2016 09:14
@MohammadHasham : What are you trying to do anyway?
What's the challenge?
Muhammad Hasham
@MohammadHasham
Aug 06 2016 09:14
Sum All Odd Fibonacci Numbers @adityaparab
like if there is 10 then i have to add 1,3,5 (which are odd fiboncacii less than 10)
Darth Skywalker
@adityaparab
Aug 06 2016 09:16

function sumFibs(num) {
  var first = 1;
  var second = 1;
  var sum = 2;
  while (first+second<=num) {
    var third = first+second;
    if (third%2!==0) sum += third;
    first = second;
    second = third;
  }
  return sum;
}

sumFibs(4);
:P :P :P :P :P
Brendan Kinahan
@BKinahan
Aug 06 2016 09:16
@MohammadHasham no, you're checking the first num fibonacci numbers, not the fibonacci numbers less than or equal to 10
@adityaparab you really shouldn't just provide solutions to someone asking for help.
Darth Skywalker
@adityaparab
Aug 06 2016 09:16
I wrote it just now...
Not even sure if that will pass tests
but the dry run seems okay-ish
Brendan Kinahan
@BKinahan
Aug 06 2016 09:16
so that's even worse :D
Darth Skywalker
@adityaparab
Aug 06 2016 09:17
:laughing:
Promise Tochi
@Promhize
Aug 06 2016 09:17
hey guys, how do i stop a script from running? Anybody have a clue? For the simon game project, trying to stop everything when you click on off
NixonRichard
@NixonRichard
Aug 06 2016 09:17
I tried so hard
And got so far
Darth Skywalker
@adityaparab
Aug 06 2016 09:17
On a second thought, yes, it will pass all the tests
Muhammad Hasham
@MohammadHasham
Aug 06 2016 09:17
@BKinahan @adityaparab Thanks now i understand that where was i going wrong
CamperBot
@camperbot
Aug 06 2016 09:17
mohammadhasham sends brownie points to @bkinahan and @adityaparab :sparkles: :thumbsup: :sparkles:
:warning: mohammadhasham already gave adityaparab points
:warning: mohammadhasham already gave bkinahan points
NixonRichard
@NixonRichard
Aug 06 2016 09:17
But in the end it doesnt even matter
Brendan Kinahan
@BKinahan
Aug 06 2016 09:17
@Promhize you can have an init function which sets all your variables back to their starting values and clears any intervals
Darth Skywalker
@adityaparab
Aug 06 2016 09:18
One thing, I don;t know why. Why people keep taking irrelevant bullshit in the freecode camp
Hey, that rhymes!
Muhammad Hasham
@MohammadHasham
Aug 06 2016 09:18
@adityaparab sorry if that was a bullshit actually i am a newbie
sorry
NixonRichard
@NixonRichard
Aug 06 2016 09:19
lol
Promise Tochi
@Promhize
Aug 06 2016 09:19
@BKinahan tried the init, only forgot to clear intervals, thanks
CamperBot
@camperbot
Aug 06 2016 09:19
promhize sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 2200 | @bkinahan |http://www.freecodecamp.com/bkinahan
Darth Skywalker
@adityaparab
Aug 06 2016 09:19
@MohammadHasham : No No! That wasn't target at you.
lol
Brendan Kinahan
@BKinahan
Aug 06 2016 09:19
@Promhize :+1:
Muhammad Hasham
@MohammadHasham
Aug 06 2016 09:19
@adityaparab Okay, :smile:
Brendan Kinahan
@BKinahan
Aug 06 2016 09:19
Also, woo, 2200 :D
Darth Skywalker
@adityaparab
Aug 06 2016 09:19
It was just a filler to continue what @NixonRichard started. Linkin Park - In The end lyrics D:
:D
@MohammadHasham
@BKinahan :Congrats! :D
Max Mirza
@maxmirza
Aug 06 2016 09:20
This message was deleted
NixonRichard
@NixonRichard
Aug 06 2016 09:20
@Promhize Nice my friend
:sparkles:
Promise Tochi
@Promhize
Aug 06 2016 09:23
@NixonRichard :+1:
NixonRichard
@NixonRichard
Aug 06 2016 09:23
Any one want to take a quick fun quiz ?
Sarah Essex
@sarahessex
Aug 06 2016 09:25
Could anyone help me with understanding the filter function? I am on https://www.freecodecamp.com/challenges/seek-and-destroy
Give me a sec, I'll post my code
NixonRichard
@NixonRichard
Aug 06 2016 09:26
Sure @sarahessex Cavalry has arrived !
Sarah Essex
@sarahessex
Aug 06 2016 09:26
function destroyer(arr) {

  arr = arr.filter(checkVal(val,arguments));
  return arr;

}

function checkVal(val,args) {
  for (var i=1; i<args.length; i++) {
      if (val == args[i]) {
        // need to filter this value out
        return false;
      }
    }
    // this value can be kept in the filter
    return true;
}
nothing seems to be happening when i test it
i was getting an error that val was undefined
i don't understand how i can pass a parameter to the function used in filter()
Azlan Mukhtar
@azlan
Aug 06 2016 09:27
first, there shouldnt be any loop there
the check should be inside filter's anonymous function
Sarah Essex
@sarahessex
Aug 06 2016 09:29
@azlan what do you mean by anonymous function?
NixonRichard
@NixonRichard
Aug 06 2016 09:29
function with out name @sarahessex
@azlan r u another Cavalry ?
Sarah Essex
@sarahessex
Aug 06 2016 09:30
@jamesmillerho thanks - i have looked at that already, i'm just stuck with how to compare the value with any of the other arguments passed to the destroyer function
CamperBot
@camperbot
Aug 06 2016 09:30
sarahessex sends brownie points to @jamesmillerho :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @jamesmillerho |http://www.freecodecamp.com/jamesmillerho
Azlan Mukhtar
@azlan
Aug 06 2016 09:30
yeah, function that you can pass to filter() as callback
cavalry, lol :smile:
how about simpler explanation about filter
Sarah Essex
@sarahessex
Aug 06 2016 09:31
@azlan is that not what I am doing with checkVal? It's inside the filter() call as the callback ? or else i've misunderstood the https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter docs
NixonRichard
@NixonRichard
Aug 06 2016 09:32
 arr.filter(function(val) {
   return val > 10;
  });
  return arr;
Darth Skywalker
@adityaparab
Aug 06 2016 09:32
@sarahessex : You're on the right tract. There is no hard and fast dependency that you have to pass in anonymous function. You can use your check checkVal function the way you're using it
NixonRichard
@NixonRichard
Aug 06 2016 09:32
a very simple example
Sarah Essex
@sarahessex
Aug 06 2016 09:32
@NixonRichard essentially that's the same as this right, just written differently?:
function destroyer(arr) {

  arr = arr.filter(checkVal);
  return arr;

}

function checkVal(val) {
  return val > 10;
}
NixonRichard
@NixonRichard
Aug 06 2016 09:33
possibly
Johnny
@JohnnyBizzel
Aug 06 2016 09:33
@sarahessex I prefer the W3Schools definition http://www.w3schools.com/jsref/jsref_filter.asp
NixonRichard
@NixonRichard
Aug 06 2016 09:34
why u guyz keep making it serious ?
Darth Skywalker
@adityaparab
Aug 06 2016 09:34
@sarahessex : First you're gonna have to separate your target array and rest of the numbers you want to destroy
I'm afraid you can't simply play with arr
inside the filter
Array.prototype.includes seems to be right choice for the problem at hand
Robert Richey
@0x0936
Aug 06 2016 09:37
been a while since summing Fibonacci numbers. struggled with that a bit
Denis
@DenisDov
Aug 06 2016 09:38
help
CamperBot
@camperbot
Aug 06 2016 09:38

CamperBot

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. e.g. find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

meet CamperBot in FreeCodeCamp/camperbotPlayground

:pencil: read more about camperbot on the FCC Wiki

Dylan Satelle
@DylanSatelle
Aug 06 2016 09:39
Anyone able to help us a little on the Word Blanks challenge? I'm pretty positive I got the chalange right but don't quite understand the two objectives that need to be met.
Denis
@DenisDov
Aug 06 2016 09:39
find Arguments
Azlan Mukhtar
@azlan
Aug 06 2016 09:39
@DylanSatelle show us the code
Sarah Essex
@sarahessex
Aug 06 2016 09:39
@azlan @adityaparab So I should check, for each argument (in a for loop?), if it's 'included' in the array, and, if so, filter it out?
Dylan Satelle
@DylanSatelle
Aug 06 2016 09:40

```
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

result = "I like " + myNoun + " that are " + myAdjective + " that can " + myAdverb + " walk";

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");

NixonRichard
@NixonRichard
Aug 06 2016 09:40
i have a quick fun quiz
anyone want to tryit ?
Azlan Mukhtar
@azlan
Aug 06 2016 09:40
@sarahessex yeah, something like that
Dylan Satelle
@DylanSatelle
Aug 06 2016 09:40
'wordBlanks' shod contain all of the passed in words separated by non word characters?
should*
Sergi
@SergiOca87
Aug 06 2016 09:41
Dylan, you aren't supposed to actually write the words in the code
Dylan Satelle
@DylanSatelle
Aug 06 2016 09:41
ah right
ok
I got ya
Sarah Essex
@sarahessex
Aug 06 2016 09:41
@azlan Ok, thanks for your help. I'll be back if I can't get it to work!
CamperBot
@camperbot
Aug 06 2016 09:41
sarahessex sends brownie points to @azlan :sparkles: :thumbsup: :sparkles:
:cookie: 10 | @azlan |http://www.freecodecamp.com/azlan
Sergi
@SergiOca87
Aug 06 2016 09:41
try it that way
Johnny
@JohnnyBizzel
Aug 06 2016 09:41
@sarahessex There is a trick you can use with the filter function. You can optionally pass in the value you want to test as this...
Parameters of filter()
callback
Function to test each element of the array. Invoked with arguments (element, index, array). Return true to keep the element, false otherwise.
thisArg
Optional. Value to use as this when executing callback.
Sergi
@SergiOca87
Aug 06 2016 09:42
I got stuck there too, imo it's hard to understandç
Darth Skywalker
@adityaparab
Aug 06 2016 09:42
@sarahessex : Filter will already spawn a loop internally and pass each element in array one by one as an argument to the function you pass to the filter.
So you don't need a loop inside your checkVal function.
Johnny
@JohnnyBizzel
Aug 06 2016 09:42
NixonRichard
@NixonRichard
Aug 06 2016 09:42
wow
Azlan Mukhtar
@azlan
Aug 06 2016 09:43
slow down, this is advanced stuff
NixonRichard
@NixonRichard
Aug 06 2016 09:43
is that just because she s a girl and u all focus helping her ?
look at all the stuffs lol
Azlan Mukhtar
@azlan
Aug 06 2016 09:43
i mean 'this' keyword
Johnny
@JohnnyBizzel
Aug 06 2016 09:43
@NixonRichard I help anyone who is on here.
Sarah Essex
@sarahessex
Aug 06 2016 09:43
@adityaparab I don't mean for looping the array, I mean for looping the arugments?
Azlan Mukhtar
@azlan
Aug 06 2016 09:44
i'm free right now, will help anyone
Sarah Essex
@sarahessex
Aug 06 2016 09:45
@JohnnyBizzel thanks, so if I pass each argument in turn as an optional argument and use this to check in my callback function, that might work..?
CamperBot
@camperbot
Aug 06 2016 09:45
sarahessex sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 354 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Darth Skywalker
@adityaparab
Aug 06 2016 09:46
@sarahessex : If you do a console.log(arguments)inside your checkVal function, you will see that the thing that is logged is not what you expect it to log.
jamesmillerho
@jamesmillerho
Aug 06 2016 09:46
@sarahessex I rewrite your code and passed now, but can you post your code again?
Darth Skywalker
@adityaparab
Aug 06 2016 09:46
Filter will pass it's own parameters to the checkVal
Johnny
@JohnnyBizzel
Aug 06 2016 09:47
@sarahessex Exactly :+1:
Dion Hobdy
@hobdydion
Aug 06 2016 09:48
Hey guys, I am currently working on the "convert celsius to fahrenheit" challenge and I am haing difficulty with the solution. I figured out the algorithms for the challenge but I can't string them together.
Sarah Essex
@sarahessex
Aug 06 2016 09:48
Give me a couple of minutes everyone, I'm going to try and work with your suggestions! Thank you
Dion Hobdy
@hobdydion
Aug 06 2016 09:48
If that makes any sene. lol
Azlan Mukhtar
@azlan
Aug 06 2016 09:48
@hobdydion paste the code
Dion Hobdy
@hobdydion
Aug 06 2016 09:48

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = 5/5 + 85;

// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(30);

NixonRichard
@NixonRichard
Aug 06 2016 09:49
hmm hmm
why 5/5 + 85 my friend
Darth Skywalker
@adityaparab
Aug 06 2016 09:49
@hobdydion : You will always get 86 as an answer :laughing:
NixonRichard
@NixonRichard
Aug 06 2016 09:49
some thing shuold replaced by celsius
Dion Hobdy
@hobdydion
Aug 06 2016 09:49
convertToF(30) should return a value of 86 @NixonRichard
Darth Skywalker
@adityaparab
Aug 06 2016 09:50
@hobdydion : Look at the instructions again, it clearly explains what formular you have to use
NixonRichard
@NixonRichard
Aug 06 2016 09:50
if celsius is 30 my friend
what if celsius is something else
Johnny
@JohnnyBizzel
Aug 06 2016 09:50

@sarahessex

function isBigEnough(value) {
  return value >= 10;
}
var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);

Here the 10 can be replaced by the optional "this"

NixonRichard
@NixonRichard
Aug 06 2016 09:50
30 stands for celsius in that case
Sarah Essex
@sarahessex
Aug 06 2016 09:50
I did it! Here's my solution:
function destroyer(arr /*, other arguments */) {

  for (i=1; i<arguments.length; i++) {
    arr = arr.filter(checkVal,arguments[i]);
  }

  return arr;

}

function checkVal(val) {
  return (val != this);
}
NixonRichard
@NixonRichard
Aug 06 2016 09:51
cuz u have the function
Sarah Essex
@sarahessex
Aug 06 2016 09:51
@JohnnyBizzel is that along the lines of what you meant?
Dion Hobdy
@hobdydion
Aug 06 2016 09:51
hhmm Should I restart?
NixonRichard
@NixonRichard
Aug 06 2016 09:51
@hobdydion js function cot(celsius) { }
Azlan Mukhtar
@azlan
Aug 06 2016 09:51
@sarahessex cool
Johnny
@JohnnyBizzel
Aug 06 2016 09:52
@sarahessex Looks good. Did it pass the tests?
Sarah Essex
@sarahessex
Aug 06 2016 09:52
@JohnnyBizzel yes!
Johnny
@JohnnyBizzel
Aug 06 2016 09:53
:D
Dion Hobdy
@hobdydion
Aug 06 2016 09:54

@NixonRichard Man. Java is rough on the spirit. ._.

I have no idea what I am doing.

Johnny
@JohnnyBizzel
Aug 06 2016 09:54
@sarahessex The only difference with my code is you start at i = 1. I believe it doesn't matter if you start at i = 0 but I see what you did there ;)
Sarah Essex
@sarahessex
Aug 06 2016 09:55
@JohnnyBizzel I did that because arguments[0] is the array itself? Thought I would have to start from index 1...
Johnny
@JohnnyBizzel
Aug 06 2016 09:55
@sarahessex (in the for loop I mean)
Sarah Essex
@sarahessex
Aug 06 2016 09:55
@JohnnyBizzel could you paste your code so I can compare?
Johnny
@JohnnyBizzel
Aug 06 2016 09:56
Forget about the JSON stringify bit
function removeValue(val) {
     if (val != this)
        return val;
}

function destroyer(arr) {
  var testArr = arr;
  var args = Array.from(arguments);
  for (i = 0; i < args.length; i++) {
        testArr = testArr.filter(removeValue, args[i]);

  }

  return JSON.stringify(testArr);
}
NixonRichard
@NixonRichard
Aug 06 2016 09:56
@hobdydion okay let s take a look
u have the argument celsius right ?
Dion Hobdy
@hobdydion
Aug 06 2016 09:57
lol Yes
NixonRichard
@NixonRichard
Aug 06 2016 09:57
function removeValue(celsius) {
like this
Darth Skywalker
@adityaparab
Aug 06 2016 09:57
@sarahessex : Were you on Seek and Destroy?
NixonRichard
@NixonRichard
Aug 06 2016 09:57
dont worry about the name
it can be anything
that s just the syntax
Sarah Essex
@sarahessex
Aug 06 2016 09:57
@adityaparab Yes
NixonRichard
@NixonRichard
Aug 06 2016 09:57
so when the function get called @hobdydion
Darth Skywalker
@adityaparab
Aug 06 2016 09:57

@sarahessex

Here is how I did it

function destroyer(arr) {
  // Remove all the values
  var args = Array.prototype.slice.call(arguments);
  var arg1 = args[0];
  var arg2 = args.slice(1);

  return arg1.filter(function(e){
    return arg2.indexOf(e) === -1;
  });


}
NixonRichard
@NixonRichard
Aug 06 2016 09:58
like this
convert(30);
Tymon
@Tymon555
Aug 06 2016 09:58
Hello, I have a problem with JS - to be exact with JSON call
Azlan Mukhtar
@azlan
Aug 06 2016 09:58
function destroyer(arr) {
  var arr2 = Array.prototype.slice.call(arguments, 1);

  return arr.filter(function(val) {   
    return (arr2.includes(val) === false);
  });

}
NixonRichard
@NixonRichard
Aug 06 2016 09:58
30 = celsius @hobdydion
Robert Richey
@0x0936
Aug 06 2016 09:58
here's my destroyer
//jshint asi:true, esversion:6, strict:implied
function destroyer(...args) {      
  return args[0].filter(n => !args.slice(1).includes(n))
}
NixonRichard
@NixonRichard
Aug 06 2016 09:58
or 40 or 50 or any else number @hobdydion
so inside the function
Tymon
@Tymon555
Aug 06 2016 09:59
    function getWeather() {
 /*$.getJSON("http://ipinfo.io", function(data){
  var xer = JSON.stringify(data);
    xer = jQuery.parseJSON(xer);
})*/
var xt,obj,place = "api.openweathermap.org/data/2.5/weather?q=";
$.getJSON('http://ipinfo.io', function(data){

    xt = JSON.stringify(data);
    xt = JSON.parse(xt);
    console.log(xt);
    place += xt.city;
    //console.log(place);
     place+="&APPID=1c4f36b03d4768daaf2eec6dc678a06b" ;
     console.log(place);
     //data.clear();
    }
)
     $.getJSON(place, function(data) {
        obj = JSON.stringify(data);
        obj = JSON.parse(obj);
        console.log(obj);
        $('#location').html(obj.name + ', ' + obj.sys.country);
        $('#weather').html(obj.main.temp + " Farenheit");
        $('#pict').html(obj.weather[0].description);
        //$('#loc').html(xt.loc);
      })
}
First one is working - I get the IP, but the second one is not :( and it worked earlier - I mean, without the IP call
Darth Skywalker
@adityaparab
Aug 06 2016 09:59
@0x0936 : Shortening the code with ES6 is cheating :D
JK
NixonRichard
@NixonRichard
Aug 06 2016 09:59
@hobdydion u got ur algorith to work with celsius
like 1 + 2 + 3 + celsius
Robert Richey
@0x0936
Aug 06 2016 09:59
;)
Dion Hobdy
@hobdydion
Aug 06 2016 10:00
Pretty much @NixonRichard
NixonRichard
@NixonRichard
Aug 06 2016 10:00
do u get it so far ?
Dion Hobdy
@hobdydion
Aug 06 2016 10:00
Barely
Sarah Essex
@sarahessex
Aug 06 2016 10:00
Thanks everyone for your help. Interesting to see different solutions. I'll be off now... :)
Dion Hobdy
@hobdydion
Aug 06 2016 10:00
This entire challenge is a big mess
NixonRichard
@NixonRichard
Aug 06 2016 10:01
@sarahessex U got the cavalry with you lady
@hobdydion let s go to private chat i ll try to explain
Dion Hobdy
@hobdydion
Aug 06 2016 10:02
Basically my main tiff with this is that it is asking me to come up with solutions for multiple convertTtoF( ) inputs. I came up with said solutions, but it's impossible to complete the challenge
lol Alright
Johnny
@JohnnyBizzel
Aug 06 2016 10:03
@Tymon555 What do you mean 2nd one?
Tymon
@Tymon555
Aug 06 2016 10:03
I mean call to Openweather API doesn't work @JohnnyBizzel
console.log(obj); shoows nothing in console
Johnny
@JohnnyBizzel
Aug 06 2016 10:04
@Tymon555 The syntax looks wrong
@Tymon555 Ther eis a bracket, no comma then the next Json call?
@Tymon555 why are you trying a 2nd json call?
Azlan Mukhtar
@azlan
Aug 06 2016 10:05
@Tymon555 can u share the whole code on codepen or jsfiddle
Johnny
@JohnnyBizzel
Aug 06 2016 10:05
@Tymon555 Pass the result of the JSON call to a variable
NixonRichard
@NixonRichard
Aug 06 2016 10:06
Hi guyz
Robert Richey
@0x0936
Aug 06 2016 10:07
@hobdydion the idea is that functions can be called with many different values - it won't always be 30. Use a formula that converts celsius to fahrenheit
@JohnnyBizzel is that way ok : obj = JSON.stringify(data); ?
NixonRichard
@NixonRichard
Aug 06 2016 10:10
Here come the Cavalry !
any problems here ?
Tymon
@Tymon555
Aug 06 2016 10:11
@NixonRichard Hello :)
I'm working on Weather App challenge and have problem with my API calls
the pen above
NixonRichard
@NixonRichard
Aug 06 2016 10:12
Yeah me too lol
Azlan Mukhtar
@azlan
Aug 06 2016 10:12
@Tymon555 ok
NixonRichard
@NixonRichard
Aug 06 2016 10:12
advice from a cavalry s skip the challenge
Johnny
@JohnnyBizzel
Aug 06 2016 10:12
@Tymon555 What is the trigger for the 2nd call?
Tymon
@Tymon555
Aug 06 2016 10:14
Both calls are inside one function
which is triggered on click
@NixonRichard I've spent too much time on that to give up! :D
Robert Richey
@0x0936
Aug 06 2016 10:15
@Tymon555 $.getJSON() is an asynchronous operation. before ipinfo returns with a response, var x = xer.loc[1]; has already run and xer is undefined. the solution is to ajax to openweather inside the first ajax callback from ipinfo
Azlan Mukhtar
@azlan
Aug 06 2016 10:15
jquery-2.2.4.min.js:4 XMLHttpRequest cannot load http://ipinfo.io/. Failed to start loading.
Okojie Osemudiame Charles
@charliwize
Aug 06 2016 10:16
what is the value of [] == ![] or what does that staement mean in Javascript
Azlan Mukhtar
@azlan
Aug 06 2016 10:17
Uncaught ReferenceError: xer is not defined
xer is not in the scope
Johnny
@JohnnyBizzel
Aug 06 2016 10:18
@Tymon555 You have an on click event
@Tymon555 Still there?
Tymon
@Tymon555
Aug 06 2016 10:18
@azlan Eh, sorry, I copied from sublime to Codepen
yep
I'll fix it
Johnny
@JohnnyBizzel
Aug 06 2016 10:18
@Tymon555 What does the click event call?
@Tymon555 Are you there?
@Tymon555 I have to go out soon so only have a few mins
NixonRichard
@NixonRichard
Aug 06 2016 10:19
@JohnnyBizzel hey u look like an old angry and serious officer :smile:
Tymon
@Tymon555
Aug 06 2016 10:20
@JohnnyBizzel ok, I fix'd pen . Click event calls getWeather function, inside which are two API calls
Azlan Mukhtar
@azlan
Aug 06 2016 10:21
btw, I recommend https://watchandcode.com/courses/practical-javascript if somebody want to learn how to use debugger inside chrome
Darth Skywalker
@adityaparab
Aug 06 2016 10:21
@JohnnyBizzel : I had a professor in the University who looked like you. He's very kind and wonderful human being. :)
Tymon
@Tymon555
Aug 06 2016 10:21
@azlan will check out :)
will work on chromium?
Johnny
@JohnnyBizzel
Aug 06 2016 10:23
@adityaparab I grew the moustache for MOVEMBER but thanks for the compliment :+1:
CamperBot
@camperbot
Aug 06 2016 10:23
johnnybizzel sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 504 | @adityaparab |http://www.freecodecamp.com/adityaparab
Johnny
@JohnnyBizzel
Aug 06 2016 10:24
@Tymon555 So you are back in business now?
Azlan Mukhtar
@azlan
Aug 06 2016 10:24
@Tymon555 i got this, VM548 jquery-2.2.4.min.js:4 XMLHttpRequest cannot load http://ipinfo.io/, maybe cant run it under codepen?
the api should be simple, http://ipinfo.io/developers
NixonRichard
@NixonRichard
Aug 06 2016 10:25
@JohnnyBizzel u still look like a serious officer with that beard... in a good way :smile:
Tymon
@Tymon555
Aug 06 2016 10:25
@azlan ipinfo works, I use it in Sublime and myh source is jQuery 3.sth
Mitul Islam
@MitulIslam
Aug 06 2016 10:25
blob
@Tymon555 is this the problem
Johnny
@JohnnyBizzel
Aug 06 2016 10:25
Are we working on IP address for the users location?
NixonRichard
@NixonRichard
Aug 06 2016 10:25
quick fun quiz
Johnny
@JohnnyBizzel
Aug 06 2016 10:26
@MitulIslam I think he has fixed that now...@Tymon555 please repost what you have so far if you still have problems
Robert Richey
@0x0936
Aug 06 2016 10:26
@Tymon555 :point_up: August 6, 2016 4:15 AM
NixonRichard
@NixonRichard
Aug 06 2016 10:26
if  
  1 - 3 + 4 = 100
  4 - 6 + 9 = 999
  2 - 6 + 7 = 879
then
  3 - 3 + 6 = ???
solve this guyz
:smile:
Johnny
@JohnnyBizzel
Aug 06 2016 10:27
6
Tymon
@Tymon555
Aug 06 2016 10:27
Sorry for lagging guys, I just don't usually use codepen to this :/
Johnny
@JohnnyBizzel
Aug 06 2016 10:27
@Tymon555 What do you use? jsfiddle?
Tymon
@Tymon555
Aug 06 2016 10:27
Sublime
and firefox
@JohnnyBizzel
dimitrije12
@dimitrije12
Aug 06 2016 10:28

Johnny
@JohnnyBizzel
Aug 06 2016 10:28
@Tymon555 I debug with Firefox and Firebug
dimitrije12
@dimitrije12
Aug 06 2016 10:30
function fearNotLetter(str) {
  var arr=str.split("");
  var letter;
  var top=arr.length-2;
  if (arr[0]=="a"){
    for (var i=0;i<top;i++){
      if ((arr[i+1].charCodeAt-arr[i].charCodeAt)>1){
       var num=arr[i].charCodeAt()+1;
        letter=String.fromCharCode(num);
        return letter;
      }
    }
  }
  else {return undefined;}

}
Johnny
@JohnnyBizzel
Aug 06 2016 10:30
@Tymon555 Still looks like the 2nd api call is outside the scope of the getweather() function
dimitrije12
@dimitrije12
Aug 06 2016 10:30
Where is the problem in my code
Johnny
@JohnnyBizzel
Aug 06 2016 10:30
@dimitrije12 Looks fine. What is the issue?
dimitrije12
@dimitrije12
Aug 06 2016 10:31
Doesnt return the letter
jamesmillerho
@jamesmillerho
Aug 06 2016 10:31
@dimitrije12 overcomplicated
Brendan Kinahan
@BKinahan
Aug 06 2016 10:31
@NixonRichard 220
dimitrije12
@dimitrije12
Aug 06 2016 10:33
Yeah my algorithms are often overcomplicated. Just don't know how to make them simpler
Azlan Mukhtar
@azlan
Aug 06 2016 10:33
"hostname": "No Hostname",
"city": "",
"region": "",
somehow it failed to give my location
NixonRichard
@NixonRichard
Aug 06 2016 10:35
@BKinahan why then :baby_chick:
jamesmillerho
@jamesmillerho
Aug 06 2016 10:35
@dimitrije12 correct way is charCodeAt(0)
Abhisek Pattnaik
@abhisekp
Aug 06 2016 10:35
@NixonRichard 3 - 3 + 6 = 6
Brendan Kinahan
@BKinahan
Aug 06 2016 10:36
@NixonRichard well I ain't spoilin' it for other players
Azlan Mukhtar
@azlan
Aug 06 2016 10:36
@Tymon555 thats the problem for me, city is blank
jamesmillerho
@jamesmillerho
Aug 06 2016 10:36

@dimitrije12

function fearNotLetter(str) {

    for (var i=1;i<str.length;i++){
      if (str[i].charCodeAt(0) - str[i-1].charCodeAt(0) !== 1){
       var num=str[i].charCodeAt(0) - 1;
        return String.fromCharCode(num);
      }
    }

}

fearNotLetter("abce");

It can pass like this

Brendan Kinahan
@BKinahan
Aug 06 2016 10:36
breakfast time, woo!
Tymon
@Tymon555
Aug 06 2016 10:37
@azlan hmm strange
city

    "Sheffield"
country