These are chat archives for FreeCodeCamp/HelpJavaScript

30th
Apr 2016
DamianMitchell
@DamianMitchell
Apr 30 2016 00:04
@ArmendBerisha
@ArmendBerisha

function testSize(num) {
// Only change code below this line
if (num < 5) {
return "Tiny";
} else if (num < 10){
return "Small";
} else if (num < 15){
return "Medium";
} else if (num < 20){
return "Large";
} else if (num >= 20){
return "hugh";
} else {
return "Change Me";
}
// Only change code above this line
}

// Change this value to test
testSize(7);

I don't see the problem.....
zackluckyf
@zackluckyf
Apr 30 2016 00:08
So I made it to the second round of an interview process and am now going to be remotely paired to do some coding. The interviewer told me he was mainly going to check into javascript functions and objects. I was thinking about just drilling the FCC algorithms again but wanted to get thoughts on if I should do anything additionally? Unfortunately it's on Monday and I work tomorrow and Sunday so time is limited. I'm open to ideas though!
Armend
@ArmendBerisha
Apr 30 2016 00:10
@DamianMitchell there is a typo, ( hugh )
and I think the other problem is related to the comparison with comparison
for the last and <= for the "Large" comparison
DamianMitchell
@DamianMitchell
Apr 30 2016 00:11
@ArmendBerisha I tryed that...let me look at the tempo
Jorge
@liberaltech
Apr 30 2016 00:11
var user = ["freecodecamp", "storbeck", "terakilobyte", "habathcx", "RobotCaleb", "thomasballinger", "noobs2ninjas", "beohoff"];
$(function Twitch(user) {

  var userLength = user.length;
  var newUser = [];


  for (var i = 0; i < userLength; i++) {
    newUser += user[i];
    var url = 'https://api.twitch.tv/kraken/streams/' + user;
    $.ajax({
      url: url,
      type: 'GET',
      contentType: 'application/json',
      dataType: 'jsonp',
      success: function(data) {

      }
    });
    $.get(url, function(data) {
      var user0 = data.stream.display_name;
      var user1 = data.display_name;

      var logo1 = data.logo;
      $('div').text(user0);
      $('img').attr('src', logo1);

      var logo2 = data.logo;

      $('#icon2').attr('src', logo2);
    });
  }

});
Armend
@ArmendBerisha
Apr 30 2016 00:12
tell me the name of the challenge @DamianMitchell
Jorge
@liberaltech
Apr 30 2016 00:12
cant get individual stream indo
info*
im not sure where my loop should be
DamianMitchell
@DamianMitchell
Apr 30 2016 00:13
@ArmendBerisha Chaining if Else Statements
I corrected the Hugh, hanged the operator nonpe
change the operator and nothing
never mind...got it...
thanks
Armend
@ArmendBerisha
Apr 30 2016 00:18
@DamianMitchell ok re doing it now
Steisaden
@steisaden
Apr 30 2016 00:25

'''
function isLess(a, b) {
// Fix this code

return a === b || a < b;

}

// Change these values to test
isLess(10, 15);
'''

Cameron Swift
@Chromps
Apr 30 2016 00:25
@zackluckyf I came across codewars today they have a ton of practice problems with all different difficulty levels. I did some of the basic ones and they only took me a few minutes each.
Karan Bhandari
@karanbhandari
Apr 30 2016 00:26
@steisaden Why are you not just doing return a <= b; ???
Steisaden
@steisaden
Apr 30 2016 00:28
@karanbhandari thx I knew I was doing too much
CamperBot
@camperbot
Apr 30 2016 00:28
steisaden sends brownie points to @karanbhandari :sparkles: :thumbsup: :sparkles:
:star: 10 | @karanbhandari | http://www.freecodecamp.com/karanbhandari
Karan Bhandari
@karanbhandari
Apr 30 2016 00:31
NP @steisaden
dontchaknow
@dontchaknow
Apr 30 2016 00:37
function lookUpProfile(firstName, prop) {
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName && contacts[i][prop]) {
return contacts[i][prop];
}
else if (contacts[i].firstName) {
return "No such contact";
}
else if (contacts[i][prop]) {
return "No such property";
}
}
}
not sure why my code isn't working
tbaugh
@tbaugh
Apr 30 2016 00:41
@liberaltech try calling https://api.twitch.tv/kraken/channels/ rather than /streams/ for things like the logo
Stephen James
@sjames1958gm
Apr 30 2016 00:42
@dontchaknow You cannot return no such contact until all contacts have been checked.
Josue Godoy Lechuga
@josue1080
Apr 30 2016 00:45
help Make Object Properties Private
CamperBot
@camperbot
Apr 30 2016 00:45

:point_right: challenge make object properties private [wiki]

Objects have their own attributes, called properties_, and their own functions, called _methods.

You can use the this keyword to reference public properties and methods of the current objects. However, when You need to create private ones so they are not accessible from the outside of the object you just remove the keyword this from the object property or method declaration and declare it with var so that it is private outside its scope.

var Bike = function() {
  var speed = 100; // private
  function addUnit(value) { // private
    return value + "KM/H";
  }

  this.getSpeed = function () {  // public
    return addUnit(speed);
  };

};

Another example:

:pencil: read more about challenge make object properties private on the FCC Wiki

dontchaknow
@dontchaknow
Apr 30 2016 00:45
I see your point but when I try my function with a valid firstName and prop, it returns a wrong value. The exercise is "Profile Lookup". If I use lookUpProfile("Kristian", "lastName"), the return value is "Laine" which is contacts[0][lastName] instead of contacts[3][lastName].
lcassettai
@lcassettai
Apr 30 2016 00:57
@dontchaknow you are not making a condition
if (contacts[i].firstName && contacts[i][prop]) {
return contacts[i][prop];
}
you must ask for eg : if (contacts[i].firstName == firstName) or something that will return true or false
i think
Stephen James
@sjames1958gm
Apr 30 2016 00:58
@dontchaknow You need to compare the firstname to the firstname passed in
tbaugh
@tbaugh
Apr 30 2016 01:03
stuck on the where art thou challenge, currently passes first two tests, any tips on how to get it to work when the second argument has two properties?
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  collection.forEach(function(obj) {
    for (var prop in obj) {
      if (obj[prop] === source[prop]){
        arr.push(obj);
      }
    }
  });
  // Only change code above this line
  return arr;
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Stephen James
@sjames1958gm
Apr 30 2016 01:04
@tbaugh All of the source properties have to be in collection[i] before pushing onto the return arr
dontchaknow
@dontchaknow
Apr 30 2016 01:05
how does the function know when I'm referring to the parameter firstName vs the global variable firstName?
Stephen James
@sjames1958gm
Apr 30 2016 01:05
The local variable overrides any global variable
@dontchaknow There is no global firstname in this challenge.
dontchaknow
@dontchaknow
Apr 30 2016 01:06
oh true
Josue Godoy Lechuga
@josue1080
Apr 30 2016 01:06
help Filter Arrays with filter
CamperBot
@camperbot
Apr 30 2016 01:06

:point_right: challenge filter arrays with filter [wiki]

Filter is a useful method that can filter out values that don't match a certain criteria.

var array = [1,2,3,4,5,6,7,8,9,10];
  // Only change code below this line.
array = array.filter(function(val) {
  return val <= 5;
});

:pencil: read more about challenge filter arrays with filter on the FCC Wiki

dontchaknow
@dontchaknow
Apr 30 2016 01:07
but why am I wrong? if (contacts[i].firstName && contacts[i][prop]) if both properties exist, it will return true otherwise false.
Mr.Jois
@Sumanthjois
Apr 30 2016 01:08
can someon help me out with record collection problem in js
please
Stephen James
@sjames1958gm
Apr 30 2016 01:08
The point is that you are looking for a contact that has the same firstname as that passed in, then returning that prop if it exists on that contact
Mr.Jois
@Sumanthjois
Apr 30 2016 01:09

// 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) {
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) {

return collection;
}

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

return collection;
}

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

this is the problem
After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"
fter updateRecords(2548, "artist", ""), artist should not be set
Josue Godoy Lechuga
@josue1080
Apr 30 2016 01:09
help Sort Arrays with sort
CamperBot
@camperbot
Apr 30 2016 01:09

:point_right: challenge sort arrays with sort [wiki]

You can use the method sort to easily sort the values in the array alphabetically or numerically

var array = [1,3,2];

array = array.sort();

This will return [1, 2, 3]
:pencil: read more about challenge sort arrays with sort on the FCC Wiki

Mr.Jois
@Sumanthjois
Apr 30 2016 01:09
After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
After updateRecords(2548, "tracks", ""), tracks should not be set
lcassettai
@lcassettai
Apr 30 2016 01:10
@Sumanthjois format your code
Stephen James
@sjames1958gm
Apr 30 2016 01:10
@Sumanthjois You need to fill in code into updateRecords that uses id, prop, value and collection
lcassettai
@lcassettai
Apr 30 2016 01:11
blob
Mr.Jois
@Sumanthjois
Apr 30 2016 01:11
i have struggling
@sjames1958gm can please show me how
oh james you play chess?
i am a chess player too
Stephen James
@sjames1958gm
Apr 30 2016 01:12
@Sumanthjois If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop. this code means that you need an if statement that makes these same tests
@Sumanthjois I play at chess, not very good, like the strategy
Mr.Jois
@Sumanthjois
Apr 30 2016 01:13
@sjames1958gm i know the login can you please show me how to set the artist and all example please
Josue Godoy Lechuga
@josue1080
Apr 30 2016 01:13
help Concatenate Arrays with concat
CamperBot
@camperbot
Apr 30 2016 01:13
no wiki entry for: concatenate arrays with concat
Mr.Jois
@Sumanthjois
Apr 30 2016 01:14
@sjames1958gm just one example please
Stephen James
@sjames1958gm
Apr 30 2016 01:17
if ((value !== "") && (prop !== "tracks"))
Mr.Jois
@Sumanthjois
Apr 30 2016 01:23

if(value!==""){
if(prop === "artist"){
collectionCopy[id].artist = value;
}
else{
collectionCopy[id].tracks= value;
}

}
else if(prop === "artist"){
collectionCopy[id].artist = value;
}
else{
collection[id].tracks= value;
}

@sjames1958gm this is my code it's not working can i know why?
ali
@ahamidizadeh
Apr 30 2016 01:24
can some one help with my code?
Karan Bhandari
@karanbhandari
Apr 30 2016 01:28
@Sumanthjois Can you please elaborate what are you trying to do here in your code
Mr.Jois
@Sumanthjois
Apr 30 2016 01:29
if (prop === "tracks" && value !== "") {
collection[id][prop].push(value);
} else if (value !== ""){
collection[id][prop] = value;
} else {
delete collection[id][prop];
}
@karanbhandari this is my solution for record solution
it's not working
can i know why?
Karan Bhandari
@karanbhandari
Apr 30 2016 01:33
@Sumanthjois your previous code up here is really difficult to read. If you could ```
Mr.Jois
@Sumanthjois
Apr 30 2016 01:34
sure in a min
Karan Bhandari
@karanbhandari
Apr 30 2016 01:34
Code
or comment it, will be easier
Mr.Jois
@Sumanthjois
Apr 30 2016 01:34
'if (prop === "tracks" && value !== "") {
collection[id][prop].push(value);
} else if (value !== ""){
collection[id][prop] = value;
} else {
delete collection[id][prop];
}'
how to convert to code?
Karan Bhandari
@karanbhandari
Apr 30 2016 01:34
if (prop === "tracks" && value !== "") {
collection[id][prop].push(value);
} else if (value !== ""){
collection[id][prop] = value;
} else {
delete collection[id][prop];
}
Mr.Jois
@Sumanthjois
Apr 30 2016 01:35
yep exactly
what wrong with the code?
Karan Bhandari
@karanbhandari
Apr 30 2016 01:36
ok, so why is there space between delete and collection
Mr.Jois
@Sumanthjois
Apr 30 2016 01:36
what thats how it's wriiten
reedhammond
@reedhammond
Apr 30 2016 01:39
This message was deleted
Frank XC
@tenkdayz
Apr 30 2016 01:40
how can I set an element's offset when the window is scrolled (jquery) ?
reedhammond
@reedhammond
Apr 30 2016 01:41
Hello! Help please! I can't figure out what I did wrong.

var user = prompt("What is most important to you? Easy, Versatile or Fast").toLowerCase();

switch(user) {

case"easy": 
    var budget = prompt("What is your budget?").toLowerCase(); 
        if (budget > $200) {
            console.log ("Look at Tulas and Kinderpacks"); }

        else {
            console.log("Look at Ergos and Lilibabies"); 
            } 
        break;  


case "versatile": 
    var budget = prompt("What is your budget?").toLowerCase(); 
    var weight = prompt("How does your baby weight?").toLowerCase(); 
        if (budget <= 100 && weight >= 25 ) {
            console.log ("Check out Tehnki Apolos"); }

        else if  (budget <= 100 && weight <= 25){
            console.log("Look at the Babywearing on the Budget") 
            } 

        else  { 
            console.log("Check out the big swap but watch out! Its addicting");

        break;  

case "fast": 
    var budget = prompt("What is your budget?").toLowerCase(); 
    var weight = prompt("How does your baby weight?").toLowerCase(); 
        if (budget <= 100 || weight >= 25  ) {
            console.log ("Maybe a do it yourself ring sling?"); }
        else  { 
            console .log("Wrap conversion ring sling");

        break;  

default: 
    console.log("I know its hard but please make a choice."); 
        }
evide
@evid
Apr 30 2016 01:49
javaScript
myVar = 87 + 1;
ali
@ahamidizadeh
Apr 30 2016 01:50
@karanbhandari can u help me with my cash register problem? I think u hinted me yesterday but im still stuck on it
evide
@evid
Apr 30 2016 01:50
could someone help me out, I am being told to use the operator ++
Himanshu Batra
@manshu
Apr 30 2016 01:52
@reedhammond what’s wrong with your code ?
i mean what’s the error ?
evide
@evid
Apr 30 2016 01:55
thanks,
don't understand the increment number with JS
++ operator
I++;
Himanshu Batra
@manshu
Apr 30 2016 01:56
i++ is same as 1 + 1
it adds 1 more value to exisiting numner
number
evide
@evid
Apr 30 2016 01:57
so if I add 87 + 1, does it equal 87++;
Himanshu Batra
@manshu
Apr 30 2016 01:57
var a = 0; var a++; var a will now be 1
yes
dontchaknow
@dontchaknow
Apr 30 2016 01:57
is there a more elegant solution instead of 3 for loops for Profile Lookup?
Himanshu Batra
@manshu
Apr 30 2016 01:57
that’s correct
dontchaknow
@dontchaknow
Apr 30 2016 01:57
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
}
for (var j = 0; j < contacts.length; j++) {
if (contacts[j].firstName !== firstName && contacts[j].hasOwnProperty(prop) === true) {
return "No such contact";
}
}
for (var k = 0; k < contacts.length; k++) {
if (contacts[k].hasOwnProperty(prop) === false) {
return "No such property";
}
}
// Only change code above this line
}
Himanshu Batra
@manshu
Apr 30 2016 01:57
help format
CamperBot
@camperbot
Apr 30 2016 01:57

: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 the code.

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

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

evide
@evid
Apr 30 2016 01:57
thanks
dontchaknow
@dontchaknow
Apr 30 2016 01:59
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
        if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)) {
            return contacts[i][prop];
        }
    }
  for (var j = 0; j < contacts.length; j++) {
        if (contacts[j].firstName !== firstName && contacts[j].hasOwnProperty(prop) === true) {
            return "No such contact";
        }
    }
  for (var k = 0; k < contacts.length; k++) {
        if (contacts[k].hasOwnProperty(prop) === false) {
            return "No such property";
        }
    }
// Only change code above this line
}
it passed but is there a more elegant solution
reedhammond
@reedhammond
Apr 30 2016 01:59
@manshu SyntaxError: Unexpected token case
Himanshu Batra
@manshu
Apr 30 2016 02:00
yes
you can refactor the code.
dontchaknow
@dontchaknow
Apr 30 2016 02:00
how?
Himanshu Batra
@manshu
Apr 30 2016 02:00
This message was deleted
CamperBot
@camperbot
Apr 30 2016 02:00
no wiki entry for: look up profile
Himanshu Batra
@manshu
Apr 30 2016 02:01
This message was deleted
CamperBot
@camperbot
Apr 30 2016 02:01

:point_right: challenge using objects for lookups [wiki]

Challenge: Using Objects for Lookups

Objects can be thought of as a key/value storage, like a dictionary. If you have tabular data, you can use an object to "lookup" values rather than a switch statement or an if/else chain. This is most useful when you know that your input data is limited to a certain range.

Here is an example of a simple reverse alphabet lookup:

var alpha = {
  1:"Z",
  2:"Y",
  3:"X",
  4:"W",
  ...
  24:"C",
  25:"B",
  26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

:pencil: read more about challenge using objects for lookups on the FCC Wiki

dontchaknow
@dontchaknow
Apr 30 2016 02:01
ahh got it. i forgot there was a wiki.
Stephen James
@sjames1958gm
Apr 30 2016 02:01
@dontchaknow
for (var i = 0; i < contacts.length; i++) {
  if (contacts[i].firstName === firstName) {
     if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
     } else {
        return "No such property";
    }
  }
}
return "No such contact";
dontchaknow
@dontchaknow
Apr 30 2016 02:01
yes that's it
Himanshu Batra
@manshu
Apr 30 2016 02:01
@reedhammond I saw that, you have some error on the last case and default. Can you make sure of syntax
reedhammond
@reedhammond
Apr 30 2016 02:02
@manshu Thanks! I'll look again
CamperBot
@camperbot
Apr 30 2016 02:02
reedhammond sends brownie points to @manshu :sparkles: :thumbsup: :sparkles:
:star: 317 | @manshu | http://www.freecodecamp.com/manshu
Himanshu Batra
@manshu
Apr 30 2016 02:02
@sjames1958gm @dontchaknow yup that’s how you refactor
Daniel
@danisan14
Apr 30 2016 02:03
how do i make object properties private
evide
@evid
Apr 30 2016 02:03
getting syntax error, trying to figure out the correct answer
myVar = 87 + 1;
Himanshu Batra
@manshu
Apr 30 2016 02:03
which one are you on ?
@evid
3tef
@3tef
Apr 30 2016 02:04
// Example
var ourVar = 19;
ourVar=9;
// Only change code below this line
James Becker
@james-becker
Apr 30 2016 02:04
Anyone for pairing for Sorted Union BF?
function uniteUnique(arr1, arr2, arr3) {
    if (arr3 === null) {
      arr3 = [3];
    }
    if (arr2 === null) {
      arr2 = [4];
    }
  var arr4 = [];
  for ( i = 0; i < arr2.length; i++) {
    if (arr1.indexOf(arr2[i]) === -1) {
      arr1.push(arr2[i]);
    }
  }
  for ( i = 0; i < arr3.length; i++) {
    if (arr1.indexOf(arr3[i]) === -1) {
      arr1.push(arr3[i]);
    }
  }
  return arr1;
}
uniteUnique([1, 2, 3], [5, 2, 1]);
Anyone know how I can compensate for a case where arr2 and arr3 may be undefined?
Himanshu Batra
@manshu
Apr 30 2016 02:08
This message was deleted
CamperBot
@camperbot
Apr 30 2016 02:08
no wiki entry for: uniteunique
Himanshu Batra
@manshu
Apr 30 2016 02:08
wiki unite unique
CamperBot
@camperbot
Apr 30 2016 02:08
no wiki entry for: unite unique
Himanshu Batra
@manshu
Apr 30 2016 02:08
find sorted union
CamperBot
@camperbot
Apr 30 2016 02:08

find sorted union

:zero: algorithm sorted union

Stephen James
@sjames1958gm
Apr 30 2016 02:08
@Alhaji24 You were not supposed to change the line you did. var myArray = [1,2,3];
@Alhaji24 Use array access to change [1, 2, 3] to [3, 2, 3]
Ronique Ricketts
@RoniqueRicketts
Apr 30 2016 02:09
Hello guys I have another concern
please check out this video.
Stephen James
@sjames1958gm
Apr 30 2016 02:10
@RoniqueRicketts What are you trying to show?
Ronique Ricketts
@RoniqueRicketts
Apr 30 2016 02:11
I am doing the topic "Return a Value from a FUnction with Return" and each time I change my number according to my own comfort the returned answer is the same
Himanshu Batra
@manshu
Apr 30 2016 02:11
it’s displaying 25 because the algorithm is right, you can pass any value, it doesn’t matter
Ronique Ricketts
@RoniqueRicketts
Apr 30 2016 02:11

// Example
function minusSeven(num) {
return num - 7;
}

// Only change code below this line
function timesFive(num){
return num * 5;
}
var answer= timesFive (2);

Himanshu Batra
@manshu
Apr 30 2016 02:11
@RoniqueRicketts
Ronique Ricketts
@RoniqueRicketts
Apr 30 2016 02:11
here is the code i wrote
Stephen James
@sjames1958gm
Apr 30 2016 02:11
@RoniqueRicketts It is running its own tests.
Himanshu Batra
@manshu
Apr 30 2016 02:12
@RoniqueRicketts As long as the test passes, it doesn’t matter what the value is...
Ronique Ricketts
@RoniqueRicketts
Apr 30 2016 02:12
@sjames1958gm I just dont want to get the wrong impression about this. Is this a bug?
Himanshu Batra
@manshu
Apr 30 2016 02:13
No its not bug. @RoniqueRicketts
Stephen James
@sjames1958gm
Apr 30 2016 02:13
@RoniqueRicketts No the little window is showing the test that the challenge is running
Chris Cullen
@123xylem
Apr 30 2016 02:13
help confirm the ending
CamperBot
@camperbot
Apr 30 2016 02:13

:point_right: algorithm confirm the ending [wiki]

Explanation:

The function is a whole Boolean operation. You need to return true if the first argument ends with the second argument. This means that for the problem script, it should return true for the confirmEnding('Bastian', 'n'); case.

:pencil: read more about algorithm confirm the ending on the FCC Wiki

Steisaden
@steisaden
Apr 30 2016 02:13
thanks @leftynaut for your help with Checkpoint: Counting Cards
CamperBot
@camperbot
Apr 30 2016 02:13
steisaden sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
:star: 499 | @leftynaut | http://www.freecodecamp.com/leftynaut
Ronique Ricketts
@RoniqueRicketts
Apr 30 2016 02:14
@manshu so in reality the returned amount should change based on whatever number I enter right?
Stephen James
@sjames1958gm
Apr 30 2016 02:14
@RoniqueRicketts yes
Himanshu Batra
@manshu
Apr 30 2016 02:14
yes, these are based on testing values. @RoniqueRicketts
In real life you might use debugger for this
Ronique Ricketts
@RoniqueRicketts
Apr 30 2016 02:15
oh ok. thanks again guys. :) I appreciate it @sjames1958gm @manshu
CamperBot
@camperbot
Apr 30 2016 02:15
roniquericketts sends brownie points to @sjames1958gm and @manshu :sparkles: :thumbsup: :sparkles:
:star: 849 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
:star: 318 | @manshu | http://www.freecodecamp.com/manshu
Himanshu Batra
@manshu
Apr 30 2016 02:15
find chunky
CamperBot
@camperbot
Apr 30 2016 02:15

find chunky

:zero: algorithm chunky monkey

Mr.Jois
@Sumanthjois
Apr 30 2016 02:22
need help with Generate Random Fractions with JavaScript




function randomFraction() {

  // Only change code below this line.
var number = Math.random() +10;
  return number;

  // Only change code above this line.
}

function randomFraction() {

// Only change code below this line.
var number = Math.random() +10;
return number;

// Only change code above this line.
}

```

can i know why this is not working
Diego Mayer
@Chrono79
Apr 30 2016 02:25
@Sumanthjois isn't it Math.random() * 10 ?
Math.random() returns a number between 0 and 1 (including 0 but not 1)
Leonardo Galante
@lndgalante
Apr 30 2016 02:25
I'm stucked at the Counting Cards algorithm
Diego Mayer
@Chrono79
Apr 30 2016 02:26
@Fenwil Paste your code
Leonardo Galante
@lndgalante
Apr 30 2016 02:26

var count = 0;

function cc(card) {
// Only change code below this line
if (2 <= card <= 6) {
count += 1;
} else if (7 <= card <= 9) {
count += 0;
} else if (card === 10 || card === "J" || card === "Q" || card === "K" || card === "A") {
count -= 1;
}

if (count > 0) {
return count + " " + "Bet";
} else if (count <= 0) {
return count + " " + "Hold";
}

// Only change code above this line
}

Stephen James
@sjames1958gm
Apr 30 2016 02:27
if (2 <= card <= 6) { this is not valid syntax
Leonardo Galante
@lndgalante
Apr 30 2016 02:27
Ahh I get it
@sjames1958gm thanks!!
CamperBot
@camperbot
Apr 30 2016 02:27
fenwil sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 850 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 30 2016 02:27
@Fenwil :+1:
Diego Mayer
@Chrono79
Apr 30 2016 02:27
@Fenwil look this
You can also skip this:
} else if (7 <= card <= 9) {
count += 0;
help format
CamperBot
@camperbot
Apr 30 2016 02:27

: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 the code.

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

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

Freedom Martin
@Freedizzle
Apr 30 2016 02:29

// Only change code below this line

var myStr = "This is the first sentence. " += "This is the second sentence.";

could someone tell me what im doing wrong here?
Himanshu Batra
@manshu
Apr 30 2016 02:29
you are adding two sentences in myStr variable
Stephen James
@sjames1958gm
Apr 30 2016 02:29
@Freedizzle += is not valid syntax at that point +=
@Freedizzle Remove the = in the +=
Diego Mayer
@Chrono79
Apr 30 2016 02:30
@Freedizzle
var myStr = "This is the first sentence. ";
myStr += "This is the second sentence.";
@sjames1958gm I think he should use +=
Freedom Martin
@Freedizzle
Apr 30 2016 02:30
Ahhh, got it! Thank you @Chrono79
CamperBot
@camperbot
Apr 30 2016 02:30
freedizzle sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 566 | @chrono79 | http://www.freecodecamp.com/chrono79
Stephen James
@sjames1958gm
Apr 30 2016 02:30
@Chrono79 Ah - yes - did not know the challenge
Diego Mayer
@Chrono79
Apr 30 2016 02:31
@Freedizzle @sjames1958gm answer was ok, in other context.
lindsy
@lindsymoran
Apr 30 2016 02:36
thanks @CaroleAnneHannon for your help with Checkpoint: Stand in Line
CamperBot
@camperbot
Apr 30 2016 02:36
lindsymoran sends brownie points to @caroleannehannon :sparkles: :thumbsup: :sparkles:
:star: 841 | @caroleannehannon | http://www.freecodecamp.com/caroleannehannon
Edward Hilgendorf
@edhilgendorf
Apr 30 2016 02:46
Hi everyone,I am a little stuck with the Random Quote Generator for sending out the tweet. Does anyone know if it is possible to use the tweet link, and just modify the href attribute with .attr() to add the text value from the quote? I can't get it to populate the tweet and I am unsure why
Jon
@Antiphilous
Apr 30 2016 02:48
Hey guys I just completed the profile lookup challenge but I'm a little concerned about how I completed it
anyone willing to take a brief look at my code
?
Edward Hilgendorf
@edhilgendorf
Apr 30 2016 02:48
I will
Jon
@Antiphilous
Apr 30 2016 02:48
function lookUpProfile(firstName, prop){
var i = 0;
while(firstName != contacts[i].firstName){
  i++;
  if(i >= contacts.length){
    return "No such contact";

  }
}
  if(firstName == contacts[i].firstName){

    if(contacts[i].hasOwnProperty(prop)){

      return contacts[i][prop];

    } else {

      return "No such property";
    }


  }
Diego Mayer
@Chrono79
Apr 30 2016 02:49
@Antiphilous not good
Jon
@Antiphilous
Apr 30 2016 02:50
Im mostly worried about the while loop, I made it such that if it goes through the entire contact object without finding the first name it will return "no such contact", my worry is that the while loop has no exit otherwise
@Chrono79 Yeah I figured but it still accepted it as completed challenge so I haven't moved on yet
Diego Mayer
@Chrono79
Apr 30 2016 02:50
@Antiphilous I think you passed the test because the test set helped you
You should put the if/else inside the loop, and the return no such contact outside
Brandon Lee
@brandonlee781
Apr 30 2016 02:51
Hey everyone, got a quick question. I'm trying to use Objects in my latest project. Is it possible to declare a constructor function INSIDE an object literal? If I want to an object to have a bunch of properties that are also objects, can the constructor be a property of it as well?
Jon
@Antiphilous
Apr 30 2016 02:52
@Chrono79 ok
Diego Mayer
@Chrono79
Apr 30 2016 02:52
@Antiphilous wait a minute, let me see your code again
it's late here
Well, it's a little weird, but it'll work
Jon
@Antiphilous
Apr 30 2016 02:53

@Chrono79 ```js
function lookUpProfile(firstName, prop){
var i = 0;
while(firstName != contacts[i].firstName){
i++;
if(i >= contacts.length){
return "No such contact";

}
}
if(firstName == contacts[i].firstName){

if(contacts[i].hasOwnProperty(prop)){

  return contacts[i][prop];

} else {

  return "No such property";
}

}
```

@Chrono79 shoot hang on
function lookUpProfile(firstName, prop){
var i = 0;
while(firstName != contacts[i].firstName){
  i++;
  if(i >= contacts.length){
    return "No such contact";

  }
}
  if(firstName == contacts[i].firstName){

    if(contacts[i].hasOwnProperty(prop)){

      return contacts[i][prop];

    } else {

      return "No such property";
    }


  }
@Chrono79 ok is there a better programming practice that I should use in this kind of scenario?
@Chrono79 I figured that the return would exit the function and also exit the loop my worry is that I would have created a while loop with no exit
Diego Mayer
@Chrono79
Apr 30 2016 02:55
@Antiphilous I don't know if it's better, in general they use a for loop, with the conditions you have outside your loop inside, and outside returns "No such contact"
Jon
@Antiphilous
Apr 30 2016 02:56
@Chrono79 ahh Ok I was trying a for loop earlier but was having a tough time of it
@Antiphilous Thank you for the help I will go back and review it
CamperBot
@camperbot
Apr 30 2016 02:56
sorry antiphilous, you can't send brownie points to yourself! :sparkles: :sparkles:
Jon
@Antiphilous
Apr 30 2016 02:57
@Chrono79 Thanks for the help... have the brownie points... w/e they are lol
CamperBot
@camperbot
Apr 30 2016 02:57
antiphilous sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 567 | @chrono79 | http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Apr 30 2016 02:57
@Antiphilous hahaha, I've never seen that message
The only way it will become an infinite loop is if you increase contacts length or don't increase i, I think you're safe
Mary
@mapruter
Apr 30 2016 02:59
what is
foo
Diego Mayer
@Chrono79
Apr 30 2016 03:00
@mapruter foo and bar are 2 words used in code examples
if you give some context I could answer better
Mary
@mapruter
Apr 30 2016 03:00
i'm not sure what you mean @Chrono79
Jon
@Antiphilous
Apr 30 2016 03:00
@Chrono79 I see the way it can be done with for loops
@Antiphilous Cool, good profile pic btw
peace out
Mary
@mapruter
Apr 30 2016 03:03
ah so it's like the lorem ipsum of code, @Chrono79 ?
Dylan
@dhcodes
Apr 30 2016 03:03
yep @mapruter
Mary
@mapruter
Apr 30 2016 03:04
sweet thans @Chrono79 and @dhcodes
Dylan
@dhcodes
Apr 30 2016 03:04
it's two words used to represent generic variables
Mary
@mapruter
Apr 30 2016 03:04
thanks @Chrono79 @dhcodes
CamperBot
@camperbot
Apr 30 2016 03:04
mapruter sends brownie points to @chrono79 and @dhcodes :sparkles: :thumbsup: :sparkles:
:star: 568 | @chrono79 | http://www.freecodecamp.com/chrono79
:star: 715 | @dhcodes | http://www.freecodecamp.com/dhcodes
Diego Mayer
@Chrono79
Apr 30 2016 03:05
'nite everyone
Norvin Burrus
@ndburrus
Apr 30 2016 03:37
@mapruter foo & bar: Foobar is a universal variable understood to represent whatever is being discussed. It's usually used in examples that illustrate concepts and ideas in computer science. For instance, a computer science professor may be discussing different file formats.
Mary
@mapruter
Apr 30 2016 03:38
if they were discussing different file formats, how would foo & bar be used @ndburrus ?
Michael Steffan
@michaelsteffan
Apr 30 2016 03:39
Hey!

function convertToF(celsius) {
// Only change code below this line

var fahrenheit = 9/5 + 32;

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

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

It's not working.
Need me to change output.
Norvin Burrus
@ndburrus
Apr 30 2016 03:39
@mapruter another description. ...moment...
@mapruter The terms foobar (/ˈfuːbɑːr/), or foo and others are used as placeholder names (also referred to as metasyntactic variables) in computer programming or computer-related documentation.1 They have been used to name entities such as variables, functions, and commands whose exact identity is unimportant and serve only to demonstrate a concept.
Michael Steffan
@michaelsteffan
Apr 30 2016 03:41
?
Norvin Burrus
@ndburrus
Apr 30 2016 03:41
@mapruter Format[edit]
A file URI takes the form of
file://host/path
where host is the fully qualified domain name of the system on which the path is accessible, and path is a hierarchical directory path of the form directory/directory/.../name. If host is omitted, it is taken to be "localhost", the machine from which the URL is being interpreted. Note that when omitting host, the slash is not omitted (while "file:///foo.txt" is valid, "file://foo.txt" is not, although some interpreters manage to handle the latter).
[RFC 3986] includes additional information about the treatment of ".." and "." segments in URIs.
Mary
@mapruter
Apr 30 2016 03:42
ok cool. that's what i thought you meant. i just wanted to make sure i was on the same page. thanks @ndburrus
CamperBot
@camperbot
Apr 30 2016 03:42
mapruter sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 283 | @ndburrus | http://www.freecodecamp.com/ndburrus
Tim Dionisio
@tdionisio1060
Apr 30 2016 03:42
Need a small point in the right direction on the "Stand In Line" assignment. Failing these conditions.
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5

function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift(item);

return item; // Change this line
}

Norvin Burrus
@ndburrus
Apr 30 2016 03:43
@michaelsteffan which challenge is that?
@mapruter :sparkles:
Mary
@mapruter
Apr 30 2016 03:44
it was a couple ones ago, they just used foo randomly. and i'd seen it before in other texts. i just never really knew what it meant
i don't remember the exact lesson that used it though
lorenzopieri
@lorenzopieri
Apr 30 2016 03:45
hello
im trying to use str.fromCharCode but it won't let me
it says it's not a function
Mary
@mapruter
Apr 30 2016 03:45
I just did the switch statement and it passed me, but I'm getting warnings and I want to know what I could do to make them go away. Below is my code:
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case 1:
      return "alpha";
      break;
    case 2:
      return "beta";
      break;
    case 3:
      return "gamma";
      break;
    case 4:
      return "delta";
  }


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

// Change this value to test
caseInSwitch(1);
Tim Dionisio
@tdionisio1060
Apr 30 2016 03:47
@mapruter I was having the same issue with the Golf code.
Haven't quite figured it out
lorenzopieri
@lorenzopieri
Apr 30 2016 03:48
what does the warning say if you hover over it?
maybe you should also do a break on the fourth case and create a default case
Mary
@mapruter
Apr 30 2016 03:52
@lorenzopieri it says unreachable 'break' after 'return'
lorenzopieri
@lorenzopieri
Apr 30 2016 03:52
try to do what I just told you: insert a break statement after case 4 and also insert a default case
Mary
@mapruter
Apr 30 2016 03:53
what's a default case?
evide
@evid
Apr 30 2016 03:53
still trying to figure this out (the var myVar87++;) is incorrect ???
Mary
@mapruter
Apr 30 2016 03:54
ok i think i figured it out @lorenzopieri , but it's still giving me the same warning
lorenzopieri
@lorenzopieri
Apr 30 2016 03:54
A default case is like the case that the Switch takes if no other case is good
Mary
@mapruter
Apr 30 2016 03:54
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case 1:
      return "alpha";
      break;
    case 2:
      return "beta";
      break;
    case 3:
      return "gamma";
      break;
    default:
      return "delta";
      break;
  }


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

// Change this value to test
caseInSwitch(1);
lorenzopieri
@lorenzopieri
Apr 30 2016 03:54
try to delete all the breaks
all of them
the statement will always return anyway
so the break will never be reached
i think that's the problem
well, not a problem, just the way javascript is built
Mary
@mapruter
Apr 30 2016 03:55
when i do that the warnings go away, but it no longer passes me on the lesson
```

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val) {
case 1:
return "alpha";
case 2:
return "beta";
case 3:
return "gamma";
default:
return "delta";
}

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

// Change this value to test
caseInSwitch(1);
```

lorenzopieri
@lorenzopieri
Apr 30 2016 03:56
well then, pass the lesson with the warning, it's FreeCodeCamp's fault this time
it is as I just explained to you, the return statement is like a break for anything, not just for the switch
Mary
@mapruter
Apr 30 2016 03:56
ok cool, i just wasn't sure if there was something i could be doing better
lorenzopieri
@lorenzopieri
Apr 30 2016 03:56
So if the case ever finds a return statement, it will never go down to the break statement, because it exited
nah, the best thing is to take away all the breaks if you wanna do it good, but if the compiler from FCC doesnt accept it it's not your fault XD
Mary
@mapruter
Apr 30 2016 03:57
@lorenzopieri the lesson says
The break tells JavaScript to stop executing statements. If the break is omitted, the next statement will be executed.
lorenzopieri
@lorenzopieri
Apr 30 2016 03:58
yes, but the return statement also breaks anything, breaks aswell XD
Mary
@mapruter
Apr 30 2016 03:58
oh ok
lorenzopieri
@lorenzopieri
Apr 30 2016 03:58
so you did good on the exercise, the warning is because the return statement will always get you OUT of the switch
which means that you will never reach the break
which means that you don't really need it, if not for this exercise in particular
Sekhar Kolli
@SekharKolli
Apr 30 2016 03:59
@evid , did you figureout the answer?
Mary
@mapruter
Apr 30 2016 03:59
gotcha. is there anything that you could write that would execute the statement that NEEDS the break after it @lorenzopieri ?
Goun Choe
@lenaChoe
Apr 30 2016 04:01

Hi guys, anyone can give me a tip for this problem? I'm tring to make destroyer function which works like "destroyer([1, 2, 3, 1, 2, 3], 2, 3) should return [1, 1].
destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) should return [1, 5, 1].
destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return 1.
destroyer([2, 3, 2, 3], 2, 3) should return [].
destroyer(["tree", "hamburger", 53], "tree", 53) should return ["hamburger"]." this. but I saves the arguments in different arrays like this.

var array = Array.prototype.slice.call(arr);
var argArr = Array.prototype.slice.call(arguments, 1);

but I'm having trouble to filter the original array(var array).. What algorithm I can filter the arguments in argArr filter out from the original array??

Michael Steffan
@michaelsteffan
Apr 30 2016 04:01
Can you guys help me with a question?
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
lorenzopieri
@lorenzopieri
Apr 30 2016 04:02
@mapruter Not in your case because the exercise asks you to return something, which is what you did exactly; you could use a trick by storing a value inside a variable, breaking the switch statement, checking whether the variable has that value and after that make the return statement outside of the Switch, which would take away the warning. You understand that this is pretty elaborate and also dumb XD
Mary
@mapruter
Apr 30 2016 04:04
yeah i know not in the exercise. i just me in general outside the scope of that one lesson, is there something would need break
lorenzopieri
@lorenzopieri
Apr 30 2016 04:05
Yes, breaks are used in switches and also loops for stopping anything whenever you need it to stop. Their usage depends on the way you want to use them and yes, they are very useful.
Mary
@mapruter
Apr 30 2016 04:12
thanks @lorenzopieri
CamperBot
@camperbot
Apr 30 2016 04:12
:star: 369 | @lorenzopieri | http://www.freecodecamp.com/lorenzopieri
mapruter sends brownie points to @lorenzopieri :sparkles: :thumbsup: :sparkles:
Lissa Sigle
@lsigle
Apr 30 2016 04:12
help Access MultiDimensional Arrays With Indexes
CamperBot
@camperbot
Apr 30 2016 04:12
no wiki entry for: access multidimensional arrays with indexes
Jevaughn Vance
@jvans7
Apr 30 2016 04:21
Anyone did lesson 63 Comparison with the Less Than Operator?
Chase
@Belax8
Apr 30 2016 04:22
@jvans7 I have. Are you stuck on that one?
Julian Betancourt
@julianbetancourt
Apr 30 2016 04:23
Hi guys :)
Jevaughn Vance
@jvans7
Apr 30 2016 04:23
@Belax8 Yes i'm stuck. can you help me out
? please
Julian Betancourt
@julianbetancourt
Apr 30 2016 04:24
do you guys know how to manipulate elements that are not in pageload with jquery ?
Chase
@Belax8
Apr 30 2016 04:24
@jvans7 Ya. What have you done so far? What does your code look like?
Julian Betancourt
@julianbetancourt
Apr 30 2016 04:25
I'm adding some html with jquery, once those elements finish loading, I want to manipulate some of them
Jevaughn Vance
@jvans7
Apr 30 2016 04:26

@Belax8 function testLessThan(val) {
if (val < 30) { // Change this line
return "Under 25";
}

if (val < 40) { // Change this line
return "Under 55";
}

return "55 or Over";
}

// Change this value to test
testLessThan(25);

i have these two with X testLessThan(25) should return "Under 55"
testLessThan(54) should return "Under 55"
Norvin Burrus
@ndburrus
Apr 30 2016 04:27

@mapruter Break statement/s: Definition and Usage
The break statement exits a switch statement or a loop (for, for ... in, while, do ... while).

When the break statement is used with a switch statement, it breaks out of the switch block. This will stop the execution of more execution of code and/or case testing inside the block.

When the break statement is used in a loop, it breaks the loop and continues executing the code after the loop (if any).

The break statement can also be used with an optional label reference, to "jump out" of any JavaScript code block (see "More Examples" below).

Note: Without a label reference, the break statement can only be used inside a loop or a switch.

Chase
@Belax8
Apr 30 2016 04:28
@jvans7 try changing your 30 to 25 and your 40 to 55
Norvin Burrus
@ndburrus
Apr 30 2016 04:29
@mapruter
js
<var text = "";
var i, j;

Loop1: // The first for loop is labeled "Loop1"
for (i = 0; i < 3; i++) {
text += "<br>" + "i = " + i + ", j = ";

    Loop2: // The second for loop is labeled "Loop2"
    for (j = 10; j < 15; j++) {
        if (j === 12) {
            break Loop2;
        }
        document.getElementById("demo").innerHTML = text += j + " ";
    }
}
The result of text will be:

i = 0, j = 10 11
i = 1, j = 10 11
i = 2, j = 10 11>
Mary
@mapruter
Apr 30 2016 04:29
@ndburrus what do you mean without a label reference?
Jevaughn Vance
@jvans7
Apr 30 2016 04:29
@Belax8 you're the man thanks
CamperBot
@camperbot
Apr 30 2016 04:29
:star: 337 | @belax8 | http://www.freecodecamp.com/belax8
jvans7 sends brownie points to @belax8 :sparkles: :thumbsup: :sparkles:
Norvin Burrus
@ndburrus
Apr 30 2016 04:30
@mapruter ...did you mean "with an optional label reference"?
Mary
@mapruter
Apr 30 2016 04:31
you said "Note: Without a label reference, the break statement can only be used inside a loop or a switch."
just wasn't sure what you meant by that @ndburrus
Norvin Burrus
@ndburrus
Apr 30 2016 04:32
@mapruter oh, without a label ref, it functions/works normally....
@mapruter ...so to answer your question - I'm not aware of any instances when you would use a break statement other than identified in these instances...
Mary
@mapruter
Apr 30 2016 04:34
ok cool thanks
Norvin Burrus
@ndburrus
Apr 30 2016 04:36
@mapruter maybe I was off just a bit. maybe this will help. i think you were looking for an example of when to use a break statement (just reread you text). example follows:
js 
<Example
In this example we use a while loop together with the break statement.

Loop through a block of code, but exit the loop when the variable i is equal to "3":

var text = "";
var i = 0;
while (i < 5) {
    text += "<br>The number is " + i;
    i++;
    if (i === 3) {
        break;
    }
}
The result of text will be:

The number is 0
The number is 1
The number is 2>
@mapruter your*
@mapruter ...now, don't ask me why the loop is established with a parameter of 5, and the desire is to exit the loop at 3...!?!?
@mapruter it's just an example....illustrating a point.
Edward Hilgendorf
@edhilgendorf
Apr 30 2016 04:41
Hi, is anyone able to get coordinates in Codepen using Navigator? I cannot get them
It doesn't even ask for my permission like it does in FCC example
Kyle Roden
@kyleroden
Apr 30 2016 04:42
@edhilgendorf Yeah, it took me all day! Use this api, you don't even need a key:http://ip-api.com/json
it will return an object with latitude and longitude properties of the device using the site
Edward Hilgendorf
@edhilgendorf
Apr 30 2016 04:43
@kyleroden Thank you!
CamperBot
@camperbot
Apr 30 2016 04:43
edhilgendorf sends brownie points to @kyleroden :sparkles: :thumbsup: :sparkles:
Kyle Roden
@kyleroden
Apr 30 2016 04:43
I was so frustrated trying to figure this out!
CamperBot
@camperbot
Apr 30 2016 04:43
:star: 286 | @kyleroden | http://www.freecodecamp.com/kyleroden
Edward Hilgendorf
@edhilgendorf
Apr 30 2016 04:43
Still wonder why navigator doesn't work. Maybe it's disabled in CP?
Kyle Roden
@kyleroden
Apr 30 2016 04:43
because you have to have https
and to have https with code, you gotta $
codpen*
Edward Hilgendorf
@edhilgendorf
Apr 30 2016 04:44
oic
Kyle Roden
@kyleroden
Apr 30 2016 04:44
codepen*!
Edward Hilgendorf
@edhilgendorf
Apr 30 2016 04:44
thanks
Norvin Burrus
@ndburrus
Apr 30 2016 04:45
@mapruter which challenge gave you the warnings, but passed the tests?
Muhammad Zaky Fauzi
@ZackOS
Apr 30 2016 04:54

hi there, so in waypoint record collection the function that i tried to test seems not working only on the delete part, here is the #1 attempt

function updateRecords(id, prop, value) {
if(value !== "") {
    if(prop !== "tracks") {
      collection[id][prop] = value;
    } else {
      collection[id][prop].push(value);
    }
else{
   delete collection[id][prop];
   }
 }
 return collection;
}

after a while i finally figured it out, here is the second one (working)

function updateRecords(id, prop, value) {
  if (value !== "" && prop === "tracks"){
  collection[id][prop].push(value);
   }else if(value !== ""){
    collection[id][prop]=value;
  }else{
    delete collection[id][prop];
  }
return collection;
}

the question is : what is the difference?

"My code isn't working , don't have any idea why.
My code is working, don't have any idea why"

Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 04:57
the format for the if else statement is always if-else if-else if-...-else if-else
thats why
if there are 2 conditions then it will be if-else
@ZackOS
Michael Steffan
@michaelsteffan
Apr 30 2016 04:58

Code isn't working, not sure why.

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
wordBlanks("cat", "little", "hit", "slowly");
// Your code above this line
return result;
}

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

Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 05:00
the problem is you have to declare what the "result" will return
i dont know how to explain it lol
Michael Steffan
@michaelsteffan
Apr 30 2016 05:00
result = wordBlanks("dog", "big", "ran", "quickly");
Muhammad Zaky Fauzi
@ZackOS
Apr 30 2016 05:00
@nctl144 the else {delete stuff} is with if(value !== "") {}
if(value !== "") {}else{delete stuff}
Norvin Burrus
@ndburrus
Apr 30 2016 05:02
@ZackOS ...also check the if/else logic. does the else explicitly/implicitly include ===? im not sure, but it was easier for me to simply use that condition....
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 05:03
@michaelsteffan the result is a string man
Michael Steffan
@michaelsteffan
Apr 30 2016 05:03
Edited to result = myNoun + myAdjective + myVerb + myAdverb;
Norvin Burrus
@ndburrus
Apr 30 2016 05:04
@ZackOS ...my comment applies to the first posted code.
Brian
@sludge256
Apr 30 2016 05:04
Now you need spaces between the words. @michaelsteffan
Muhammad Zaky Fauzi
@ZackOS
Apr 30 2016 05:04
This message was deleted
Michael Steffan
@michaelsteffan
Apr 30 2016 05:05
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 05:08
Capture.PNG
Muhammad Zaky Fauzi
@ZackOS
Apr 30 2016 05:08
function updateRecords(id, prop, value) {
if(value !== "") {
    if(prop !== "tracks") {
      collection[id][prop] = value;
    } else {
      collection[id][prop].push(value);
    }
else{
   delete collection[id][prop];
   }
 }
 return collection;
}
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 05:08
hey does anyone know how to delcare a space?
@ZackOS its just all about logic
Norvin Burrus
@ndburrus
Apr 30 2016 05:08
@michaelsteffan use the var/iable/s (result), and myNoun, myAdjective, etc. to form the desired output/result....
Michael Steffan
@michaelsteffan
Apr 30 2016 05:09
Never mind, found the solution.
Muhammad Zaky Fauzi
@ZackOS
Apr 30 2016 05:09
@nctl144 i'm asking for the logic, haha
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 05:10
@ZackOS i dont know how to explain. but heres the thing. if you declare if "value is not blank" then else should be "value is blank"
Norvin Burrus
@ndburrus
Apr 30 2016 05:11
@ZackOS that would be a true statement.
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 05:11
if you combine "value is not blank" and "prop is not blank" at the same time then there should be 4 solutions i believe
@ZackOS lol im lost in your question now
Norvin Burrus
@ndburrus
Apr 30 2016 05:13
@ZackOS but you are not declaring prop as not blank. you are declaring prop as not tracks.
@ZackOS im not sure my comment applied. i was responding to @nctl144 's comment. in any event, the code is clearer for me when multiple conditions are applied within a single/else if if statement/s (i.e. clearer than nested single conditions).
Muhammad Zaky Fauzi
@ZackOS
Apr 30 2016 05:17
@ndburrus @nctl144 ok, so apparently i only misplaced the brackets and wrong declaration. thank you guys. and also the 2nd one is more simple
CamperBot
@camperbot
Apr 30 2016 05:17
zackos sends brownie points to @ndburrus and @nctl144 :sparkles: :thumbsup: :sparkles:
:star: 247 | @nctl144 | http://www.freecodecamp.com/nctl144
:star: 284 | @ndburrus | http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Apr 30 2016 05:17
@ZackOS
js
<  if (value !== "" && prop !== "tracks") {
   //
    collection[id][prop] = value;
  }
  else if (value !== "" && prop == "tracks") {
   // 
    collection[id][prop].push(value);
  }
  else if (value === "") {

    delete collection[id][prop];
  }
  return collection;
  }
  while (collection[id] == "id");
}>
@ZackOS ...also the === condition is explicitly indicated/stated.... Kudos to you! :+1:
@nctl144 did you get a response? which challenge is that?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 05:21
i passed it thank you:)
im about to have new problem soon
Muhammad Zaky Fauzi
@ZackOS
Apr 30 2016 05:21
about to have ? :smile:
CamperBot
@camperbot
Apr 30 2016 05:21
you need to ask about @someone!
Spencer Kuzara
@kodaxx
Apr 30 2016 05:23
Anyone here that can answer a question for me about Wikipedia viewer zipline?
Frank XC
@tenkdayz
Apr 30 2016 05:24
@kodaxx go
Spencer Kuzara
@kodaxx
Apr 30 2016 05:25
Okay, so it seems like sometimes my request doesn't go through, and other times it does. I will get the success message sometimes and others I just get nothing. Is that a problem with API or my code? I can link to my codepen
I'm only just getting to the JS part, so the page is not really functional yet, but I have some console.logs set up so I know that I'm taking the right steps
$("#search-button").on("click", function() {
  var searchQuery = encodeURI($("#search-box").val());
  console.log(searchQuery);

  //wikipedia API request
  $.ajax({
  url: 'http://en.wikipedia.org/w/api.php',
  data: {action: 'query',
         format: 'json',
         list: 'search',
         srsearch: searchQuery,
         srprop: 'titlesnippet%7Csnippet' },
  dataType: 'jsonp',
  success: function (x) {
  console.log('request success');
  }
});
      });
Does this all look correct?
Sebastian Chua
@ChewChuTrain
Apr 30 2016 05:29
This message was deleted
Boyce
@Yijianc
Apr 30 2016 05:36
help Sum All Primes
CamperBot
@camperbot
Apr 30 2016 05:36

:point_right: algorithm sum all primes [wiki]

Explanation:

The explanation for this problem is very simple. You will generate a list of prime numbers up to the number you are given as a parameter. Then you need to add them all up and return that value. The tricky part is on generating the list of prime numbers. I suggest you find a code or a good math algorithm that you can turn into code.

:pencil: read more about algorithm sum all primes on the FCC Wiki

Spencer Kuzara
@kodaxx
Apr 30 2016 05:41
@tenkdayz Any ideas?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 05:41
does anyone know how to compare 2 strings?
Sebastian Chua
@ChewChuTrain
Apr 30 2016 05:44

Hey guys, doing the Record Collection waypoint and having trouble pushing values into the nested array. Any ideas on how to fix it?

function updateRecords(id, prop, value) {
if (value !== "" && collection[id][prop] !== "tracks") {
collection[id][prop] = value;
} else if (value !== "" && collection[id][prop] == "tracks") {
collection[id].tracks.push("cat");
} else if (value === "") {
delete collection[id][prop];
}
return collection;
}

Norvin Burrus
@ndburrus
Apr 30 2016 05:44
@nctl144 when comparing 2 strings, convert to arrays to compare...
Spencer Kuzara
@kodaxx
Apr 30 2016 05:44
I mean, I can't very well keep goign if it's the API's fault, how will I test to make sure things are working as I go along?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 05:44
@ndburrus i did and im just wondering how to compare 2 arrays
Spencer Kuzara
@kodaxx
Apr 30 2016 05:44
If it's my fault I'd like to understand though
Norvin Burrus
@ndburrus
Apr 30 2016 05:45
@ChewChuTrain check this statement: collection[id].tracks.push("cat");
Ante
@JilaMK64
Apr 30 2016 05:46
@nctl144 I made for loops for that
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 05:47
@JilaMK64 what do you do in the loop
Ante
@JilaMK64
Apr 30 2016 05:48
Take one element from first array, and I check is it an element of another array
Sebastian Chua
@ChewChuTrain
Apr 30 2016 05:48
@ndburrus sorry i forgot to change it back to collection[id].tracks.push(value);
Ante
@JilaMK64
Apr 30 2016 05:49
@nctl144 It is nesteed arrays. Shall I send you code ex
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 05:49
hang on a sec i think i can do it ill tell you if i get stuck soon
Norvin Burrus
@ndburrus
Apr 30 2016 05:49
@nctl144
js
<function arraysAreIdentical(arr1, arr2){
    if (arr1.length !== arr2.length) return false;
    for (var i = 0, len = arr1.length; i < len; i++){
        if (arr1[i] !== arr2[i]){
            return false;
        }
    }
    return true; 
}>
Sebastian Chua
@ChewChuTrain
Apr 30 2016 05:50
@ndburrus when I try to run this code, the whole array "tracks" becomes replaced with whatever's in "value"
Norvin Burrus
@ndburrus
Apr 30 2016 05:50
@ChewChuTrain moment...
@ChewChuTrain ...why is cat being pushed?
@ChewChuTrain ...might that need to be a var/iable?
Ante
@JilaMK64
Apr 30 2016 05:53
@ChewChuTrain What is purpose of your code?
James Becker
@james-becker
Apr 30 2016 05:54
Hi all, can someone please explain how this filter (from BF Sorted Union) works? I don't understand how it can function with 2 variable arguments (item and pos). The FCC BF page has no further documentation on how it works either.
  uniqueArray = concatArr.filter(function(item, pos) {
    return concatArr.indexOf(item) == pos;
  });
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 05:55
Capture.PNG
@ndburrus can you tell me what's wrong with my code?
Muhammad Zaky Fauzi
@ZackOS
Apr 30 2016 05:57
@ChewChuTrain the idea of that waypoint is updateRecords() will add new prop or update the existing prop if the requierments are fulfilled
Norvin Burrus
@ndburrus
Apr 30 2016 05:58
@nctl144 im working on that one also. one thing i notice is that the split removes spaces, i believe. it is indicated that in addition to spaces being removed, that punctuation & symbols need to also be removed.
Zuo Bruno
@Brun0L3z
Apr 30 2016 05:59
How can I send my code as I see others sending here?
Norvin Burrus
@ndburrus
Apr 30 2016 06:00
@nctl144 ...also, it looks like the if "else" logic, needs the else....
help paste code
CamperBot
@camperbot
Apr 30 2016 06:00
no wiki entry for: paste code
Norvin Burrus
@ndburrus
Apr 30 2016 06:00
help post code
CamperBot
@camperbot
Apr 30 2016 06:00
Zuo Bruno
@Brun0L3z
Apr 30 2016 06:01
Thanks @camperbot
CamperBot
@camperbot
Apr 30 2016 06:01
brun0l3z sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1632 | @camperbot | http://www.freecodecamp.com/camperbot
Zuo Bruno
@Brun0L3z
Apr 30 2016 06:02
How can I solve this problem?
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");
Norvin Burrus
@ndburrus
Apr 30 2016 06:04
@Brun0L3z use the variables (myNoun, myAdjective...etc, result) given to construct/build the desired output. :)
Boyce
@Yijianc
Apr 30 2016 06:04
help Smallest Common Multiple
CamperBot
@camperbot
Apr 30 2016 06:04

:point_right: algorithm smallest common multiple [wiki]

Explanation:

The smallest common multiple between two numbers is the smallest number that
both numbers can divide into. This concept can be extended to more than two
numbers as well.

We can first start with just finding the smallest common multiple between two
numbers. Naively, you can start writing out multiple of each number until you
write a multiple that exists from both numbers.

An example would be the numbers 3 and 4. The multiples of 3 are 3, 6, 9, 12, 15, 18, ... and the multiples of 4 are 4, 8, 12, 16, 20, .... The
first smallest number we run into in both lists is 12 so this is the smallest
common multiple between 3 and 4.

This problem can be confusing because most people look for the smallest common
multiple of just the two numbers but forget the keyword range. However, this
means that if you are given [1,5], then you have to check for the smallest
common multiple for all the numbers [1,2,3,4,5] that is evenly divisible by
all of them.

:pencil: read more about algorithm smallest common multiple on the FCC Wiki

need help debugging one big issue
im not sure what exactly causing it
for example you can try 5+6 , you will get 11
and add -3 and you get 8 , all good
and than you try *5 or something
and you get something crazy
plotterbaboom
@plotterbaboom
Apr 30 2016 06:07
You have to use parentheses to separate your equation(5+6-3)*5
Norvin Burrus
@ndburrus
Apr 30 2016 06:08
@Brun0L3z also take a llok at the compose & chat buttons to the right of your text box. you will find those useful also, for posting code...
@Brun0L3z look*
Zuo Bruno
@Brun0L3z
Apr 30 2016 06:10
ok
bvb437
@bvb437
Apr 30 2016 06:11
hello
what can i do to improve this code

function reverseString(str) {
var array = str.split("");
return array.reverse().join("");
}

reverseString("hello");

Eldar Tinjić
@EldarT90
Apr 30 2016 06:11
@plotterbaboom but where should i put them without messing everything up
bvb437
@bvb437
Apr 30 2016 06:11
or it is okay? :)
it works, but i want to know if there is a better solution
Zuo Bruno
@Brun0L3z
Apr 30 2016 06:11
so if I understand well i have to create variables (or better still assign strings to variables) myNoun, myAdjective, myVerb, myAdverb right @ndburrus
Norvin Burrus
@ndburrus
Apr 30 2016 06:12
@Brun0L3z help code formatting
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:12
Capture.PNG
Norvin Burrus
@ndburrus
Apr 30 2016 06:13
help code formatting
CamperBot
@camperbot
Apr 30 2016 06:13

: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 the code.

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

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

Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:13
@ndburrus okay i found the way to delete punctuation and lowercase
but i dont know whats wrong with my loop
Norvin Burrus
@ndburrus
Apr 30 2016 06:13
@nctl144 ok...
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:13
i did check and those two arrays should be correct
Norvin Burrus
@ndburrus
Apr 30 2016 06:15
@Brun0L3z the variables have been created already. these are the ones mentioned in the challenge. you just need to arrange/assign them to produce the desired string output.
@nctl144 can u post your code? brb
Zuo Bruno
@Brun0L3z
Apr 30 2016 06:16
@ndburrus Please what should I write here, this particular challenge is confusing. Please!!!
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:16
Capture.PNG
@ndburrus thats my code for now
Rex Smith Jr.
@rsmith731
Apr 30 2016 06:17
hey can someone tell me how to get “script execution” to stop running every time i refresh my page
Norvin Burrus
@ndburrus
Apr 30 2016 06:17
@Brun0L3z
js
<  result = 'The ';
  result = result + myAdjective;
  result = result + ' ';
  result = result + myNoun;
  result = result + ' ';
  result = result + myVerb;
  result = result + ' ';
  result = result + myAdverb;
  result = result + '.';>
@nctl144 ...did you attend to the incomplete if statement?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:19
but what should i fill in the "else"
Zuo Bruno
@Brun0L3z
Apr 30 2016 06:19
Thanks @ndburrus
CamperBot
@camperbot
Apr 30 2016 06:19
brun0l3z sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 285 | @ndburrus | http://www.freecodecamp.com/ndburrus
Zuo Bruno
@Brun0L3z
Apr 30 2016 06:20
I will now go through the code and try to understand why I got confuse:
Norvin Burrus
@ndburrus
Apr 30 2016 06:20
@Brun0L3z ...taking a look at the code, does it make sense?
@Brun0L3z ok :+1:
@nctl144 ...here is an alternative statement to remove non-alphanumeric characters
@nctl144 str.replace(/[^0-9a-z]/gi, '')
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:23
thanks @ndburrus
CamperBot
@camperbot
Apr 30 2016 06:23
nctl144 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 286 | @ndburrus | http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Apr 30 2016 06:23
@nctl144 ...hmm... did the tests pass?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:23
not yet
even if i put else with the return true statement
it still does not pass
Norvin Burrus
@ndburrus
Apr 30 2016 06:24
@nctl144 ok... i think i may have been wrong on the needed else statement....
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:24
yeah thats where i am stuck now
Norvin Burrus
@ndburrus
Apr 30 2016 06:24
@nct im working on this one also....
@nct brb....
Eldar Tinjić
@EldarT90
Apr 30 2016 06:25
can some1 check my while loop
Norvin Burrus
@ndburrus
Apr 30 2016 06:26
@nctl144 oh, have you considered the comparison in lowercase?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:26
i did transform everything to lowercase
Ayooluwa
@ayoisaiah
Apr 30 2016 06:26
Hi guys, I'm working through the intermediate algorithms. This is my current challenge --https://www.freecodecamp.com/challenges/finders-keepers
Norvin Burrus
@ndburrus
Apr 30 2016 06:26
@EldarT90 which challenge please?
Ayooluwa
@ayoisaiah
Apr 30 2016 06:26
This message was deleted
Eldar Tinjić
@EldarT90
Apr 30 2016 06:27
@ndburrus tic-tac-toe https://codepen.io/EldarT/pen/bpmwYV
Norvin Burrus
@ndburrus
Apr 30 2016 06:27
@EldarT90 ok, im not there yet...
Eldar Tinjić
@EldarT90
Apr 30 2016 06:27
@ndburrus oke
Ayooluwa
@ayoisaiah
Apr 30 2016 06:28
         function findElement(arr, func) {

             for (var i = 0; i < arr.length; i++) {
                 var num = arr[i];
                 if (func(num) === true) {
                     return num;
                 } 

                 else {
                     return undefined;
                 }
             }
        }

        findElement([1, 3, 5, 8, 9, 10], function(num){ return num % 2 === 0; });
Can anyone tell me why my solution does not work for this challenge --> https://www.freecodecamp.com/challenges/finders-keepers
Norvin Burrus
@ndburrus
Apr 30 2016 06:29
@nctl144 your right, i overlooked it... brb
@nctl144 how many tests do not pass?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:30
what do you mean
Eldar Tinjić
@EldarT90
Apr 30 2016 06:31
@ayoisaiah you should use filter for this challenge which is 2 lines of code
Norvin Burrus
@ndburrus
Apr 30 2016 06:31
@nctl144 how many red x's are there?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:31
im not sure..
Ayooluwa
@ayoisaiah
Apr 30 2016 06:34
@EldarT90 Alright, let me look at that. But I'm confused as to why this solution doesn't work
Eldar Tinjić
@EldarT90
Apr 30 2016 06:35
@ayoisaiah it will check only first number and return undefined
if its not the right one
Ayooluwa
@ayoisaiah
Apr 30 2016 06:38
Oh shit! Haha can't believe I didn't see that @EldarT90. I've gotten it to work using filter. Thanks
CamperBot
@camperbot
Apr 30 2016 06:38
ayoisaiah sends brownie points to @eldart90 :sparkles: :thumbsup: :sparkles:
:star: 328 | @eldart90 | http://www.freecodecamp.com/eldart90
Eldar Tinjić
@EldarT90
Apr 30 2016 06:39
@ayoisaiah np mate
Norvin Burrus
@ndburrus
Apr 30 2016 06:48
@nctl144 r u still there?
Taras Yaremkiv
@Y-Taras
Apr 30 2016 06:48
Hello everyone. Who knows regex? I'm trying to capture using regex two groups. One is Uppercase symbols, and another is space symbol, But something is wrong in my statement
/([A-Z]+)(\s)/g
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:48
yeah i am
Norvin Burrus
@ndburrus
Apr 30 2016 06:50
@nctl144 scroll down on the left side & see how many tests do not pass...
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:50
my function just return true
Norvin Burrus
@ndburrus
Apr 30 2016 06:50
@nctl144 ...under Run Tests, Reset, code window...
@nctl144 so it passed?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 06:51
which means all the tests which are supposed to return true are passed
but the tests which are supposed to return false are not passed
Norvin Burrus
@ndburrus
Apr 30 2016 06:52
@nctl144 ok...
Ali Hammad
@alihammad-gist
Apr 30 2016 06:52
@Y-Taras I think you have capture them separately using two separate regexp.
Taras Yaremkiv
@Y-Taras
Apr 30 2016 06:54
@alihammad-gist I need two groups, so that I could replace one group and then another using function
Aparna
@Aparna-S
Apr 30 2016 06:54
i am doing this "Golf"

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

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

Mujaahid
@mujaahid
Apr 30 2016 06:55

``function submitAnswers(){
var total = 5;
var score = 0;

var q1= document.forms["quizform"]["q1"].value;
var q2= document.forms["quizform"]["q2"].value;
var q3= document.forms["quizform"]["q3"].value;
var q4= document.forms["quizform"]["q4"].value;
var q5= document.forms["quizform"]["q5"].value;
var questions = ['q1','q2','q3','q4','q5'];
console.log(questions);

for(var i = 1; i <= total; i++){
    if (eval('q'+i)=== null || eval('q'+i) ===''){
        alert("You missed question"+ i);
        return false;
    }
}
var answers= ['b','a', 'd','b','d'];

for(var i =1; i<= total;i++){
    if(eval('q'+i)==answers[i - 1]){
        score++;
    }
}var results = document.GetElement.id('results');
results.innerHtml = "<h3> you";
alert ("you scored" +score+"out of" +total); 

}

`

```

The code above isn't working
Aparna
@Aparna-S
Apr 30 2016 06:56
can anyone help me where i went wrong?
Norvin Burrus
@ndburrus
Apr 30 2016 06:57
@Aparna-S in the if/else if statements - comparisons are needed between strokes & par...
@Aparna-S there are commas in those statements now - with values on both sides...
@Aparna-S review the logic there....
Piyush Sharma
@piyushon2411
Apr 30 2016 06:59
This program always returns true, I am not able to debug since console log is not printing anything. What am I doing wrong here? Please help.
function palindrome(str) {
 // Testing first only for spaces, punctuations later 
 // Remove all whitespaces
 str = str.replace(/\s/g,"");
 console.log("str:"+str); 
 // Convert all letters to lowercase 
 str.toLowerCase();
 console.log("str:"+str); 
 // Split all the letters into an array 
 var arr = str.split("");
 console.log("arr:"+arr); 
 // Reverse and put it into new array 
 var newArray = arr.reverse();
 console.log("newArray:"+newArray);
 // Iterate and compare both arrays  
 for(var i=0;i<arr.length;i++){
    // if the letters don't match at any position, return false 
    if(arr[i]!==newArray[i]){
      return false;
    }
 }
 // return true if a palindrome 
 return true;
}
palindrome("eye is Black");
cannelflow
@cannelflow
Apr 30 2016 07:00
@piyushon2411 use https://repl.it/
Piyush Sharma
@piyushon2411
Apr 30 2016 07:00
ok Thanks @cannelflow
CamperBot
@camperbot
Apr 30 2016 07:00
piyushon2411 sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 1117 | @cannelflow | http://www.freecodecamp.com/cannelflow
Ali Hammad
@alihammad-gist
Apr 30 2016 07:01
@Y-Taras I am not entirely sure what you are trying to do. Here is an example of replacing every Uppercase letter in a string with _. 'abc DaB'.replace(/[A-Z]/g, function (r) { return '_' }
cannelflow
@cannelflow
Apr 30 2016 07:01
https://repl.it/CL7X @piyushon2411
Aparna
@Aparna-S
Apr 30 2016 07:01
@ndburrus i tried using && operator, it doesnt work either , what operator to use here??
cannelflow
@cannelflow
Apr 30 2016 07:02
@piyushon2411 you can always start by making everything lowercase
Norvin Burrus
@ndburrus
Apr 30 2016 07:03
@Aparna-S hint: you are comparing strokes to return (par) values....
@Aparna-S ...just like the chart illustrates...
Aparna
@Aparna-S
Apr 30 2016 07:07
@ndburrus like this - if (strokes>=par + 3) {
return "Go Home!";
} ?
Piyush Sharma
@piyushon2411
Apr 30 2016 07:07
@cannelflow Ok, was wondering what is the reason behind this convention?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 07:09
@piyushon2411 have you passed that ?
im stuck with it
Norvin Burrus
@ndburrus
Apr 30 2016 07:09
@Aparna-S ...now the fire is starting... :fire:
Piyush Sharma
@piyushon2411
Apr 30 2016 07:10
YEah @nctl144
What's the issue?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 07:10
Capture.PNG
Norvin Burrus
@ndburrus
Apr 30 2016 07:10
@Aparna-S use the chart as a guide....
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 07:10
heres my code right now
@piyushon2411 it always return true
cannelflow
@cannelflow
Apr 30 2016 07:11
@nctl144 can you paste your code
wiki format
CamperBot
@camperbot
Apr 30 2016 07:11

: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 the code.

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

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

Piyush Sharma
@piyushon2411
Apr 30 2016 07:11
array.reverse() reverses the contents of array itself without making a copy @nctl144
so while comparing both the array are same
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 07:12

function palindrome(str) {
// Good luck!
str=str.toLowerCase();
var rep=str.replace(/[.,\/#!$%\^&*;:{}=-_`~()]/g,"");

var array=[];
array=rep.split("");
var anotherArray=[];
anotherArray=array.reverse();

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

if (array[i]!==anotherArray[i]){
  return false;
}else{
  return true;
}

}

}

palindrome("L....aadasdas");```js

@piyushon2411 but thats why i made a new array and then compare the new array to the old one
Mujaahid
@mujaahid
Apr 30 2016 07:15
document.forms.quizform

I cant obtain the value of my form and work with them

function submitAnswers(){
    var total = 5;
    var score = 0;

    var q1= document.forms["quizform"]["q1"].value;
    var q2= document.forms["quizform"]["q2"].value;
    var q3= document.forms["quizform"]["q3"].value;
    var q4= document.forms["quizform"]["q4"].value;
    var q5= document.forms["quizform"]["q5"].value;
    console.log(q1+q2+q3+q4+q5);

    for(var i = 1; i <= total; i++){
        if (eval('q'+i)=== null || eval('q'+i) ===''){
            alert("You missed question"+ i);
            return false;
        }
    }
    var answers= ['b','a', 'd','b','d'];

    for(var i =1; i<= total;i++){
        if(eval('q'+i)==answers[i - 1]){
            score++;
        }
    }var results = document.GetElement.id('results');
    results.innerHtml = "<h3> you";
    alert ("you scored" +score+"out of" +total); 
}

pls help

Piyush Sharma
@piyushon2411
Apr 30 2016 07:16
@nctl144 just a minute, sorry for early "Yeah", mine is not passed... would be right back..
Mujaahid
@mujaahid
Apr 30 2016 07:17
here is my html
<!DOCTYPE html>
<html>
<head>
    <title>Learn JavaScript</title>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="css/style.css"> 
</head>
<body>
<div id="container">
    <header>
        <h1>Simple JavaScript Quiz</h1>
        <p>Test you knowlegde in <strong>Javascript fundamentals</strong></p>
    </header>
    <section>
        <div id="results">
            <form method="get" name="quizForm" onsubmit='return submitAnswers()'>
                <h3>1. In which HTML element do we put Javascript code?</h3>
                <input type="radio" name="q1" value="a" id="q1a">a. &lt;js&gt;</br>
                <input type="radio" name="q1" value="b" id="q1a">b. &lt;script&gt;</br>
                <input type="radio" name="q1" value="c" id="q1a">c. &lt;body&gt;</br>
                <input type="radio" name="q1" value="d" id="q1a">d. &lt;link&gt;</br>

                <h3>2. In which HTML element do we put Javascript code?</h3>
                <input type="radio" name="q2" value="a" id="q2a">a. &lt;js&gt;</br>
                <input type="radio" name="q2" value="b" id="q2a">b. &lt;script&gt;</br>
                <input type="radio" name="q2" value="c" id="q2a">c. &lt;body&gt;</br>
                <input type="radio" name="q2" value="d" id="q2a">d. &lt;link&gt;</br>

                <h3>3. In which HTML element do we put Javascript code?</h3>
                <input type="radio" name="q3" value="a" id="q3a">a. &lt;js&gt;</br>
                <input type="radio" name="q3" value="b" id="q3a">b. &lt;script&gt;</br>
                <input type="radio" name="q3" value="c" id="q3a">c. &lt;body&gt;</br>
                <input type="radio" name="q3" value="d" id="q3a">d. &lt;link&gt;</br>

                <h3>4. In which HTML element do we put Javascript code?</h3>
                <input type="radio" name="q4" value="a" id="q4a">a. &lt;js&gt;</br>
                <input type="radio" name="q4" value="b" id="q4b">b. &lt;script&gt;</br>
                <input type="radio" name="q4" value="c" id="q4a">c   . &lt;body&gt;</br>
                <input type="radio" name="q4" value="d" id="q4a">d. &lt;link&gt;</br>

                <h3>5. In which HTML element do we put Javascript code?</h3>
                <input type="radio" name="q5" value="a" id="q5a">a. &lt;js&gt;</br>
                <input type="radio" name="q5" value="b" id="q5ab">b. &lt;script&gt;</br>
                <input type="radio" name="q5" value="c" id="q5a">c   . &lt;body&gt;</br>
                <input type="radio" name="q5" value="d" id="q5a">d. &lt;link&gt;</br>
            <input type="submit" value="submit answer">


            </form>
        </div>
    </section>
    <footer>
         <p>&copy 2016. All right reserved</p>
    </footer>
</div>
</body>
<script src="js/script.js"></script>
</html>
Norvin Burrus
@ndburrus
Apr 30 2016 07:17
@Aparna-S ...how's it going?
Aparna
@Aparna-S
Apr 30 2016 07:19
@ndburrus chart illustrator? .. i tried following the same as the first code i showed above, but throws error for rows like this - else if (strokes= par+2)
oops
it should be == right
Norvin Burrus
@ndburrus
Apr 30 2016 07:20
@Aparna-S yes, use the ==, remember the = is used for assignments
@Aparna-S can you post what you've got so far?
Aparna
@Aparna-S
Apr 30 2016 07:21
@ndburrus hmm right! ,, and for else if (1) ?

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

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

Norvin Burrus
@ndburrus
Apr 30 2016 07:22
@Aparna-S hmmm... else if (1)? what about 1? what does that mean?
Aparna
@Aparna-S
Apr 30 2016 07:23
@ndburrus is it strokes and par are =1?
Norvin Burrus
@ndburrus
Apr 30 2016 07:25
@Aparna-S what does the chart say? also, what does the following code do?
js
<else
return "Change Me";>
@Aparna-S hint: look at the column heading...
Aparna
@Aparna-S
Apr 30 2016 07:26
chart say 1 returns hole in one , thecode change me is for any conditions other than the ones given in the chart
right?
else if (strokes==1) {
return "Hole-in-one";
}
Norvin Burrus
@ndburrus
Apr 30 2016 07:28
@Aparna-S aaah... ok... now for the change me code. there are no other conditions (outside of the chart) to evaluate...
@Aparna-S are there?
@Aparna-S ...and where is that ! ??
Aparna
@Aparna-S
Apr 30 2016 07:30
is it for strokes ==0?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 07:30
Capture.PNG
Norvin Burrus
@ndburrus
Apr 30 2016 07:30
@Aparna-S said another way - exclamation point
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 07:30
everything is so far so good
i tested so many words and it passed almost all
Norvin Burrus
@ndburrus
Apr 30 2016 07:31
@Aparna-S no, it is for strokes == 1
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 07:31
but the word almostomla it returns "true"
i dont even know why
can anyone help me with that
Aparna
@Aparna-S
Apr 30 2016 07:33
@ndburrus it still cant get how these two codes works :(
Norvin Burrus
@ndburrus
Apr 30 2016 07:33
@Aparna-S if those corrections are made, i think you're all set! :smile:
@Aparna-S
js
<   if (strokes == 1) {
    return "Hole-in-one!";
  } 
  else if (strokes <= par - 2) {
    return "Eagle";
  } 
  else if (strokes == par - 1) {
    return "Birdie";
  }
  else if (strokes == par) {
    return "Par";
  } 
  else if (strokes == par + 1) {
    return "Bogey";
  }
  else if (strokes == par + 2) {
    return "Double Bogey";
  }
  else {
    return "Go Home!";
  } >
Aparna
@Aparna-S
Apr 30 2016 07:35
it should be in ascending order?
Norvin Burrus
@ndburrus
Apr 30 2016 07:35
@Aparna-S i just followed the chart order...
@Aparna-S top to bottom...
Aparna
@Aparna-S
Apr 30 2016 07:36
highest to lowest i thought (strokes>=par + 3) returns greater values than (strokes==1)
Norvin Burrus
@ndburrus
Apr 30 2016 07:36
@Aparna-S as long as the logic is correct, it shouldn't make a difference...
Aparna
@Aparna-S
Apr 30 2016 07:36
wrong?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 07:37
can anyone help me?
Aparna
@Aparna-S
Apr 30 2016 07:38

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

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

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

Norvin Burrus
@ndburrus
Apr 30 2016 07:39
@Aparna-S i dont' understand your point. if the relative par value is higher (as you said), then it won't get dealt with until later in the posted code. but, it will get dealt with properly.
Aparna
@Aparna-S
Apr 30 2016 07:39
still throws error for golfScore(1, 1) should return "Hole-in-one!"
@ndburrus ok so its hould alsways start with smaller values to larger ones..correct?
Norvin Burrus
@ndburrus
Apr 30 2016 07:42
@Aparna-S i don't know if always would be a good rule, it depends on the scenario...
@Aparna-S the logic needs to fit
Tousif Baig
@dev6
Apr 30 2016 07:42
Hello everyone, I need a little help for the Title case a sentence exercise. Just want to know the direction to go with it. Tried with for loop but that was getting really complicated. Any other ideas to solve this problem?
Aparna
@Aparna-S
Apr 30 2016 07:43
@ndburrus oh ok... and my code still not perfect, dono whats the change required for - golfScore(4, 1) should return "Hole-in-one!" & golfScore(1, 1) should return "Hole-in-one!"
@ndburrus an can you tell me what is return "Change Me" is exactly for?
Norvin Burrus
@ndburrus
Apr 30 2016 07:45
@Aparna-S th change me code is unnecessary
@Aparna-S the*
Randy Goldsmith
@Dueldrawer8
Apr 30 2016 07:46
could someone tell me why my code returns NaN?
function sumNums(num){
    var total = 0;
    for(var i = 0; i <= num; i++){
        total+= num[i];
    }
    return total;
}
nvm got it
Aparna
@Aparna-S
Apr 30 2016 07:49
@ndburrus oh ok, thanks :)
CamperBot
@camperbot
Apr 30 2016 07:49
aparna-s sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 287 | @ndburrus | http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Apr 30 2016 07:50
@Aparna-S does it work now?
@Aparna-S you're on fire! :fire:
Aparna
@Aparna-S
Apr 30 2016 07:50
@ndburrus yes i left ! in the hole in one!
@ndburrus thanks to you for helping me out!!
CamperBot
@camperbot
Apr 30 2016 07:50
aparna-s sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: aparna-s already gave ndburrus points
Piyush Sharma
@piyushon2411
Apr 30 2016 07:50
Hey @nctl144 this will help you understand the issue and debug
Norvin Burrus
@ndburrus
Apr 30 2016 07:51
@Aparna-S You're the Best!! :+1:
Piyush Sharma
@piyushon2411
Apr 30 2016 07:52
Try this one ...https://repl.it/CL7X/3 @nctl144
Aparna
@Aparna-S
Apr 30 2016 07:52
@ndburrus haha you too!!
Norvin Burrus
@ndburrus
Apr 30 2016 07:55
ok, bed time... see you later... :sparkles:
ALMY91
@ALMY91
Apr 30 2016 07:58
hi guys
Attempting to read a non-existent property returns undefined, but you can test for the actual existence of a property with the in operator
how does this work? could u guys do up a simple code to show the difference?
i don understand how does the in operator help in this case though. because so long the property is non-existent/deleted,attempting to read them will always return undefined and the in operator will always return false .
Lars Kerick
@Brice187
Apr 30 2016 08:05
hey guys, i am working on importing a json for the quote machine challenge. i want to have a button to import the json: $("#getMessage").on("click", function(){
$.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(a) {
$(".message").html(JSON.stringify(a));
});
what am i doing wrong? ;)
Jackson Bates
@JacksonBates
Apr 30 2016 08:13
@Brice187 What error are you getting, or what seems to not be working?
Lars Kerick
@Brice187
Apr 30 2016 08:16
i get no error, but also no data :(
Ankur sharma
@ankur1163
Apr 30 2016 08:18
can someone help me in chunky monkey exercise
here's my code
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var dew =  arr.slice(0,size);
  var newdew = arr.slice(size+1,arr.length-1);
  var deut = dew + newdew;
  return deut;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Jackson Bates
@JacksonBates
Apr 30 2016 08:22
@Brice187 I think your biggest problem is that you haven't loaded jquery into the javascript pane
@Brice187 The console says $ is not defined. However, when I load jq into it, you get a cross origin error, so you'll need to look into that next. I didn't use that API, but cross origin errors are common - you want to find out how to get the JSONP returned, rather than the JSON...
@Brice187 I'm about to have dinner, so hopefully that will give you enough to go on. If you're still stuck when I come back online later, I'll try to help out more :)
Lars Kerick
@Brice187
Apr 30 2016 08:24
thx
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 08:29
can anyone here help me with the palindrome challenge?
Lars Kerick
@Brice187
Apr 30 2016 08:30
@nctl144 did you get stuck on the last test? :)
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 08:30
the almostomla
i dont even know why it doesnt pass
it works with almost every word
except for the almostomla
Capture.PNG
i cant sleep because of that
ALMY91
@ALMY91
Apr 30 2016 08:37
hellooo
is anybody able to help me out here....
Attempting to read a non-existent property returns undefined, but you can test for the actual existence of a property with the in operator
UtkarshShukla7
@UtkarshShukla7
Apr 30 2016 08:40
@nctl144 you are returning just after comparing first characters
you should return outside loop
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 08:41
oh yeah i didnt think about that
thanks
UtkarshShukla7
@UtkarshShukla7
Apr 30 2016 08:41
@nctl144 np
Javier
@sh1g
Apr 30 2016 08:47
whoops accidently created an infinite loop on codepen.. DX
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 08:47
@UtkarshShukla7 i dont even know how to return outside the loop...
UtkarshShukla7
@UtkarshShukla7
Apr 30 2016 08:49
@nctl144
function palindrome(str) {
// Good luck!
str=str.toLowerCase();
var rep=str.replace(/[.,\/#!$%\^&*;:{}=-_`~()]/g,"");
var array=[];
array=rep.split("");
var anotherArray=[];
anotherArray=array.reverse();var check=true;
for(var i=0;i<array.length; i++){console.log(array[i],anotherArray[i]);
if (array[i]!==anotherArray[i]){
  check= false;
}else{
  check= true;
}
}return check;
}
palindrome("almostala");
Brendan Kinahan
@BKinahan
Apr 30 2016 08:50
@ALMY91 you mean hasOwnProperty()?
Chau Tung Lam Nguyen
@nctl144
Apr 30 2016 08:51
okay thanks @UtkarshShukla7
CamperBot
@camperbot
Apr 30 2016 08:51
nctl144 sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:star: 409 | @utkarshshukla7 | http://www.freecodecamp.com/utkarshshukla7
UtkarshShukla7
@UtkarshShukla7
Apr 30 2016 08:52
@nctl144 np
Javier
@sh1g
Apr 30 2016 08:53
can anyone help me with some RegExp
function translatePigLatin(str) {
  if (str.match(/([b-z]?[^aeiou])/gi)) {
    return true;  
  } else {
    return false;
  }

}

translatePigLatin("a");
now I just want to sleect the first character
Brendan Kinahan
@BKinahan
Apr 30 2016 08:56
@sh1g the regex for the start of a string is ^, so something like /^[aeiou]/ will check if the string starts with a vowel
@sh1g remember that you need to check more that the first character, ie ghost changes to ostghay and not hostgay
Javier
@sh1g
Apr 30 2016 08:57
@BKinahan that's right...hmm this is what I get for trying to use regex at 2:00am. my head hurts
Javier
@sh1g
Apr 30 2016 09:13
@BKinahan figured it out. Thanks! used regex101. Such a great tool xD
CamperBot
@camperbot
Apr 30 2016 09:13
sh1g sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1408 | @bkinahan | http://www.freecodecamp.com/bkinahan
Jackson Bates
@JacksonBates
Apr 30 2016 09:13
@Brice187 actually, when I load jquery into the JavaScript window on my mobile it works without a cross origin error, which is weird. But it seems like the cross origin error isn't a problem. If you look at their API docs they mention cross origin workarounds and you code is similar to theirs. Do you realise you have repeated your Css and JS in the html window? You don't need it in both places
Brendan Kinahan
@BKinahan
Apr 30 2016 09:14
@sh1g great :smile:
Coryphaeus
@cvdeby
Apr 30 2016 09:15
@sh1g If you wanna get only first character try this /^./g
Kartik Shah
@krtk6160
Apr 30 2016 09:32
Hey guys, I'm on the stand in line part of the basic JS. Can anyone tell me what's wrong with my function?
'''
function nextInLine(arr, item) {
// Your code here
arr.push(item);
x = arr.unshift();
return x ; // Change this line
}
'''
CamperBot
@camperbot
Apr 30 2016 09:32
:bulb: to format code use backticks! ``` more info
Javier
@sh1g
Apr 30 2016 09:32
@cvdeby this was my regex in the end /^.*?(?=[aeiou])/i
Stephen James
@sjames1958gm
Apr 30 2016 09:35
@krtk6160 Unshift puts an element onto the front of the array
Kartik Shah
@krtk6160
Apr 30 2016 09:36
@sjames1958gm Man, that was really stupid of me. Thank you.
CamperBot
@camperbot
Apr 30 2016 09:36
krtk6160 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 851 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 30 2016 09:36
@krtk6160 :+1:
@krtk6160 You can directly return the result of shift - don't need x -> return arr.shift();
Kartik Shah
@krtk6160
Apr 30 2016 09:37
@sjames1958gm Yep, I realized that later. :)
fjurcev
@fjurcev
Apr 30 2016 09:39
Hi, anyone knows how to show data in html from external json file?
kirbyedy
@kirbyedy
Apr 30 2016 09:40
@fjurcev did you try this: http://api.jquery.com/jquery.getjson/
fjurcev
@fjurcev
Apr 30 2016 09:47
@kirbyedy yea, but actually not solved my proble, thank you
CamperBot
@camperbot
Apr 30 2016 09:47
fjurcev sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 935 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
Stephen James
@sjames1958gm
Apr 30 2016 09:48
@fjurcev Are you asking how to get the data out of the json once you have loaded the external file?
kirbyedy
@kirbyedy
Apr 30 2016 09:48
@fjurcev you have to be more specific then :)
fjurcev
@fjurcev
Apr 30 2016 09:52
I didn't work a lot with this before, I have external link with json rest service, and I need to show it in table, html
hope you understand me :)
Stephen James
@sjames1958gm
Apr 30 2016 10:06
@fjurcev Your question is too broad. Do you know how to get the data from the rest service are you now looking at how to put into table?
Chiara
@chiara-f
Apr 30 2016 10:07
hello everyone! could anyone please take a look at my arguments optional algorithm?
Stephen James
@sjames1958gm
Apr 30 2016 10:07
@chiara-f Sure
Chiara
@chiara-f
Apr 30 2016 10:07
function addTogether() {
  for (var i = 0; i < arguments.length; i++) {
    if (isNaN(arguments[i])) {
      return undefined;
    }
  }
  if (arguments.length === 2) {
    return arguments[0] + arguments[1];
  } else {
    return function(num) {
      return arguments[0] + num;
    };
  }
}

addTogether(2)(3);
Stephen James
@sjames1958gm
Apr 30 2016 10:08
@chiara-f The arguments inside of the function you are returning is not the same as the arguments passed into addTogether - you have to assign to a local var.
addTogether(2)(3) is I am guessing returning 6 not 5
Chiara
@chiara-f
Apr 30 2016 10:09
@sjames1958gm it did, but with your correction now it runs correctly
Stephen James
@sjames1958gm
Apr 30 2016 10:10
:+1:
Chiara
@chiara-f
Apr 30 2016 10:11
function addTogether() {
  for (var i = 0; i < arguments.length; i++) {
    if (isNaN(arguments[i])) {
      return undefined;
    }
  }
  var first = arguments[0];
  if (arguments.length === 2) {
    return arguments[0] + arguments[1];
  } else {
    return function(num) {
      return first + num;
    };
  }
}

addTogether(2, "3"); //returns 23
addTogether(2)([3]); //returns 23
and these last two cases should return undefined
Stephen James
@sjames1958gm
Apr 30 2016 10:11
@chiara-f You are supposed to check that num is a number in your passed back function.
Chiara
@chiara-f
Apr 30 2016 10:12
@sjames1958gm shouldn't isNaN do that? (first if)
Stephen James
@sjames1958gm
Apr 30 2016 10:13
@chiara-f Actually isNaN is testing if the parameter is a number, but in this case "3" and [3] are never passed to addTogether so that code never sees it.
Diego Mayer
@Chrono79
Apr 30 2016 10:13
@chiara-f no, NaN converts string to see if it's a valid number
Chiara
@chiara-f
Apr 30 2016 10:14
@sjames1958gm @Chrono79 aha. would it better to use typeof?
Stephen James
@sjames1958gm
Apr 30 2016 10:14
@chiara-f You need a check inside of the returned function when it is called outside of addTogether.
Diego Mayer
@Chrono79
Apr 30 2016 10:14
@chiara-f yes, and as @sjames1958gm said, check again there too
Chiara
@chiara-f
Apr 30 2016 10:15
almost!
function addTogether() {
  for (var i = 0; i < arguments.length; i++) {
    if (typeof arguments[i] !== 'number') {
      return undefined;
    }
  }
  var first = arguments[0];
  if (arguments.length === 2) {
    return arguments[0] + arguments[1];
  } else {
    return function(num) {
      return first + num;
    };
  }
}

addTogether(2)([3]); // still returns 23
Stephen James
@sjames1958gm
Apr 30 2016 10:17
@chiara-f You still need a check inside the passed back function.
@chiara-f [3] is not passed to addTogether so your check doesn't see it.
Chiara
@chiara-f
Apr 30 2016 10:19
@sjames1958gm i'm afraid you lost me. how come it doesn't see addTogether(2)([3]) but it works fine for addTogether(2)(3)?
Stephen James
@sjames1958gm
Apr 30 2016 10:21
@chiara-f addTogether(2) returns -> function (num) { 2 + num; } then that is called with num of 3 or [3] there is no check to see if num is a number
Diego Mayer
@Chrono79
Apr 30 2016 10:22
@chiara-f this is the case it sees: addTogether(2, "3") the others not
Chiara
@chiara-f
Apr 30 2016 10:22
@sjames1958gm now i got it!
@Chrono79 @sjames1958gm thank you all for your help!
CamperBot
@camperbot
Apr 30 2016 10:23
chiara-f sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 569 | @chrono79 | http://www.freecodecamp.com/chrono79
:star: 856 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Chiara
@chiara-f
Apr 30 2016 10:23
```js
function addTogether() {
  for (var i = 0; i < arguments.length; i++) {
    if (typeof arguments[i] !== 'number') {
      return undefined;
    }
  }
  var first = arguments[0];
  if (arguments.length === 2) {
    return arguments[0] + arguments[1];
  } else {
    return function(num) {
      if (typeof arguments[0] !== 'number') {
      return undefined;
    }
      return first + num;
    };
  }
}

addTogether(2)([3]);
@sjames1958gm @Chrono79 now that you explained to me, i'm like "why was it so difficult?!"
thanks again :)
Stephen James
@sjames1958gm
Apr 30 2016 10:25
@chiara-f New concepts of returning functions and closure.
Chiara
@chiara-f
Apr 30 2016 10:27
@sjames1958gm i studied the links provided and also read further explanations, but i guess until one puts it into practice, all the theory in the world won't help
Stephen James
@sjames1958gm
Apr 30 2016 10:27
@chiara-f In theory you learn more from practice than theory :)
Chiara
@chiara-f
Apr 30 2016 10:28
@sjames1958gm aha! good pun! you're absolutely right! :smiley:
Ankur sharma
@ankur1163
Apr 30 2016 10:29
i am doing falsy bouncer
why this code is not correct and returning object object
function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  var myFilterArray = arr.filter(Boolean);
  return myFilterArray;
}

bouncer([7, "ate", "", false, 9]);
Anas R. Firdousi
@afirdousi
Apr 30 2016 10:31

Iterators, For Of Loop, Custom Iterators, Generators and a taste of Functional JavaScript in -ECMA2015 (ES6)

  • My latest post is now out:

http://anasfirdousi.com/es6-iterators-forof-custom-iterators-generators-next-in-es2015-es6.html

Stephen James
@sjames1958gm
Apr 30 2016 10:31
@ankur1163 It worked fine in chrome console.
Diego Mayer
@Chrono79
Apr 30 2016 10:32
@ankur1163 Boolean is an object too, you have to define a function and use Boolean()
Chiara
@chiara-f
Apr 30 2016 10:33
@ankur1163 this is strange, because it works fine even in the FCC console (i just tried)
Ankur sharma
@ankur1163
Apr 30 2016 10:35
seems like I have weird browser
the icon is chrome but in blue color
let me check it in normal chrome browser
yeah it worked
thanks @sjames1958gm
CamperBot
@camperbot
Apr 30 2016 10:36
ankur1163 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 857 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Ankur sharma
@ankur1163
Apr 30 2016 10:36
thanks @Chrono79
CamperBot
@camperbot
Apr 30 2016 10:36
ankur1163 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 570 | @chrono79 | http://www.freecodecamp.com/chrono79
Ankur sharma
@ankur1163
Apr 30 2016 10:36
thanks @chiara-f
CamperBot
@camperbot
Apr 30 2016 10:36
ankur1163 sends brownie points to @chiara-f :sparkles: :thumbsup: :sparkles:
:star: 346 | @chiara-f | http://www.freecodecamp.com/chiara-f
Stephen James
@sjames1958gm
Apr 30 2016 10:36
That sounds like chromium
@ankur1163 Open source version of chrome
Ankur sharma
@ankur1163
Apr 30 2016 10:38
yes, you are right
i checked now and it says "about chromium " in settings section
Suyash Mittal
@suyash01
Apr 30 2016 10:40
Hi new here
Chiara
@chiara-f
Apr 30 2016 10:41
@suyash01 welcome
Stephen James
@sjames1958gm
Apr 30 2016 10:42
@suyash01 Hey
Suyash Mittal
@suyash01
Apr 30 2016 10:43
Thanks @chiara-f @sjames1958gm
CamperBot
@camperbot
Apr 30 2016 10:43
suyash01 sends brownie points to @chiara-f and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 347 | @chiara-f | http://www.freecodecamp.com/chiara-f
:star: 858 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Boyce
@Yijianc
Apr 30 2016 10:46
help Drop it
CamperBot
@camperbot
Apr 30 2016 10:46

:point_right: algorithm drop it [wiki]

Explanation:

Basically while the second argument is not true, you will have to remove the first element from the left of the array that was passed as the first argument.

:pencil: read more about algorithm drop it on the FCC Wiki

Vivek
@vivek28111992
Apr 30 2016 10:48
@suyash01 Welcome to FCC
Stephen James
@sjames1958gm
Apr 30 2016 10:48
@Yijianc Need help?
Javier
@sh1g
Apr 30 2016 10:49
thanks for all the help. I should probably get some sleep or I won't function in 4 hours...
Boyce
@Yijianc
Apr 30 2016 10:50
@sjames1958gm camperbot already tells me how to do it. But, still, thanks.
CamperBot
@camperbot
Apr 30 2016 10:50
yijianc sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 859 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Ankur sharma
@ankur1163
Apr 30 2016 11:00
is there some other way to learn json api and ajax?
free code camp lessons looks little confusion
confusing
Adam El-Naggar
@adamelnaggar
Apr 30 2016 11:05

Hey, so I've created this little meditation timer web app and it works as it should on desktop browsers. It's responsive and works on mobile also, however when the timer starts and finishes it's supposed to play html5 audio. This won't work on mobile, I've tested it on iOS Safari/Chrome and Chrome for Android.

I have the audio set to play with setTimeout functions after the click to begin the timer. Is there anyway I can get something like this to work and play on mobile? I'm struggling to find any solution that will work.

Here is the app: http://automatecutback.co.uk/breathe/

kirbyedy
@kirbyedy
Apr 30 2016 11:07
@ankur1163 well there is the official documentation, and also there are tutorials on youtube
hjernefrys
@hjernefrys
Apr 30 2016 11:07

Hi, I need some help with the weather app challenge, can someone take a look at my pen and help me with getting the requests correct?

https://codepen.io/icenburg/pen/JXmpPw/

kirbyedy
@kirbyedy
Apr 30 2016 11:08
@hjernefrys you might want to use getJSON instead of xml
Stephen James
@sjames1958gm
Apr 30 2016 11:09
@hjernefrys Your sucess function for getting the position shouldn't return anything. you need to invoke your get weather from inside the success function of get position.
Boyce
@Yijianc
Apr 30 2016 11:10
help Steamroller
CamperBot
@camperbot
Apr 30 2016 11:10

:point_right: algorithm steamroller [wiki]

Explanation:

This problem seems simple but you need to make sure to flatten any array, regardless of the level which is what adds a bit of difficulty to the problem.

:pencil: read more about algorithm steamroller on the FCC Wiki

hjernefrys
@hjernefrys
Apr 30 2016 11:12
ok thanks @kirbyedy and @sjames1958gm I think that will help me a bit moving forwards. I'm also wondering if I need to shorten the number of decimals on the lat, long response and how I would do that accurately
CamperBot
@camperbot
Apr 30 2016 11:12
hjernefrys sends brownie points to @kirbyedy and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 860 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
:star: 936 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
kirbyedy
@kirbyedy
Apr 30 2016 11:14
@hjernefrys I dont think so, the more decimal the more accurate is the location
I think...
hjernefrys
@hjernefrys
Apr 30 2016 11:16
super @sjames1958gm . @kirbyedy yes, it's more accurate, but I think some API's have a limit to e.g 6 decimals
z5014823
@z5014823
Apr 30 2016 11:19
drop it.png
i don't understand why this is wrong?
Stephen James
@sjames1958gm
Apr 30 2016 11:21
@z5014823 How is it failing?
z5014823
@z5014823
Apr 30 2016 11:21
drop it.png
at the bottom, the condition is n>2, however the element 2 is included in the array answer
nevermind
Stephen James
@sjames1958gm
Apr 30 2016 11:24
@sjames1958gm Maybe you need indexOf(true) not lastIndexOf(false) the requirements say nothing about the elements past the first true value
z5014823
@z5014823
Apr 30 2016 11:24
the condition is applied only to the first element
not the whoel array
@sjames1958gm yup
Theodore P.
@Ierofantis
Apr 30 2016 11:25
can anyone help me and review my simon says code and guide me?I am stuck
Stephen James
@sjames1958gm
Apr 30 2016 11:26
@z5014823 Also you don't need sliceEnd as the default for second parameter is arr.length, also you don't need the check for sliceStart > sliceEnd if sliceStart is past end of array it returns []
z5014823
@z5014823
Apr 30 2016 11:35
drop it.png
@sjames1958gm great info, removed the sliceEnd parameter and the code worked. however when sliceStart>sliceEnd it doesnt seem to return []
@sjames1958gm sorry, i'm getting the q wrong for another reason. thanks for your hlep!
CamperBot
@camperbot
Apr 30 2016 11:37
z5014823 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 861 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
ALMY91
@ALMY91
Apr 30 2016 11:49
<html>
<head></head>
<body>

<script type="text/javascript">

var o ={x:1,y:2};
delete o.x; 


</script>
</body>
</html>
why doesn my console return true?
Eldar Tinjić
@EldarT90
Apr 30 2016 11:49

   b = Math.round(Math.random()*9);
      while (newArr.indexOf(b) !== -1) {
      b = Math.round(Math.random()*9);
  }
would this influence b outside of while ?
ALMY91
@ALMY91
Apr 30 2016 11:50
the book states that delete returns true if it successfully deletes the specified lvalue
Shivam Arora
@shivamarora13
Apr 30 2016 11:50
@EldarT90 b is a global variable?
Eldar Tinjić
@EldarT90
Apr 30 2016 11:51
@shivamarora13 yes
Mateusz Szymański
@matszym
Apr 30 2016 11:52
@ALMY91 use console.log()
Shivam Arora
@shivamarora13
Apr 30 2016 11:52
@EldarT90 If while will get true at any point, b will be influenced
Mateusz Szymański
@matszym
Apr 30 2016 11:52
@ALMY91 it returned tru but you didnt do anything with it
Eldar Tinjić
@EldarT90
Apr 30 2016 11:52
@shivamarora13 but it looks like it doesnt thats the thing
ALMY91
@ALMY91
Apr 30 2016 11:52
@matszym thanks
CamperBot
@camperbot
Apr 30 2016 11:52
almy91 sends brownie points to @matszym :sparkles: :thumbsup: :sparkles:
:star: 24 | @matszym | http://www.freecodecamp.com/matszym
Shivam Arora
@shivamarora13
Apr 30 2016 11:53
@EldarT90 :|
send entire code
what im trying to do is making every field of tic tac toe like different array element
and if that element has already been part of an array (which is empty at start), than do math random again
until you get one which is not inside
but it doesnt do it
Shivam Arora
@shivamarora13
Apr 30 2016 11:56
@EldarT90 I cannot really understand your problem.
Eldar Tinjić
@EldarT90
Apr 30 2016 11:57
@shivamarora13 when i click for example field 1; another field should be opened randomly
but it cant open the same field
and by open i mean change html to O or X
Shivam Arora
@shivamarora13
Apr 30 2016 11:58
@EldarT90 Ok Ok, lemme see.
z5014823
@z5014823
Apr 30 2016 11:59
hello, why is the exclamation mark required in this code?
blob
Shivam Arora
@shivamarora13
Apr 30 2016 12:00
@z5014823 it makes the element to be pushed into the newArray
if it is not array
! means not.
!true = false
!false = true
Eldar Tinjić
@EldarT90
Apr 30 2016 12:00
@z5014823 nice music choice
trance all the way
Shivam Arora
@shivamarora13
Apr 30 2016 12:01
@shivamarora13 bro, i have used console.log() on ur field click function, I think the values being pushed are wrong..
or are not getting properly, that's why it cannot check, and that function doesn't work
Eldar Tinjić
@EldarT90
Apr 30 2016 12:01
@shivamarora13 hmm tnx for that, let me see
CamperBot
@camperbot
Apr 30 2016 12:01
eldart90 sends brownie points to @shivamarora13 :sparkles: :thumbsup: :sparkles:
:star: 302 | @shivamarora13 | http://www.freecodecamp.com/shivamarora13
Shivam Arora
@shivamarora13
Apr 30 2016 12:02
@EldarT90 though I am not sure.
z5014823
@z5014823
Apr 30 2016 12:02
@shivamarora13 @EldarT90 thanks
CamperBot
@camperbot
Apr 30 2016 12:02
z5014823 sends brownie points to @shivamarora13 and @eldart90 :sparkles: :thumbsup: :sparkles:
:star: 303 | @shivamarora13 | http://www.freecodecamp.com/shivamarora13
:star: 329 | @eldart90 | http://www.freecodecamp.com/eldart90
Eldar Tinjić
@EldarT90
Apr 30 2016 12:03
@shivamarora13 they are pushed properly in my console log
felisnox
@felisnox
Apr 30 2016 12:06
Hey guys, trying to use jQuery's scrollTop and it is returning 0 no matter the position of my scroll bar, not sure if pasting code directly into this chat will work or should i make a codepen?
$(document).ready(function() {
$("html, body").scroll(function() {
var height = $(window).scrollTop();
console.log(height);
That's all the code is
height will always be 0
Mateusz Szymański
@matszym
Apr 30 2016 12:17
@felisnox Is element window scrollable?
felisnox
@felisnox
Apr 30 2016 12:19
yeah it is scrollable, as i scroll down the page it's just returning 0 on each scroll
felisnox
@felisnox
Apr 30 2016 12:24
huh, just fixed it, apparently having the html element set to 100% height made this occur
must have null'd it
Shivam Arora
@shivamarora13
Apr 30 2016 12:26
@EldarT90 I might be wrong somewhere, sorry bro.
Eldar Tinjić
@EldarT90
Apr 30 2016 12:27
@shivamarora13 np mate
Chris Cullen
@123xylem
Apr 30 2016 12:31
help repeat a string
CamperBot
@camperbot
Apr 30 2016 12:31

:point_right: algorithm repeat a string repeat a string [wiki]

Explanation:

The program is very simple, we have to take a variable and return that variable being repeated certain amount of times. No need to add space or anything, just keep repeating it into one single string.

:pencil: read more about algorithm repeat a string repeat a string on the FCC Wiki

ALMY91
@ALMY91
Apr 30 2016 12:33
<html>
<head></head>
<body>

<script type="text/javascript">

console.log (i=0,j=1,k=2)



</script>
</body>
</html>
shouldn this return 2?
since the comma operator evaluates its left n right operand and then returns the value of the right operand
Stephen James
@sjames1958gm
Apr 30 2016 12:40
@ALMY91 Depends on what console.log returns
Chris Cullen
@123xylem
Apr 30 2016 12:40
function repeatStringNumTimes(str, num) {
  var  newS =" " ;
var  count =1;
  while (count< num){
    newS =str +str;

  }


  return newS;
}

repeatStringNumTimes("abc", 3);
The browser says this is a potential infinite loop at line 4 but I dont think it is... Does this work?>
Stephen James
@sjames1958gm
Apr 30 2016 12:41
@123xylem How does it get out of the loop?
Chris Cullen
@123xylem
Apr 30 2016 12:41
when count isnt less than num?
felisnox
@felisnox
Apr 30 2016 12:41
you aren't increating count
increasing*
Stephen James
@sjames1958gm
Apr 30 2016 12:41
@123xylem And how does count get >= num
Chris Cullen
@123xylem
Apr 30 2016 12:41
o yea :( haaha ty
@felisnox thanks @sjames1958gm
CamperBot
@camperbot
Apr 30 2016 12:42
123xylem sends brownie points to @felisnox and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 158 | @felisnox | http://www.freecodecamp.com/felisnox
:star: 862 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
ALMY91
@ALMY91
Apr 30 2016 12:42
@sjames1958gm its returning 0,1,2
@sjames1958gm in my console..
Stephen James
@sjames1958gm
Apr 30 2016 12:42
@ALMY91 It is returning undefined its writing 0, 1, 2 to the console
@123xylem Rule of programming, the computer is right more often than the programmer :)
Ankur sharma
@ankur1163
Apr 30 2016 12:51
I have a question . I am learning about api
I think I saw somewhere a tech company which makes working with api easy
I dont remember the name
but part of their promise was you dont need to spend countless hours in figuring out how to do xxxx in xxxx api
but I cant recall that name. Anybody remember such service?
ionakathryn
@ionakathryn
Apr 30 2016 12:54
Hi so I am working on the first algorithm scripting challenge...reversing the string 'hello'
i have managed to split by ""
but in my final result i have h,e,l,l,o
how do i get rid of these commas? :/
thanks (Y)
:)
Stephen James
@sjames1958gm
Apr 30 2016 12:55
@ionakathryn join back to string it is an array
ionakathryn
@ionakathryn
Apr 30 2016 12:55
function reverseString(str) {
  var a = str.split("");
  a.reverse();
  return a.toString();

}

reverseString("hello");
heres what i got... which returns o,l,l,e,h
Chase
@Belax8
Apr 30 2016 12:58
@ionakathryn instead of .toString try .join('');
ionakathryn
@ionakathryn
Apr 30 2016 12:58
have also added return a.join();
to the end but doesnt work
Stephen James
@sjames1958gm
Apr 30 2016 12:58
@ionakathryn a.join('');
ionakathryn
@ionakathryn
Apr 30 2016 12:59
thank you! it worked - but doesn't that mean my result is an array not a string ?
or does join function turn it in to a string??
Stephen James
@sjames1958gm
Apr 30 2016 13:00
@ionakathryn join coverts an array to a string putting the parameter between each element.
@ionakathryn Since the parameter was "" it just joined them all together.
ionakathryn
@ionakathryn
Apr 30 2016 13:01
what does "" stand for then?
Stephen James
@sjames1958gm
Apr 30 2016 13:02
Empty string
Same as ''
ionakathryn
@ionakathryn
Apr 30 2016 13:03
Oh ok
so its basically another way of saying toString?
i am a bit confused as to why i cant return multiple times also
thank you for your help though!
Stephen James
@sjames1958gm
Apr 30 2016 13:04
You mean array.toString vs array.join ?
@ionakathryn You mean return multiple times from a function? Well, you can have more than one return, but once you reach one return the function is over.
nimaOngchu
@nimaOngchu
Apr 30 2016 13:10
Screen Shot 2016-04-30 at 11.06.47 PM.png
hi why am i not able to set the value for the prop.
Stephen James
@sjames1958gm
Apr 30 2016 13:14
Read the note provided
handi09
@handi09
Apr 30 2016 13:16
helo
Stephen James
@sjames1958gm
Apr 30 2016 13:16
Hi
evide
@evid
Apr 30 2016 13:18
good morning! could someone help me with converting Fahrenheit to Celsius?
Moisés Man
@moigithub
Apr 30 2016 13:18
@nimaOngchu id and prop are variables.. u cant use dot notation
evide
@evid
Apr 30 2016 13:18
no if or else statements,
convertToF)-30) should return a value of -22
Stephen James
@sjames1958gm
Apr 30 2016 13:19
@evid no if or else - simply use celsius parameter and formula
nimaOngchu
@nimaOngchu
Apr 30 2016 13:19
i tried the bracket notation aswell, still doenot work.
Stephen James
@sjames1958gm
Apr 30 2016 13:19
@nimaOngchu Post your code
help format
CamperBot
@camperbot
Apr 30 2016 13:19

: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 the code.

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

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

evide
@evid
Apr 30 2016 13:19
not working??? could you give me an example
Stephen James
@sjames1958gm
Apr 30 2016 13:19
F = C * 9 / 5 + 32
nimaOngchu
@nimaOngchu
Apr 30 2016 13:20
Screen Shot 2016-04-30 at 11.19.58 PM.png
Stephen James
@sjames1958gm
Apr 30 2016 13:20
@evid In the code F is the variable fahernheit and C is parameter celsuis
Moisés Man
@moigithub
Apr 30 2016 13:20
This message was deleted
Stephen James
@sjames1958gm
Apr 30 2016 13:21
@nimaOngchu id is also a variable
@nimaOngchu Every instance of id and prop need brackets
evide
@evid
Apr 30 2016 13:21
not working, thank you. have to convert five F to C
Stephen James
@sjames1958gm
Apr 30 2016 13:22
@evid The function is called 5 times, so the function provides the conversion. Post what you have
Ghulam Ahmed Lasi
@roon83
Apr 30 2016 13:22

'''
var Bike = function() {

// Only change code below this line.
var gear = 0;
this.setGear = function(change) {
gear += change;
};
this.getGear = function() {
return gear;
};

};

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(1);
'''

CamperBot
@camperbot
Apr 30 2016 13:22
:bulb: to format code use backticks! ``` more info
nimaOngchu
@nimaOngchu
Apr 30 2016 13:22
oh ok i will try that thanks
evide
@evid
Apr 30 2016 13:23
okay, but keep deleting
handi09
@handi09
Apr 30 2016 13:23
heloo
Stephen James
@sjames1958gm
Apr 30 2016 13:23
@roon83 setting gear does not meaning adding to current value
nimaOngchu
@nimaOngchu
Apr 30 2016 13:24
Thanks guys it worked.
Stephen James
@sjames1958gm
Apr 30 2016 13:25
@roon83 To get formatting use backticks ```
Ghulam Ahmed Lasi
@roon83
Apr 30 2016 13:26
var Bike = function() {

  // Only change code below this line.
  var gear = 0;
  this.setGear = function(change) {
    gear += change;
  };
  this.getGear = function() {
    return gear;
  };

};

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(1);
Did it thanks
What's wrong with the code?
Bruce Hyatt
@mrthnmn
Apr 30 2016 13:28
Hello all! I'm having a problem with the mediawiki API.
Stephen James
@sjames1958gm
Apr 30 2016 13:28
@roon83 I had to put this. in front of gear to get it to pass.
Bruce Hyatt
@mrthnmn
Apr 30 2016 13:29
my query returns an object that looks like this: { 23290197: Object }
The number (key) is dynamic
Stephen James
@sjames1958gm
Apr 30 2016 13:29
@mrthnmn can you console.log(stringify(response)) to see what the structure is
Natasha Nazari
@natashanazari
Apr 30 2016 13:30
Hey everyone! I'm stuck on the Nesting For Loops challenge. I don't understand why this error is occurring: "Error: Potential Infinite loop at line 4." Here's my code:

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++) {
for (var s = 0; i < arr[i].length; s++) {
console.log (product * (arr[i][s]));
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Stephen James
@sjames1958gm
Apr 30 2016 13:30
@mrthnmn You can use Object.keys(data) to get the dynamic keys
Stephen James
@sjames1958gm
Apr 30 2016 13:30
@natashasgodwin Your inner loop needs s < arr[i].length
Moisés Man
@moigithub
Apr 30 2016 13:31
@natashasgodwin also store on the variable product whatever multiplication u doing.. instead of console.log
Bruce Hyatt
@mrthnmn
Apr 30 2016 13:31
@sjames1958gm I'm afraid I don't have that open right now. I just want to know how I get the key, or number, which is dynamic, depending on the search string.
Zito Relova
@zitorelova
Apr 30 2016 13:31
Hello! Can someone help me with Stand in Line? I'm not quite sure what I should be doing
Stephen James
@sjames1958gm
Apr 30 2016 13:31
@mrthnmn Object.keys(data) - will return an array of keys which you can loop over
Bruce Hyatt
@mrthnmn
Apr 30 2016 13:32
@sjames1958gm I tried using the hasOwnProperty method and couldn't get it to work
Ghulam Ahmed Lasi
@roon83
Apr 30 2016 13:32
@sjames1958gm which gear?
Natasha Nazari
@natashanazari
Apr 30 2016 13:32
@sjames1958gm Haha! Dumb mistake, thanks for catching that!
CamperBot
@camperbot
Apr 30 2016 13:32
natashasgodwin sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 863 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Natasha Nazari
@natashanazari
Apr 30 2016 13:32
@moigithub Gotcha! It works now.
Stephen James
@sjames1958gm
Apr 30 2016 13:33
@roon83 return gear; I had to do return this.gear; for set gear as well - also don't add to the gear property in setGear just set it
Bruce Hyatt
@mrthnmn
Apr 30 2016 13:33
@sjames1958gm OK. I'll try that. Thanks
CamperBot
@camperbot
Apr 30 2016 13:33
mrthnmn sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 864 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 30 2016 13:33
@natashasgodwin :+1:
Richard Andrews
@Whiplash5057
Apr 30 2016 13:33
Guys need help ...!
Stephen James
@sjames1958gm
Apr 30 2016 13:33
@Whiplash5057 Yes, most guys need help.
What help do you need :)
Moisés Man
@moigithub
Apr 30 2016 13:33
;)
Richard Andrews
@Whiplash5057
Apr 30 2016 13:34
I don't know why ..my getElementByClass isn't working ....!! but geElementById is working ...
let me send you the pen
Moisés Man
@moigithub
Apr 30 2016 13:34
probably ur element dont hav a classs ?
Stephen James
@sjames1958gm
Apr 30 2016 13:34
@Whiplash5057 - you do know that getElementByClass returns an array unlike get element by id
Moisés Man
@moigithub
Apr 30 2016 13:35
Stephen James
@sjames1958gm
Apr 30 2016 13:36
@moigithub :+1:
Richard Andrews
@Whiplash5057
Apr 30 2016 13:36
@sjames1958gm getElementById also sends an array I thought ...!!check Out the console
Moisés Man
@moigithub
Apr 30 2016 13:36
in theory ID's should be UNIQUES
Stephen James
@sjames1958gm
Apr 30 2016 13:37
@Whiplash5057 Nope
Richard Andrews
@Whiplash5057
Apr 30 2016 13:37
@moigithub Yes ...U just wanna check things out ...hey ...getElementByClassName also doesn't work
@sjames1958gm ???
Eldar Tinjić
@EldarT90
Apr 30 2016 13:37
@sjames1958gm hey mate, can you look at something ?
Moisés Man
@moigithub
Apr 30 2016 13:37
elementS @Whiplash5057
Stephen James
@sjames1958gm
Apr 30 2016 13:38
@Whiplash5057 getElementsByClassName - there is an s in there. ID returns single element no array
@EldarT90 sure
Richard Andrews
@Whiplash5057
Apr 30 2016 13:38
still not working...!!!
hehe
:smile:
Stephen James
@sjames1958gm
Apr 30 2016 13:39
@Whiplash5057 Uncaught TypeError: list.querySelectorAll is not a function
Eldar Tinjić
@EldarT90
Apr 30 2016 13:39
@sjames1958gm https://codepen.io/EldarT/pen/bpmwYV - when i click one field i want randomly to get the second field but sometimes it works, sometimes it doesnt (variable b and newArr are important)
Stephen James
@sjames1958gm
Apr 30 2016 13:39
@sjames1958gm possibly because list is an array
Bruce Hyatt
@mrthnmn
Apr 30 2016 13:40
@sjames1958gm That returns undefined, it appears. Here's the code:
Richard Andrews
@Whiplash5057
Apr 30 2016 13:40
@sjames1958gm @moigithub @moigithub But in the console it is showing getElementByClassName is not a function
Bruce Hyatt
@mrthnmn
Apr 30 2016 13:40
      type: "GET",
      crossDomain: true,
      url: "https://en.wikipedia.org/w/api.php",
      data: {
        action: "query",
        titles: searchText,
        generator: "links",
        format: "json"
      },
      dataType: "jsonp",
      jsonpCallback: "jsonp_cb",
      success: function(response) {
        $.each(response.query.search, function(key, value){
          var list = document.getElementById("jsonResults");
          $(list).append("<div id='result'>" + value.title + "<br>" + value.snippet + "</div><br>")
        })
var keys = response.query.pages;        console.log(keys.keys);
      }
    })
Moisés Man
@moigithub
Apr 30 2016 13:41
@Whiplash5057 getElementsByClassName ... check the correct name of the method
Bruce Hyatt
@mrthnmn
Apr 30 2016 13:41
Try again $.ajax({ type: "GET", crossDomain: true, url: "https://en.wikipedia.org/w/api.php", data: { action: "query", titles: searchText, generator: "links", format: "json" }, dataType: "jsonp", jsonpCallback: "jsonp_cb", success: function(response) { $.each(response.query.search, function(key, value){ var list = document.getElementById("jsonResults"); $(list).append("<div id='result'>" + value.title + "<br>" + value.snippet + "</div><br>") }) var keys = response.query.pages; console.log(keys.keys); } })
Richard Andrews
@Whiplash5057
Apr 30 2016 13:42
@moigithub still not working ...!!
sorry to trouble u guys but noting is working .... :smile:
Ghulam Ahmed Lasi
@roon83
Apr 30 2016 13:42
@sjames1958gm Thanks but I am still unable to solve this.
CamperBot
@camperbot
Apr 30 2016 13:42
roon83 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 865 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 30 2016 13:42
@Whiplash5057
var list = document.getElementsByClassName ("checklist")

var items = list[0].querySelectorAll("li");
console.log( items);
@roon83
this.setGear(gear) {
  this.gear = gear;
}
this.getGear() {
  return this.gear;
}
Richard Andrews
@Whiplash5057
Apr 30 2016 13:43
@sjames1958gm wowowowowowow.....!!!
that worked ...
Stephen James
@sjames1958gm
Apr 30 2016 13:44
@Whiplash5057 :)
@mrthnmn Where did you put the keys = Object.keys(response.query.pages);
Bruce Hyatt
@mrthnmn
Apr 30 2016 13:46
@sjames1958gm I tried to return it in the console. I thought "Object" meant MY object, not "Object" literally
Stephen James
@sjames1958gm
Apr 30 2016 13:46
@mrthnmn sry my bad
Richard Andrews
@Whiplash5057
Apr 30 2016 13:47
@sjames1958gm That means ...getElementsByClassName sends an array ...then what is getElementsByClass used form
for*
Boyce
@Yijianc
Apr 30 2016 13:47
help Everything Be True
CamperBot
@camperbot
Apr 30 2016 13:47

:point_right: algorithm everything be true [wiki]

Explanation:

The program needs to check if the second argument is a truthy element, and it must check this for each object in the first argument.

Hint: 1

Remember to iterate through the first argument to check each object.

Hint: 2

Only if all of them are truth will we return true, so make sure all of them check.

Hint: 3

You could use loops or callbacks functions, there are multiple ways to solve this problem.

Spoiler Alert!

687474703a2f2f7777772e796f75726472756d2e636f6d2f796f75726472756d2f696d616765732f323030372f31302f31302f7265645f7761726e696e675f7369676e5f322e676966.gif

Solutions ahead!

:pencil: read more about algorithm everything be true on the FCC Wiki

Bruce Hyatt
@mrthnmn
Apr 30 2016 13:48
@sjames1958gm No! That worked! Thanks again! I had tried that before and, of course, had the same problem.
CamperBot
@camperbot
Apr 30 2016 13:48
mrthnmn sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: mrthnmn already gave sjames1958gm points
Stephen James
@sjames1958gm
Apr 30 2016 13:48
@Whiplash5057 i don't find that function on document
Richard Andrews
@Whiplash5057
Apr 30 2016 13:50
cool cool ...and one more thing ...I use getElementById in this pen and it works ....It sends a response as an array ....
Eldar Tinjić