These are chat archives for FreeCodeCamp/HelpJavaScript

3rd
Aug 2016
Troy
@twf
Aug 03 2016 00:00
I must be missing something

function nextInLine(arr, item) {
  // Your code here

 return arr.push(5);  // Change this line

}

// Test Setup
var testArr = ([5,6,7,8,9],[]);

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 3)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
still can't figure it out
BeefHazard
@BeefHazard
Aug 03 2016 00:01
@Sent-A-Message why are you pushing 5?
Troy
@twf
Aug 03 2016 00:01
it says to " Add the number to the end of the array, then remove the first element of array"
Norvin Burrus
@ndburrus
Aug 03 2016 00:03
@Sent-A-Message
...good to see you back!
it may be helpful to review the previous comment/s: :sparkles:
BeefHazard
@BeefHazard
Aug 03 2016 00:03
@Sent-A-Message so why did you pick 5?
Haelmorn
@Haelmorn
Aug 03 2016 00:04
Need help again :/
Robinsond7691
@Robinsond7691
Aug 03 2016 00:04

Guys, I'm trying to go through a loop to check the properties of each object in the array. My question is, how do I refer to the property in each object in a statement? As an example:

for (j = 0; j < contacts[i].length; j++) {
          if (contacts[i][j] == prop) {
            return contacts[i][j];
           }

contacts[1][j] is incorrect because that's how you refer to a nested array right? How do I make my loop check through the properties of an object?

Haelmorn
@Haelmorn
Aug 03 2016 00:04
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup = {
   "alpha":"Adams",
   "bravo":"Boston",
   "charlie":"Chicago",
   "delta":"Denver",
   "echo":"Easy",
   "foxtrot":"Frank",
  };

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

// Change this value to test
phoneticLookup("charlie");
the challenge is Using Objects for Lookups
BeefHazard
@BeefHazard
Aug 03 2016 00:05
@Haelmorn hint: result should have a value
Robinsond7691
@Robinsond7691
Aug 03 2016 00:05
was that for me?
Norvin Burrus
@ndburrus
Aug 03 2016 00:05

@Haelmorn
examine the instructions sample code to see how they access the desired value from the object table. here:

alpha[2]; // "Y"
alpha[24]; // "C"

once we have the value, it can be assigned to a variable... :sparkles:

BeefHazard
@BeefHazard
Aug 03 2016 00:06
@Robinsond7691 if I mean you I would've mentioned you
Robinsond7691
@Robinsond7691
Aug 03 2016 00:06
oh ok
Troy
@twf
Aug 03 2016 00:06
had to look it up on reddit couldn't take it anymore
function nextInLine(arr, item) {
  // Your code here
   arr.push(item);
   return arr.shift();
}
BeefHazard
@BeefHazard
Aug 03 2016 00:06
@Sent-A-Message if you'd just think logically and reason yourself through it, this shouldn't have been much of a problem
Troy
@twf
Aug 03 2016 00:07
@BeefHazard they gave a bunch of random # and that totally through me off as I thought the goal was to make them work in the problem
BeefHazard
@BeefHazard
Aug 03 2016 00:08
@Sent-A-Message we've tried to tell you that you shouldn't pick a random number to push....
Troy
@twf
Aug 03 2016 00:08
Random trash had nothing to do with how to solve the problem
easy to tell i was looking at wrong thing now :(
BeefHazard
@BeefHazard
Aug 03 2016 00:08
@Sent-A-Message they're numbers to check if your solution is correct. The algorithm automatically enters those when checking
Haelmorn
@Haelmorn
Aug 03 2016 00:09
@ndburrus @BeefHazard nope Im not getting it.
BeefHazard
@BeefHazard
Aug 03 2016 00:09
@Haelmorn at the end of your function you have return result;
what is the value of result at this moment?
Norvin Burrus
@ndburrus
Aug 03 2016 00:09
@jhcastanod you're welcome! enjoy! :palm_tree:
Haelmorn
@Haelmorn
Aug 03 2016 00:10
@BeefHazard it does not have a value, as I dont know how to assign one to it
BeefHazard
@BeefHazard
Aug 03 2016 00:10
@Haelmorn well let's find out
@Haelmorn first, let's analyse what we have. We have the argument val, we have an object lookup and we need to return a result
now the question is: how to combine them so result returns the thing associated with val
it's one rule of code
Haelmorn
@Haelmorn
Aug 03 2016 00:12
result = lookup.phoneticLookup?
Norvin Burrus
@ndburrus
Aug 03 2016 00:13
@Haelmorn
alright, the object table looks great! :sparkles:
now, we need to use the object table to get (and return) a value (result).
here: alpha[2]; // "Y" (in the sample code) the object table name (alpha) is used, along with the key value (in this case 2), to get the value "Y"
see how this works?
BeefHazard
@BeefHazard
Aug 03 2016 00:13
getting close. Remember phoneticLookup is the name of the function, you can't call that inside the function
Tyler Brown
@pelicanscarecrow
Aug 03 2016 00:14
Can anyone help me with the "convert celsius to fahrenheit challenge? Here is the starting code

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

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

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

Haelmorn
@Haelmorn
Aug 03 2016 00:14
@BeefHazard result = lookup.val?
Tyler Brown
@pelicanscarecrow
Aug 03 2016 00:14
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
Here are the check marks
BeefHazard
@BeefHazard
Aug 03 2016 00:14
@pelicanscarecrow for this one, I'd advise you to put it into algebra first
Norvin Burrus
@ndburrus
Aug 03 2016 00:14
@pelicanscarecrow :sparkles:
The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
we can rewrite the equation/formula to: Fahrenheit is (=) Celsius times() 9/5, plus (+) 32.
which is F = C
9/5 + 32,
or F = C(9/5) + 32.
alright, so we need to convert this formula to code!
BeefHazard
@BeefHazard
Aug 03 2016 00:15
@ndburrus you have a hotkey for that one, don't you? ;)
Norvin Burrus
@ndburrus
Aug 03 2016 00:15
@Haelmorn look at the example code format...
BeefHazard
@BeefHazard
Aug 03 2016 00:15
@Haelmorn point and bracket notation can get a little confusing. You didn't choose the right one this time. Looks great for the rest!
Norvin Burrus
@ndburrus
Aug 03 2016 00:15
@BeefHazard what is a hotkey? :smile:
ghiasR
@ghiasum
Aug 03 2016 00:16
Hello can someone explain to me why this code doesn't work for the seek and destroy algorithm:
// Remove all the values
arr = arr.filter(function(element){
for(var i=1; i<arguments.length; i++){
if(element === arguments[i]){
return false;
}
}
return true;
});
Tyler Brown
@pelicanscarecrow
Aug 03 2016 00:16
Okay, so if I was to convertToF(-30) then I would plug in -30 into the F?
and solve for C?
Haelmorn
@Haelmorn
Aug 03 2016 00:16
@BeefHazard @ndburrus hey, that worked. Thx again!!
CamperBot
@camperbot
Aug 03 2016 00:16
haelmorn sends brownie points to @beefhazard and @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 1306 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 254 | @beefhazard |http://www.freecodecamp.com/beefhazard
BeefHazard
@BeefHazard
Aug 03 2016 00:16
@pelicanscarecrow don't look at the numbers for the checking
Tyler Brown
@pelicanscarecrow
Aug 03 2016 00:16
Or would I want to work the other way around
BeefHazard
@BeefHazard
Aug 03 2016 00:17
@pelicanscarecrow take celsius = x, how would you write down the formula?
Tyler Brown
@pelicanscarecrow
Aug 03 2016 00:17
I am sorry I am just very confused on what to write inside the actual code.
it would be like y=mx + b
BeefHazard
@BeefHazard
Aug 03 2016 00:17
@pelicanscarecrow look at the description, it tells you what to do
Tyler Brown
@pelicanscarecrow
Aug 03 2016 00:17
f= 9/5 +32
C*
Norvin Burrus
@ndburrus
Aug 03 2016 00:17
@Haelmorn you're welcome!
great job! way to go! :+1:
for future reference, this may be helpful: :sparkles:
BeefHazard
@BeefHazard
Aug 03 2016 00:17
@pelicanscarecrow where does celsius come in?
Tyler Brown
@pelicanscarecrow
Aug 03 2016 00:18
I would say " fahrenheit " and then what that is what is loses me
BeefHazard
@BeefHazard
Aug 03 2016 00:18
@pelicanscarecrow because you just described a constant to me
@pelicanscarecrow paste the description here
scarejar
@scarejar
Aug 03 2016 00:19
the break statement stops the loop right? Or just the if statement?
Norvin Burrus
@ndburrus
Aug 03 2016 00:19
@pelicanscarecrow :point_up: August 2, 2016 8:14 PM
Haelmorn
@Haelmorn
Aug 03 2016 00:22
@BeefHazard last one for today, need help with Testing Objects for Properties
```

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
 myObj.checkProp("gift");
}

// Test your code by modifying these values
checkObj("gift");
Robert Richey
@0x0936
Aug 03 2016 00:23
@scarejar break stops the current loop
Tyler Brown
@pelicanscarecrow
Aug 03 2016 00:23
And how would I check off the "convertToF(0) should return a number" checkmark?
BeefHazard
@BeefHazard
Aug 03 2016 00:23
note the description
Haelmorn
@Haelmorn
Aug 03 2016 00:24
how do I note?
BeefHazard
@BeefHazard
Aug 03 2016 00:24
@pelicanscarecrow is that the only one not checked now?
@Haelmorn by reading it and being alert
you see the method they use?
Keli Fine
@kelifine
Aug 03 2016 00:24
Hey I've got an array of numbers and characters I'm trying to convert back to characters using fromCharCode, for some reason any number below 60 is not converting back to a character but ones above are, can anyone help me? Here is the section of code
var array3 = [];
for (var m = 0; m<array2.length; m++) {
if (typeof(array2[m]) === "number") {
array3.push(String.fromCharCode(array2[m]));
}
else {array3.push(array2[m]);}
}
scarejar
@scarejar
Aug 03 2016 00:25
@0x0936 ahh thanks.
CamperBot
@camperbot
Aug 03 2016 00:25
scarejar sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1621 | @0x0936 |http://www.freecodecamp.com/0x0936
Haelmorn
@Haelmorn
Aug 03 2016 00:25
@BeefHazard yea but they use sth that returns t/f and Im supposed to get strings
Tyler Brown
@pelicanscarecrow
Aug 03 2016 00:25
No they are all not checked, I just do not understand what to do exactly when it says "convertToF(-30) should return a value of -22", where would I plug in each of those numbers? and what would I write on the code?
BeefHazard
@BeefHazard
Aug 03 2016 00:26
@pelicanscarecrow you don't have to! Stop looking at those numbers. They're useless. The checking algorithm will input them. You see the word between parentheses after function? That's an argument. The argument can be anything and your function will apply some transformations to the input, then returning it.
@pelicanscarecrow so all you have to do is make the formula and input the argument wherever you'd expect a number
ghiasR
@ghiasum
Aug 03 2016 00:27

Hey Guys. can someone help me with the seek and destroy algorithm ?

This is what my code looks like right now. I am trying to figure out why it doesn't work.

function destroyer(arr) {
// Remove all the values
arr = arr.filter(function(element){
for(var i=1; i<arguments.length; i++){
if(element === arguments[i]){
return false;
}
}
return true;
});

return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Tyler Brown
@pelicanscarecrow
Aug 03 2016 00:28
@BeefHazard oh that makes sense. So what would I write in the code? Just "F=9/5c+32"?
BeefHazard
@BeefHazard
Aug 03 2016 00:28
@pelicanscarecrow nearly. You've got the formula right, now you have to convert it to actual code
@pelicanscarecrow this would mean fahrenheit = (9/5) * celsius + 32
@Haelmorn Note "If the property is found, return that property's value"
Tyler Brown
@pelicanscarecrow
Aug 03 2016 00:30
thank you @BeefHazard
CamperBot
@camperbot
Aug 03 2016 00:30
pelicanscarecrow sends brownie points to @beefhazard :sparkles: :thumbsup: :sparkles:
:cookie: 255 | @beefhazard |http://www.freecodecamp.com/beefhazard
BeefHazard
@BeefHazard
Aug 03 2016 00:30
@Haelmorn so what're you going to check for?
scarejar
@scarejar
Aug 03 2016 00:32
@ghiasum think you should return a different value because the code is just going to return the passed in parameter, so rename arr = arr.filter something else
Haelmorn
@Haelmorn
Aug 03 2016 00:32
This message was deleted
myObj.hasOwnProperty(checkProp);
  return myObj[checkProp];
I have that, it somehow works! :D
BeefHazard
@BeefHazard
Aug 03 2016 00:32
@Haelmorn It does? I solved it with an if-clause
Haelmorn
@Haelmorn
Aug 03 2016 00:33
But I dont really know how to get different result if answer is false. Edit: Modified it to : if (myObj.hasOwnProperty(checkProp)) {
return myObj[checkProp];
} else {
return "Not Found";
} and it works
@BeefHazard thx for helping again!
CamperBot
@camperbot
Aug 03 2016 00:35
haelmorn sends brownie points to @beefhazard :sparkles: :thumbsup: :sparkles:
:warning: haelmorn already gave beefhazard points
BeefHazard
@BeefHazard
Aug 03 2016 00:36
@Haelmorn That's the correct way. Happy to help!
Moisés Man
@moigithub
Aug 03 2016 00:36
the else part u could remove.. since return exit the function.. and first return is controlled by IF condition
ghiasR
@ghiasum
Aug 03 2016 00:37
@scarejar i tried renaming it to tmpArr but it gives the same results.
Moisés Man
@moigithub
Aug 03 2016 00:38
@ghiasum EVERY function have its own arguments object
using arguments in the callback its not the same as using it outside
they will give different values
u can check using console.log(arguments )
thechanchanman
@thechanchanman
Aug 03 2016 00:40
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!";
  }
}

// Change these values to test
golfScore(1, 1);
Hello! Any idea why this isn't accepted answer on "Golf Code"?
llamatarianism
@llamatarianism
Aug 03 2016 00:41
@thechanchanman I think it should be "Hole-in-one!"
thechanchanman
@thechanchanman
Aug 03 2016 00:41
lol
thanks :)
ghiasR
@ghiasum
Aug 03 2016 00:41
@moigithub Thnx! that really helped. Got it working now
CamperBot
@camperbot
Aug 03 2016 00:41
ghiasum sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1793 | @moigithub |http://www.freecodecamp.com/moigithub
Keli Fine
@kelifine
Aug 03 2016 00:48
Hey I've got an array of numbers and characters I'm trying to convert back to characters using fromCharCode, for some reason any number below 60 is not converting back to a character but ones above are, can anyone help me? Here is the section of code
var array3 = [];
for (var m = 0; m<array2.length; m++) {
if (typeof(array2[m]) === "number") {
array3.push(String.fromCharCode(array2[m]));
}
else {array3.push(array2[m]);}
}
anyone??
llamatarianism
@llamatarianism
Aug 03 2016 00:51
@kelifine that part of your code looks fine
the problem is somewhere else
Keli Fine
@kelifine
Aug 03 2016 00:52
@llamatarianism Here's the entire thing:
function rot13(str) { // LBH QVQ VG!
var array1 = [];
for (var i = 0; i<str.length; i++) {
switch (str.charAt(i)) {
case " ":
case ".":
case "?":
case "!":
array1.push(str.charAt(i));
break;
default:
array1.push(str.charCodeAt(i));
break;
}
}
var array2 = [];
for (var k = 0; k<array1.length; k++) {
if (typeof(array1[k]) === "number") {
array2.push(array1[k] - 13);
}
else {array2.push(array1[k]);}
}
var array3 = [];
for (var m = 0; m<array2.length; m++) {
if (typeof(array2[m]) === "number") {
array3.push(String.fromCharCode(array2[m]));
}
else {array3.push(array2[m]);}
}
var finalstring = array3.join('');
return finalstring;
}
BeefHazard
@BeefHazard
Aug 03 2016 00:53
@kelifine if you want to be helped properly, use code markdown
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 00:53
@kelifine check what typeof does, and your if
Keli Fine
@kelifine
Aug 03 2016 00:54
@stonefmagiecurata the typeof checks to see if it's a number and should convert it to a character if it is - it does for some numbers but not numbers with code below 60, so I'm not sure why that's happening
@BeefHazard how do I do that?
BeefHazard
@BeefHazard
Aug 03 2016 00:55
```js
your code
```
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 00:55
@kelifine check this line in your code: if (typeof(array1[k]) === "number")
Keli Fine
@kelifine
Aug 03 2016 00:56
@stonefmagiecurata that seems to be working ok because my array2 has all the numbers I'm wanting?
@BeefHazard am I supposed to add that here when I copy my code?
BeefHazard
@BeefHazard
Aug 03 2016 00:57
@kelifine put 3 of these: ` on top and 3 below. If you want syntax highlighting, put "js" next to the top 3
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 00:58
@kelifine only that part will work of course, cause it will always return as true
Keli Fine
@kelifine
Aug 03 2016 00:58
function rot13(str) { // LBH QVQ VG!
var array1 = [];
for (var i = 0; i<str.length; i++) {
switch (str.charAt(i)) {
case " ":
case ".":
case "?":
case "!":
array1.push(str.charAt(i));
break;
default:
array1.push(str.charCodeAt(i));
break;
}
}
var array2 = [];
for (var k = 0; k<array1.length; k++) {
if (typeof(array1[k]) === "number") {
array2.push(array1[k] - 13);
}
else {array2.push(array1[k]);}
}
var array3 = [];
for (var m = 0; m<array2.length; m++) {
if (typeof(array2[m]) === "number") {
array3.push(String.fromCharCode(array2[m]));
}
else {array3.push(array2[m]);}
}
var finalstring = array3.join('');
return finalstring;
}
Ralph Nahra
@Rallph
Aug 03 2016 00:58
Hey guys I'm having trouble with the check for palindromes challenge. most of the things are good but for some reason palindrome("_eye") is returning false
function palindrome(str) {
  var val = str.toLowerCase().replace(/\W/g,'');

if (val === val.split("").reverse().join("")) {

  return true;
  } else {
    return false;
  }
}



palindrome("_eye");
Keli Fine
@kelifine
Aug 03 2016 00:59
@stonefmagiecurata so I'm not understanding why some of the numbers in array2 are being converted to characters in array3 but some aren't?
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 01:00
@kelifine if (typeof(array1[k]) === "number") translates to: if (typeof(true)) or if (typeof(false))
Cristian Ramírez Jiménez
@CodingCris7
Aug 03 2016 01:00
Hi guys, I have this problem with my code(below): "Cannot read porperty 'length' of undefined", I tried to inspect my code with the debugger's browser(Chromiun) and it runs until a certain point but then that problem shows up.
function findLongestWord(str) {
  var chonk = str.split(" ");

  var maxChonk = chonk[0].length;
  for ( var i = 0 ; i < chonk.length ; i++ ){
      if ( maxChonk > chonk[i+1].length ){
          maxChonk = chonk[i].length;    
      }
      else {
          maxChonk = chonk[i+1].length;
      }
  }
  return maxChonk;
}
Keli Fine
@kelifine
Aug 03 2016 01:00
@stonefmagiecurata so why does that work on some numbers but not on others?
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 01:00
@kelifine my bad I missed the closing parans
Robert Richey
@0x0936
Aug 03 2016 01:03
@CodingCris7 on the last loop iteration, chonk[i+1] is accessing an element outside the array's bounds. On the last iteration, i+1 is equal to the length and there's no element at that index
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 01:05
@kelifine what is the name of the challenge?
Keli Fine
@kelifine
Aug 03 2016 01:05
@stonefmagiecurata caesars cipher
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 01:05
@kelifine ok, I'll check out the specs
Cristian Ramírez Jiménez
@CodingCris7
Aug 03 2016 01:05
@0x0936 I wasn't notice that, you're right. Thanks man
CamperBot
@camperbot
Aug 03 2016 01:05
codingcris7 sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1622 | @0x0936 |http://www.freecodecamp.com/0x0936
Keli Fine
@kelifine
Aug 03 2016 01:07
@stonefmagiecurata thank you!
CamperBot
@camperbot
Aug 03 2016 01:07
kelifine sends brownie points to @stonefmagiecurata :sparkles: :thumbsup: :sparkles:
:cookie: 284 | @stonefmagiecurata |http://www.freecodecamp.com/stonefmagiecurata
BeefHazard
@BeefHazard
Aug 03 2016 01:08
ugh, gonna finish off object oriented & functional programming and call it a day
Jim Zhang
@dividez
Aug 03 2016 01:09
hello?
BeefHazard
@BeefHazard
Aug 03 2016 01:09
Hello @dividez
Jim Zhang
@dividez
Aug 03 2016 01:09
this have a problem
````
Tyler Brown
@pelicanscarecrow
Aug 03 2016 01:10

// Example
var ourStr = "I come first. " + "I come second.";

// Only change code below this line

var myStr = "This is the start." + "This is the end.";

Jim Zhang
@dividez
Aug 03 2016 01:10
 ``` 
```
Tyler Brown
@pelicanscarecrow
Aug 03 2016 01:10
mrStr should have a value of This is the start. This is the end.
Am I not correct?
Jim Zhang
@dividez
Aug 03 2016 01:11
 ``` 
```
function sumAll(arr) {
var myArray = [];
for (var i = Math.min(arr); i <= Math.max(arr); i++) {
myArray.push(i);
}
alert(myArray) ;
}
sumAll([1, 4]);
 ``` 

function sumAll(arr) {
var myArray = [];
for (var i = Math.min(arr); i <= Math.max(arr); i++) {
myArray.push(i);
}
alert(myArray) ;
}

sumAll([1, 4]);

```

no
oh my god
Tyler Brown
@pelicanscarecrow
Aug 03 2016 01:13

// Example
var ourStr = "I come first. " + "I come second.";

// Only change code below this line

var myStr = "This is the start." + "This is the end.";

Any one know this problem?
Robert Richey
@0x0936
Aug 03 2016 01:14

@kelifine looks like the problem may be with this part

if (typeof(array1[k]) === "number") {
  array2.push(array1[k] - 13);
}

That push is assuming the character code of the letter is greater than 'A'.charCodeAt(0) + 13, otherwise, you'll get a rotation in the ASCII table to whatever comes before 'A'

Jim Zhang
@dividez
Aug 03 2016 01:15

```function sumAll(arr) {
var myArray = [];
for (var i = Math.min(arr); i <= Math.max(arr); i++) {
myArray.push(i);
}
alert(myArray) ;
}

sumAll([1, 4]);

```

stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 01:15
@kelifine ok I checked it, you always subtract 13
@kelifine based on the letters, you have to add OR subtract 13
Robert Richey
@0x0936
Aug 03 2016 01:16
@pelicanscarecrow Looks like you're missing a space to separate the two sentences.
Brenda Kaing
@brendak
Aug 03 2016 01:17
Hi! Can anyone help me with 'Repeat a string repeat a string': Repeat a given string (first argument) num times (second argument). Return an empty string if num is not a positive number.
This message was deleted

function repeatStringNumTimes(str, num) {
for(var i = 0; i < str.lenght; i++) {
str = str.repeat(num);
}
return str;
}

repeatStringNumTimes("abc", 3);

^ That is what I have so far
Keli Fine
@kelifine
Aug 03 2016 01:18
@stonefmagiecurata how do I know which I have to do?
Ademola Adegbuyi
@ooade
Aug 03 2016 01:18
@brendak you don't need a loop since you're using the .repeat()
return str.repeat(num); //will do
Keli Fine
@kelifine
Aug 03 2016 01:19
@stonefmagiecurata oh is it if it's less than 13 from the end or beginning of the alphabet I go the other way?
Robert Richey
@0x0936
Aug 03 2016 01:19
@dividez Math.min() and Math.max() take comma separated values as arguments - not an array. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min. You could use the spread operator to spread out the values of an array as comma separated arguments.
Math.min(...arr); // for example
Brenda Kaing
@brendak
Aug 03 2016 01:19
Thanks @marhyorh!
CamperBot
@camperbot
Aug 03 2016 01:19
brendak sends brownie points to @marhyorh :sparkles: :thumbsup: :sparkles:
:cookie: 699 | @marhyorh |http://www.freecodecamp.com/marhyorh
Hassaan Hafeez
@HassHz
Aug 03 2016 01:19
@brendak You also need to check if num is 0 or less, and return just "" if it is
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 01:19
@kelifine yeah
@kelifine or find the middle letter in the alfabet, and go with that logic
Brenda Kaing
@brendak
Aug 03 2016 01:20
@HassHz ah yes, it doesn't work with negatives currently
Jim Zhang
@dividez
Aug 03 2016 01:20
@0x0936 thanks
CamperBot
@camperbot
Aug 03 2016 01:20
dividez sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1623 | @0x0936 |http://www.freecodecamp.com/0x0936
Keli Fine
@kelifine
Aug 03 2016 01:20
@stonefmagiecurata I guess I'm still confused as to why 50s won't work for the fromCharCode?
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 01:21
@kelifine well it works, but it doesn;t give you the value you want
Keli Fine
@kelifine
Aug 03 2016 01:22
@stonefmagiecurata ohhhh ok so it's giving me a different number because that's the code for that number
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 01:22
@kelifine exactly
Keli Fine
@kelifine
Aug 03 2016 01:23
@stonefmagiecurata thank you so so much you're the best!!!
CamperBot
@camperbot
Aug 03 2016 01:23
kelifine sends brownie points to @stonefmagiecurata :sparkles: :thumbsup: :sparkles:
:warning: kelifine already gave stonefmagiecurata points
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 01:23
@kelifine here's the table with the codes and their values
William Sun
@WillTheSun
Aug 03 2016 01:23

Hello, I’m trying to import a javascript module but it’s not working
This works:

import  FishL from './FishUtils’;

But this doesn’t:

import { FishL } from './FishUtils’;
AlexanderNelson
@AlexanderNelson
Aug 03 2016 01:23
I think I'm not reading this right. Any help?

In the editor, use the Car constructor to create a new instance and assign it to myCar.

Then give myCar a nickname property with a string value.


var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 5;
};

// Only change code below this line.

var myCar = new Car();{
  this.nickname = ("black sunshine");
}
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 01:24
@kelifine so you can have something visual, else it's a blindfolded duck hunt :D
Keli Fine
@kelifine
Aug 03 2016 01:24
@stonefmagiecurata awesome that helps so much thank you!!!
CamperBot
@camperbot
Aug 03 2016 01:24
kelifine sends brownie points to @stonefmagiecurata :sparkles: :thumbsup: :sparkles:
:warning: kelifine already gave stonefmagiecurata points
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 01:24
@kelifine :+1:
Robert Richey
@0x0936
Aug 03 2016 01:25
@AlexanderNelson you got this part right var myCar = new Car(); now, how can you add a property to myCar?
@AlexanderNelson you have the right idea about using dot notation, however instead of this, use myCar. Also, don't use parentheses around your string, and remove the curly brackets
JavarriL
@JavarriL
Aug 03 2016 01:30
Is it possible to split a split? For example split "I'm the best" into ["i'm],["the"],["best] then split it again so every array has an array that separates each letter? Also I am doing the "Title Case a Sentence" so if I'm not supposed to do a split in a split, tell me
Tyler Brown
@pelicanscarecrow
Aug 03 2016 01:31
where am I missing a space?
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 01:31
@JavarriL you can't use split on arrays
Tyler Brown
@pelicanscarecrow
Aug 03 2016 01:31

// Example
var ourStr = "I come first. " + "I come second.";

// Only change code below this line

var myStr = "This is the start." + "This is the end.";

Robert Richey
@0x0936
Aug 03 2016 01:32
@pelicanscarecrow there is no space between these two sentences
var myStr = "This is the start." + "This is the end.";
AlexanderNelson
@AlexanderNelson
Aug 03 2016 01:32
@0x0936 I put the parenthesis on as I was trying to break it differently in my confusion. Its pretty crazy how something so simple can be fleeting until someone else asks you a question. Thanks I got it from that. This forum is a huge help.
CamperBot
@camperbot
Aug 03 2016 01:32
alexandernelson sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1624 | @0x0936 |http://www.freecodecamp.com/0x0936
JavarriL
@JavarriL
Aug 03 2016 01:33
@stonefmagiecurata Thanks, I'll think of something else
CamperBot
@camperbot
Aug 03 2016 01:33
javarril sends brownie points to @stonefmagiecurata :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @stonefmagiecurata |http://www.freecodecamp.com/stonefmagiecurata
Hassaan Hafeez
@HassHz
Aug 03 2016 01:33
@JavarriL You could for loop through the first split and split each of the words
Robert Richey
@0x0936
Aug 03 2016 01:34
@pelicanscarecrow notice in the example, a space is added after the first sentence, right after the period
Hassaan Hafeez
@HassHz
Aug 03 2016 01:34
var arr = str.split(' ');
for(var i = 0; i < arr.length; i++) { var letters = arr[i].split('')); }
Robert Richey
@0x0936
Aug 03 2016 01:35
@AlexanderNelson I know the feeling all too well :+1: :)
Justin Clark
@jeclark9063
Aug 03 2016 01:36
how can i use .replace() to get ride of ALL special characters
Robert Richey
@0x0936
Aug 03 2016 01:37
@jeclark9063 are you familiar with regex?
JavarriL
@JavarriL
Aug 03 2016 01:37
@HassHz Do you think that we can use the slice method as well for this challenge?
Justin Clark
@jeclark9063
Aug 03 2016 01:38
@0x0936 I am not but I will read about it
Robert Richey
@0x0936
Aug 03 2016 01:41
@JavarriL I used slice in my solution to that :+1:
JavarriL
@JavarriL
Aug 03 2016 01:41
@0x0936 @HassHz Thanks for the insight. I will try both and see how it goes
CamperBot
@camperbot
Aug 03 2016 01:41
javarril sends brownie points to @0x0936 and @hasshz :sparkles: :thumbsup: :sparkles:
:star2: 1625 | @0x0936 |http://www.freecodecamp.com/0x0936
:cookie: 636 | @hasshz |http://www.freecodecamp.com/hasshz
Tyler Brown
@pelicanscarecrow
Aug 03 2016 01:43
@0x0936 thank you
CamperBot
@camperbot
Aug 03 2016 01:43
pelicanscarecrow sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1626 | @0x0936 |http://www.freecodecamp.com/0x0936
Robert Richey
@0x0936
Aug 03 2016 01:44
:)
Micah Bales
@micahbales
Aug 03 2016 01:45
Anyone have a clue as to why this code wouldn't work?
$('#navbar').toggleClass('.no-display');
Beth Qiang
@bethqiang
Aug 03 2016 01:47
so i've been able to learn/do a lot of the beginning and intermediate stuff relatively easily, with a combination of help from external resources, google/stackoverflow, and the fcc community. however, in the last few intermediate algorithms, i feel like i've struggled A LOT and i feel like i've hit a little bit of a wall--before, i could at least work my way through the challenges by breaking them down and going step by step and now i always just feel like i have no idea where to start and i can't seem to wrap my head around any explanations i find. any advice for how to get over this?
Micah Bales
@micahbales
Aug 03 2016 01:47
@bethqiang Have you found the resources provided (linked) helpful at all?
@bethqiang Some of those intermediates are really hard.
Beth Qiang
@bethqiang
Aug 03 2016 01:49
@micahbales - sometimes, depends on the challenge. for the later ones that i'm struggling with, not really--because it's like, okay, i know how to use this, but i don't know how at all to use it within the context of the problem? and even if i have a vague idea, i can't seem to understand how the rest of the problem works.
Pau Cortes
@paucortes
Aug 03 2016 01:51
@micahbales I remember reading something about single quotes not being validated for the exercises in jQuery?
Hassaan Hafeez
@HassHz
Aug 03 2016 01:51
@JavarriL There's a lot of ways to go about doing that challenge, you could use replace(), but also slice() (but maybe not for the reason you are thinking)
Diego Mayer
@Chrono79
Aug 03 2016 01:53
@micahbales the class name goes without the dot
http://api.jquery.com/toggleclass/
Stef Busta
@DesertBugZ
Aug 03 2016 01:56
I am completely stuck on Convert Celsius to Fahrenheit challenge. I'm not sure how to set it up. I'm drawing a complete blank. lol Would someone mind helping me with this one?
LaurenCodes
@LaurenCodes
Aug 03 2016 01:56

hi guys! any idea how I can import JS multiple modules?
here’s my single module code

import  Calc from ‘./CalcUtils’;

But this double import stops working

import { Calc, square } from ‘./CalcUtils’;

in fact this single import with curly braces doesn’t work either

import { Calc  } from ‘./CalcUtils’;
Diego Mayer
@Chrono79
Aug 03 2016 01:58
@DesertBugZ Write this as code:
The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
fahrenheit = ...
llamatarianism
@llamatarianism
Aug 03 2016 02:00
@LaurenCodes the syntax with braces is used to import stuff from modules.

the syntax without braces is like python's import statement.

import calc

the syntax with braces is like python's from ... import statement.

from calc import square
import { Calc } from "./CalcUtils/;
is wrong unless Calc is a member of that module.
if you want to import multiple modules, use multiple import statements
Stef Busta
@DesertBugZ
Aug 03 2016 02:02
@Chrono79 ok thanks! a little simpler that I thought..
CamperBot
@camperbot
Aug 03 2016 02:02
desertbugz sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1720 | @chrono79 |http://www.freecodecamp.com/chrono79
llamatarianism
@llamatarianism
Aug 03 2016 02:03
import module from "/path/to/module";
import { memberFunction, memberObject } from "/path/to/other/module/";
mrankins
@mrankins
Aug 03 2016 02:03
This message was deleted

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line. Math.floor(Math.random() 20);
var randomWholeNum = Math.floor ( Math.random()
10);

return Math.random();
}

llamatarianism
@llamatarianism
Aug 03 2016 02:04
because you're not returning randomWholeNum
Diego Mayer
@Chrono79
Aug 03 2016 02:04
@mrankins because you return Math.random()
mrankins
@mrankins
Aug 03 2016 02:05
@llamatarianism @Chrono79 thanks so much
CamperBot
@camperbot
Aug 03 2016 02:05
mrankins sends brownie points to @llamatarianism and @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1109 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
:star2: 1721 | @chrono79 |http://www.freecodecamp.com/chrono79
Micah Bales
@micahbales
Aug 03 2016 02:08
@Chrono79 Thank you!
CamperBot
@camperbot
Aug 03 2016 02:08
micahbales sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1722 | @chrono79 |http://www.freecodecamp.com/chrono79
Tyler Brown
@pelicanscarecrow
Aug 03 2016 02:08

// Example
var firstNameLength = 0;
var firstName = "Ada";

firstNameLength = firstName.length;

// Setup
var lastNameLength = 0;
var lastName = "Lovelace";

// Only change code below this line.

lastNameLength = lastName;

Where would I insert the .length?
Diego Mayer
@Chrono79
Aug 03 2016 02:09
firstNameLength = firstName.length;
where is length there?
Stef Busta
@DesertBugZ
Aug 03 2016 02:09

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

fahrenheit= 5;
fahrenheit= -22;
fahrenheit= 14;
fahrenheit= 32;
fahrenheit= 68;
fahrenheit= 86;

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

// Change the inputs below to test your code
convertToF(0);
convertToF(-30);
convertToF(-10);
convertToF(0);
convertToF(20);
convertToF(30);

THE 1st and last one worked, what did i do wrong?

convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86

Tyler Brown
@pelicanscarecrow
Aug 03 2016 02:10
Okay I got it. They are always more simple than you would think
Diego Mayer
@Chrono79
Aug 03 2016 02:10
@DesertBugZ you hardcoded a lot, use the formula and the function parameter
Tyler Brown
@pelicanscarecrow
Aug 03 2016 02:10
@Chrono79 thank you
CamperBot
@camperbot
Aug 03 2016 02:10
pelicanscarecrow sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1723 | @chrono79 |http://www.freecodecamp.com/chrono79
Sergio Salinas
@sergiosalfer
Aug 03 2016 02:11
hi yall
can you help me?
Diego Mayer
@Chrono79
Aug 03 2016 02:12
with what? @sergiosalfer
Sergio Salinas
@sergiosalfer
Aug 03 2016 02:12
Diego Mayer
@Chrono79
Aug 03 2016 02:13
@sergiosalfer have you written some code yet? Look at the code example at the left
Stef Busta
@DesertBugZ
Aug 03 2016 02:13
@Chrono79 ok..
Sergio Salinas
@sergiosalfer
Aug 03 2016 02:15
no, should I delete all the switch and convert it to a object?
Diego Mayer
@Chrono79
Aug 03 2016 02:15
@DesertBugZ all those lines are the same as writing the last line, after all, you overwrite each line with the next, and at the end, the value of fahrenheit is 86.
Your function should return different values for different inputs
@sergiosalfer yes, you could comment it to not lose the values and use them to build the object
Lusako Njwaba
@lunjwaba1
Aug 03 2016 02:16
hey there peeps
XxINFENROxX
@XxINFENROxX
Aug 03 2016 02:16
I am working on the Find the Longest Word in a String challenge, and I am trying to use a for loop to output the length of each element of the array but it is only outputting the length of the first element.
Sergio Salinas
@sergiosalfer
Aug 03 2016 02:16
thanks
Lusako Njwaba
@lunjwaba1
Aug 03 2016 02:16
i am stuck on the Profile Lookup excercise
XxINFENROxX
@XxINFENROxX
Aug 03 2016 02:16
Does anyone know what the problem could be?
Diego Mayer
@Chrono79
Aug 03 2016 02:17
No, if you don't show your code @XxINFENROxX
My best guess is your return inside the loop
XxINFENROxX
@XxINFENROxX
Aug 03 2016 02:17
What would be the simplest way to do that @Chrono79 , it won't let me copy the code
Diego Mayer
@Chrono79
Aug 03 2016 02:18
are you using the chat at full screen?
Phalanxie
@Phalanxie
Aug 03 2016 02:19
Hey, guys, can anybody help me with some code? I need to understand it.
XxINFENROxX
@XxINFENROxX
Aug 03 2016 02:19
@Chrono79 I'm not sure what you mean by that
Lusako Njwaba
@lunjwaba1
Aug 03 2016 02:20
@XxINFENROxX show your code
Diego Mayer
@Chrono79
Aug 03 2016 02:20
what's the url you're seeing right now? @XxINFENROxX is it https://gitter.im/FreeCodeCamp/HelpJavaScript ?
@Phalanxie show the code or we can't help you
XxINFENROxX
@XxINFENROxX
Aug 03 2016 02:21
No, I just clicked help so I'm still on freecodecamp
Diego Mayer
@Chrono79
Aug 03 2016 02:22
well, go to that url and try to paste your code there (open a new tab if you want)
XxINFENROxX
@XxINFENROxX
Aug 03 2016 02:22
image.png
Phalanxie
@Phalanxie
Aug 03 2016 02:22
$('a[href^="#targetElement"]').on('click', function(event) {
    var target = $(this.getAttribute('href'));
    if( target.length ) {
        event.preventDefault();
        $('html, body').stop().animate({
            scrollTop: target.offset().top
        }, 1000);
    }
});
Jorge Castaño Delgado
@jhcastanod
Aug 03 2016 02:22
function findLongestString(str){
  var store  = [];
  var newString = str.split(' ');

  for(i = 0; i < newString.length; i++){
    var firstValue = newString[i].length;
    var secondValue = newString[i + 1];

    if(firstValue > secondValue){
      store = store.push(newString[i]);
    }
    else{
    store = store.push(newString[i + 1]);
    }
  }
}
when I am running the code above I've gotten the following error : Uncaught TypeError: store.push is not a function. What should I do?
XxINFENROxX
@XxINFENROxX
Aug 03 2016 02:23
@Chrono79 Thanks that worked
CamperBot
@camperbot
Aug 03 2016 02:23
xxinfenroxx sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1724 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Aug 03 2016 02:23
@XxINFENROxX Say what, my guess was right, you return inside your loop, and that exits the function
use a var to store the value and return outside the loop
XxINFENROxX
@XxINFENROxX
Aug 03 2016 02:25
Oh yeah, I am starting to remember that now, sorry I just got back from a long vacation and am forgetting everything.
Diego Mayer
@Chrono79
Aug 03 2016 02:25
@jhcastanod push returns the new length of the array, so it's a number and numbers haven't a push method
John Irle
@JohnIrle
Aug 03 2016 02:26
Could someone look at my twitch project? I had it working to an extent and then I changed it to fix some things. I can't seem to get it to work and I know it's probably something small I'm missing. http://codepen.io/doudeman/pen/RRYxqk?editors=0011
Robert Richey
@0x0936
Aug 03 2016 02:28
@JohnIrle open up your dev console and you'll see the error
Sergio Salinas
@sergiosalfer
Aug 03 2016 02:28
you can send code in the chat with ``` at the beginning and the end of your code
Diego Mayer
@Chrono79
Aug 03 2016 02:28
@jhcastanod rethink your code, declare only one var outside the loop and use it inside to store the candidate longest length
John Irle
@JohnIrle
Aug 03 2016 02:29
@0x0936 but it is defined?
Jorge Castaño Delgado
@jhcastanod
Aug 03 2016 02:30
@Chrono79 ok i'll try and then let you know. thanks
CamperBot
@camperbot
Aug 03 2016 02:30
jhcastanod sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1725 | @chrono79 |http://www.freecodecamp.com/chrono79
Robert Richey
@0x0936
Aug 03 2016 02:30
@JohnIrle you defined it within the jquery closure. Outside of that, streamers is not defined.
John Irle
@JohnIrle
Aug 03 2016 02:30
I see I moved it back in and it's still not displaying
Kevin Ogden
@kogden
Aug 03 2016 02:31
can someone tell me why this line isn't assigning the variable?
myStorage.car.inside["glove box"] = gloveBoxContents;
Diego Mayer
@Chrono79
Aug 03 2016 02:31
@kogden because it's the other way around, assignation goes from right to left
Kevin Ogden
@kogden
Aug 03 2016 02:32
omg. ofc
@Chrono79 thanks for the help
CamperBot
@camperbot
Aug 03 2016 02:32
kogden sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1726 | @chrono79 |http://www.freecodecamp.com/chrono79
Robert Richey
@0x0936
Aug 03 2016 02:32
@JohnIrle there are multiple problems. the next one says d is not defined. your api callback defines data
John Irle
@JohnIrle
Aug 03 2016 02:33
I changed that too
Robert Richey
@0x0936
Aug 03 2016 02:33
@JohnIrle now what does the dev console say
Diego Mayer
@Chrono79
Aug 03 2016 02:33
@JohnIrle not really a debuger but you can also click analyze js an see some errors there too
Justin Clark
@jeclark9063
Aug 03 2016 02:33

function palindrome(str) {
str.toLowerCase();
var re = /[^a-z]/;
var newstr = str.replace(re, '');
var arr = newstr.split("");
var ispal = true;

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

palindrome("eye");

What am I doing wrong here?

John Irle
@JohnIrle
Aug 03 2016 02:34
Alright I feel stupid. Thanks @0x0936 and @Chrono79
CamperBot
@camperbot
Aug 03 2016 02:34
johnirle sends brownie points to @0x0936 and @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1628 | @0x0936 |http://www.freecodecamp.com/0x0936
:star2: 1727 | @chrono79 |http://www.freecodecamp.com/chrono79
John Irle
@JohnIrle
Aug 03 2016 02:34
Fixed it. But I did learn to use devtools with codepen thanks
Robert Richey
@0x0936
Aug 03 2016 02:34
@JohnIrle :+1: :)
Diego Mayer
@Chrono79
Aug 03 2016 02:36
@jeclark9063 some errors there
toLowerCase() doesn't modify the string, it returns a modified copy
You'll want to keep the numbers too for some test case
Jorge Castaño Delgado
@jhcastanod
Aug 03 2016 02:37
@Chrono79 Diego, I have a question, in the if statement, when I declared store.push('newString[i]'), why is it storing a number instead a word? e.g. newStringo[0] is a word no a number. I dont know why it is happening
Justin Clark
@jeclark9063
Aug 03 2016 02:37
@Chrono79 Thanks
CamperBot
@camperbot
Aug 03 2016 02:37
jeclark9063 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1728 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Aug 03 2016 02:40
@jhcastanod https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push
It doesn't matter what you push to the array, you wrote this:
store =  store.push('newString[i]'); //you overwrite store that was an array with the new length of store that is a number, so the next time you can't use push
when you only want to add some element to an array, do this:
store.push('newString[i]');
Reyner
@ReynerAL
Aug 03 2016 02:44

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = (celcius * 9 / 5) + 32;
// Only change code above this line
return fahrenheit;
}

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

can anyone help me? how do I define the celcius value??

Diego Mayer
@Chrono79
Aug 03 2016 02:44
@ReynerAL misspelled celsius (one c, two s)
Reyner
@ReynerAL
Aug 03 2016 02:45
@Chrono79 oh thank you! I feel kinda stupid now .-.
CamperBot
@camperbot
Aug 03 2016 02:45
reyneral sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1729 | @chrono79 |http://www.freecodecamp.com/chrono79
Stephanie Chin
@stephaniejue
Aug 03 2016 02:45
var count = 0;

function cc(card) {
  // Only change code below this line
switch (card) {  
  case 2:
  case 3:
  case 4:
  case 5:
  case 6:
    count+=1;
    break;
  case 7:
  case 8:
  case 9:
    count+=0;
    break;
  case 10:
  case 'J':
  case 'Q':
  case 'K':
  case "A":
    count-=1;
    break;
}

  if (count > 0){
  return count + " bet";
  }
  else {
  return count + " hold";
  }
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(3); cc(7); cc('Q'); cc(8); cc('A');
Help please? It returns the correct string, but I must be doing something wrong because the tests don't pass
CamperBot
@camperbot
Aug 03 2016 02:46
no wiki entry for: please it returns the correct string but i must be doing something wrong because the tests dont pass
Diego Mayer
@Chrono79
Aug 03 2016 02:46
I actually think that challenge has those 2 var names to make you learn the hard way that var names should be checked twice ;) @ReynerAL
@sjue check bet and hold capitalization
Stephanie Chin
@stephaniejue
Aug 03 2016 02:47
@Chrono79 ahhhh thank you!!
CamperBot
@camperbot
Aug 03 2016 02:47
sjue sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1730 | @chrono79 |http://www.freecodecamp.com/chrono79
Ken Haduch
@khaduch
Aug 03 2016 02:50
@sjue - check the spelling of "Bet" and "Hold"
Tyler Brown
@pelicanscarecrow
Aug 03 2016 02:54

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");

how would I get this word blank started?
its the word blank challenge/
Diego Mayer
@Chrono79
Aug 03 2016 02:58
@pelicanscarecrow read mad libs link and review this challenge: https://www.freecodecamp.com/challenges/constructing-strings-with-variables
Jeremy
@CanadianGuy91
Aug 03 2016 03:00
Hey Guys
Ken Haduch
@khaduch
Aug 03 2016 03:04
@CanadianGuy91 - hey
Justin Woodward
@jwoo92
Aug 03 2016 03:11
I am having a little bit of trouble playing around with setInterval() and clearInterval() while using on click calls if anyone would like to review my js code.
artimath
@artimath
Aug 03 2016 03:13
Hello, I’m having trouble with LearnYouMongo:Insert.

‘’'
var mongo = require("mongodb").MongoClient;
var url = 'mongodb://localhost:27017/learnyoumongo';

mongo.connection(url, function(e, db){
if (e) {
console.log(e);
return;
}else {
console.log('Connection Established...');
var collection = db.collection('docs');
collection.insert({
firstname: process.argv[2]
, lastname: process.argv[3]
}, function(e, data){
if (e) {
console.log(e);
return;
} else {
console.log(JSON.stringify(data));
db.close();
}
});
}
});

‘''

Whoops
code test  = true;
```
var mongo = require("mongodb").MongoClient;
var url = 'mongodb://localhost:27017/learnyoumongo';


mongo.connection(url, function(e, db){
    if (e) {
        console.log(e);
        return;
    }else {
        console.log('Connection Established...');
        var collection = db.collection('docs');
        collection.insert({
                firstname: process.argv[2]
            ,   lastname: process.argv[3]
            }, function(e, data){
                if (e) {
                    console.log(e);
                    return;
                } else {
                    console.log(JSON.stringify(data));
                    db.close();
                }
            });
    }
});
I run learnyoumongo verify insert.js and receive:

# FAIL

Your solution to INSERT didn't pass. Try again!
Figured it out by running
node insert.js
Robel Tesfaye
@Robel612
Aug 03 2016 03:17
@sjue Use switch statements instead of if...else. Also create new variable that returns "0 Hold", "1 Bet". and so on.
artimath
@artimath
Aug 03 2016 03:17
mongo.connection is not a function, it’s mongo.connect. HA
Angel Jaimes
@Haeguil
Aug 03 2016 03:17
Hi guys!
Robel Tesfaye
@Robel612
Aug 03 2016 03:18
Hello!
artimath
@artimath
Aug 03 2016 03:18
Ello @Haeguil @Robel612
Tyler Brown
@pelicanscarecrow
Aug 03 2016 03:18

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
var result = "My name is " + myNoun + " and I love candy. I am rather " + myAdjective + " for my kind. One time I" + myVerb + " very, very " + myAdverb + " from the police. "
// Your code above this line
return result;
}

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

For some reason this code does not check off "wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib)."
Does anyone see why?
artimath
@artimath
Aug 03 2016 03:19

use triple back ticks

like this

to show code

Tyler Brown
@pelicanscarecrow
Aug 03 2016 03:19
I figured it out
Ken Haduch
@khaduch
Aug 03 2016 03:20
@pelicanscarecrow - missing one space?
Robel Tesfaye
@Robel612
Aug 03 2016 03:21
Can anybody explain to me in thorough manner what the 'record collection' task is asking, because i'm a bit perplexed by FCC's explanation. Thanks in advance!
Jamie Lipschitz
@Jlipschitz
Aug 03 2016 03:22
@Robel612 personally I like the else if in this case for readability with counting cards
Robel Tesfaye
@Robel612
Aug 03 2016 03:23
I'm not sure whether to create a property called "tracks" or just pass in an argument to the parameter in the function called "tracks".
Ken Haduch
@khaduch
Aug 03 2016 03:23
@Robel612 - I have an explanation that I wrote, not sure if it will be helpful to you - but here it is (it might be a little out of date because they have updated the challenge, but I'll post it anyway) :
Working with the data that is given, several operations can be performed to add to, and modify, this data.
Each "album" is represented by a JavaScript object, and is indexed by an ID value, which is a numeric
 property that uniquely identifies the album.  Property values are passed as one of the function parameters,
indicating the property of an album to be modified, for example, to refer to information about the performing
artist, the property will be "artist".  A "value" parameter will also be passed as one of the function parameters.
If a value is given, the property should be added to the album object if it does not exist, or the current value
updated if the property already exists.  If the value that is passed in is blank, then the property should be
deleted.  If the property name that is specified is "tracks", and the value is blank, then the "tracks" property
should be deleted; otherwise, the new value (a new song title) should be added to the end of the "tracks"
array.
Justin Woodward
@jwoo92
Aug 03 2016 03:25
I am having a little bit of trouble playing around with setInterval() and clearInterval() while using on click calls if anyone would like to review my js code on my pomodoro clock and assist in providing feedback.
Ken Haduch
@khaduch
Aug 03 2016 03:26
@jwoo92 - I can take a quick look...
Robel Tesfaye
@Robel612
Aug 03 2016 03:26
@khaduch Thank you so much!
CamperBot
@camperbot
Aug 03 2016 03:26
robel612 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1506 | @khaduch |http://www.freecodecamp.com/khaduch
Angel Jaimes
@Haeguil
Aug 03 2016 03:27
Does it count as a problem if in the escape sequence challenge I placed the answer as such var myStr = "FirstLine\n\\SecondLine\\\rThirdLine";but the console shows it to me as just a block of text without the line break? It also didn't work in another computer I tried to do the challenger earlier on...
Haib Zhang
@nperhb
Aug 03 2016 03:29

hello,guys,I have a question.```
$(document).ready(function() {
var geo = new getGeolocation();
geo.setLocation();

setTimeout(function() {
    alert(geo.getCurrentLat());
},2000);

});

function getGeolocation() {

this.lat = "";
this.lon = "";

this.setLocation = function() {

    if(navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function(position) {
            this.lat = position.coords.latitude;
            this.lon = position.coords.longitude;

        });
    }


}

this.getCurrentLat = function() {
    return this.lat;
}

this.getCurrentLon = function() {
    return this.lon;
}

}

in the code ```if(navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(function(position) {
                this.lat = position.coords.latitude;
                this.lon = position.coords.longitude;

            });
        }

i think the problem is the wordthiserror,what word can replace?

Justin Woodward
@jwoo92
Aug 03 2016 03:30

@khaduch thank you Ken. Please note that my clock is in the very early stages and I am only focused on my timer function, play button, and pause button at the moment. I am aware of other issues I must correct. I can get my timer to begin when I click on my start button, but when I click on my pause button, my clearInterval() is not working as I hoped. I have been toying around with no luck so far.

http://codepen.io/jwoo/pen/AXQJEA/

line 14: timer function
line 73: start button on click call
line 81: pause button on click call

CamperBot
@camperbot
Aug 03 2016 03:30
jwoo92 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1507 | @khaduch |http://www.freecodecamp.com/khaduch
Haib Zhang
@nperhb
Aug 03 2016 03:31
This message was deleted
tannerkovach
@tannerkovach
Aug 03 2016 03:32
Anyone willing to help me with the Javascript lesson titled "Selecting from many options with Switch Statements"?
Ken Haduch
@khaduch
Aug 03 2016 03:34

@jwoo92 - while I'm waiting for your project to load, never mind, it loaded. A couple things that I see really quickly:

  • your code clock === setInterval(timer, 1000); you should only be using a single =. And the line after that clock; is not useful at all? That will probably fix the basic problem.

one other comment coming.

Justin Woodward
@jwoo92
Aug 03 2016 03:35
@khaduch very nice and such a simple correction. thank you again for looking into my project.
CamperBot
@camperbot
Aug 03 2016 03:35
jwoo92 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: jwoo92 already gave khaduch points
Ken Haduch
@khaduch
Aug 03 2016 03:37
@jwoo92 - here is a common problem, and one potential way to fix it. If I click on your Start button multiple times, multiple setInterval calls are made, and it makes the timer run away like crazy. There is no way to stop it. What you need to do is prevent multiple setInterval() calls from happening. I use the variable that you are capturing the setInterval return in, you named it clock, and test that for a non-zero value before allowing another call to setInterval(). The main thing that you have to remember, then is that after you call clearInterval(clock);, you have to set clock = 0; to properly maintain the state of that, so that you can re-start the timer.
Ba Ba K
@cyclops24
Aug 03 2016 03:37
Hi guys.
I need to limit the number of function call (execution) at the same time in javascript.
Can someone help me?
Ken Haduch
@khaduch
Aug 03 2016 03:39
@jwoo92 - another tip to simplify the counter operation is to keep your time value in seconds, that way you don't have to do any hairy calculations to see when you're crossing the minute boundaries - just keep the count of seconds, and write a function to output the time as mm:ss
Ba Ba K
@cyclops24
Aug 03 2016 03:39
For example I have a array and need to process all of this but I want process only five item from array at same time.
Justin Woodward
@jwoo92
Aug 03 2016 03:47
@khaduch I noticed that as well. I am deciding whether to do a hide/show between start and pause buttons to eliminate that or just create a disable feature where needed. also, you idea of writing a function for simply outputting mm:ss is a great idea! I do admit my current form is not that pretty. Thank you again for volunteering your time to review my clock.
CamperBot
@camperbot
Aug 03 2016 03:47
jwoo92 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: jwoo92 already gave khaduch points
comaeternal
@comaeternal
Aug 03 2016 03:49
var myStr = 'FirstLine\n\\SecondLine\\\r';//Change this line
What's wrong with my code?
llamatarianism
@llamatarianism
Aug 03 2016 03:49
@comaeternal you're missing the third line
comaeternal
@comaeternal
Aug 03 2016 03:50
@llamatarianism thanks
CamperBot
@camperbot
Aug 03 2016 03:50
comaeternal sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1110 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Andrew Kay
@andrewjkay
Aug 03 2016 03:52
General question: is lookup a type of object, or just something that can be done with an object?
llamatarianism
@llamatarianism
Aug 03 2016 03:53
@andrewjkay second one
Andrew Kay
@andrewjkay
Aug 03 2016 03:54
@llamatarianism thanks, that clears a lot up. Google turned up answers that were way over my head at this point. Thanks!
CamperBot
@camperbot
Aug 03 2016 03:54
andrewjkay sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1111 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
Aug 03 2016 03:54
keep in mind
objects in JS are often used a lot like hashmaps in other languages
in most languages they're separate concepts
Andrew Kay
@andrewjkay
Aug 03 2016 03:55
I'll keep that in mind moving foward
*forward
Aled Wassell
@aledwassell
Aug 03 2016 03:57

```
function findLongestWord(str) {
str.split(' ');
var longest = 0;
var longWord = null;
for (var i = 0; i < str.length; i++){
if (longest < str[i].length){
longest = str[i].length;
longWord = str[i];
}
}
return longWord;
}

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

function findLongestWord(str) {
  str.split(' ');
  var longest = 0;
  var longWord = null;
  for (var i = 0; i < str.length; i++){
    if (longest < str[i].length){
      longest = str[i].length;
      longWord = str[i];
    }
  }
  return longWord;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
ookay so I am trying to find the longest word here
I feel like I am on the road to getting there
Orv Bongat
@orvb
Aug 03 2016 03:59
@aledwassell not using str.split properly
Ba Ba K
@cyclops24
Aug 03 2016 04:01
I need to limit the number of function call (execution) at the same time in javascript.
For example I have a array and need to process all of this but I want process only five item from array at same time.
Can someone help me?
Amey Singh
@AmeySingh
Aug 03 2016 04:02

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

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

return collection;
}

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

Justin Woodward
@jwoo92
Aug 03 2016 04:02
@khaduch here is an update on the button issue you mentioned.
http://codepen.io/jwoo/pen/AXQJEA/
Aled Wassell
@aledwassell
Aug 03 2016 04:04
hey @AmeySingh use ``` these three ticks at the beginning of your code if you want to put it in a nice black box
Orv Bongat
@orvb
Aug 03 2016 04:04
@cyclops24 you want to process 5 items in the array one at a time or 5 items at the same time?
Aled Wassell
@aledwassell
Aug 03 2016 04:04

@AmeySingh like this ```
function findLongestWord(str) {
str.split(' ');
var longest = 0;
var longWord = null;
for (var i = 0; i < str.length; i++){
if (longest < str[i].length){
longest = str[i].length;
longWord = str[i];
}
}
return longWord;
}

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

oh no I screwed up
turns out, I don't know what I'm doing
Orv Bongat
@orvb
Aug 03 2016 04:05
lol, you can edit your post
pahosler
@pahosler
Aug 03 2016 04:06
@aledwassell just edit and put the backticks on lines by themselves
Orv Bongat
@orvb
Aug 03 2016 04:07
@jwoo92 nice pomodoro, looks great. one suggestion though, when the timer is already going and i hit pause, the "start" button should probably say something else like "resume" instead of "start"
Aled Wassell
@aledwassell
Aug 03 2016 04:07
thank you @pahosler
CamperBot
@camperbot
Aug 03 2016 04:07
aledwassell sends brownie points to @pahosler :sparkles: :thumbsup: :sparkles:
:cookie: 327 | @pahosler |http://www.freecodecamp.com/pahosler
Ba Ba K
@cyclops24
Aug 03 2016 04:07
@orvb 5 items at the same time.
Justin Woodward
@jwoo92
Aug 03 2016 04:07
@orvb that is a great idea, Thanks!
CamperBot
@camperbot
Aug 03 2016 04:07
jwoo92 sends brownie points to @orvb :sparkles: :thumbsup: :sparkles:
:cookie: 330 | @orvb |http://www.freecodecamp.com/orvb
Aled Wassell
@aledwassell
Aug 03 2016 04:08
and thanks @orvb
CamperBot
@camperbot
Aug 03 2016 04:08
aledwassell sends brownie points to @orvb :sparkles: :thumbsup: :sparkles:
:cookie: 331 | @orvb |http://www.freecodecamp.com/orvb
This is related to this stackoverflow question: http://stackoverflow.com/questions/38722616/using-async-in-meteor-1-3
Orv Bongat
@orvb
Aug 03 2016 04:09
@cyclops24 ah, you want to do it like that in parrallel without using that library?
Justin Woodward
@jwoo92
Aug 03 2016 04:10

@orvb updated with your suggestion:

http://codepen.io/jwoo/pen/AXQJEA/

Ba Ba K
@cyclops24
Aug 03 2016 04:10
I used async keyword and convert my function to async style but I want to limit rate.
Orv Bongat
@orvb
Aug 03 2016 04:10
@jwoo92 nice dude!
Ba Ba K
@cyclops24
Aug 03 2016 04:12

@orvb For example now My output is:

I20160803-08:17:00.009(4.5)? Process Start for: test
I20160803-08:17:00.010(4.5)? Process Start for: test2
I20160803-08:17:00.011(4.5)? Process Start for: test3
I20160803-08:17:00.011(4.5)? Process Start for: test4
I20160803-08:17:00.012(4.5)? Process Start for: test5
I20160803-08:17:00.012(4.5)? Process Start for: test6
I20160803-08:17:00.013(4.5)? Process Start for: test7
I20160803-08:17:00.014(4.5)? Process Start for: test8
I20160803-08:17:00.014(4.5)? Process Start for: test9
I20160803-08:17:00.015(4.5)? Process Start for: test10
I20160803-08:17:00.021(4.5)? Process Start for: test11
I20160803-08:17:00.022(4.5)? Process Start for: test12
I20160803-08:17:00.022(4.5)? Process Start for: test13
I20160803-08:17:00.022(4.5)? Process Start for: test14
I20160803-08:17:00.023(4.5)? Process Start for: test15
I20160803-08:17:00.023(4.5)? Process Start for: test16
I20160803-08:17:00.023(4.5)? Process Start for: test17
I20160803-08:17:00.023(4.5)? Process Start for: test18
I20160803-08:17:00.023(4.5)? Process Start for: test19
I20160803-08:17:00.024(4.5)? Process Start for: test20
I20160803-08:17:00.735(4.5)? Process Finished for: test8
I20160803-08:17:00.783(4.5)? Process Finished for: test16
I20160803-08:17:01.187(4.5)? Process Finished for: test6
I20160803-08:17:02.223(4.5)? Process Finished for: test7
I20160803-08:17:02.234(4.5)? Process Finished for: test14
I20160803-08:17:02.427(4.5)? Process Finished for: test9
I20160803-08:17:02.632(4.5)? Process Finished for: test3
I20160803-08:17:02.712(4.5)? Process Finished for: test19
I20160803-08:17:02.780(4.5)? Process Finished for: test4
I20160803-08:17:03.185(4.5)? Process Finished for: test
I20160803-08:17:03.280(4.5)? Process Finished for: test18
I20160803-08:17:03.579(4.5)? Process Finished for: test10
I20160803-08:17:03.786(4.5)? Process Finished for: test2
I20160803-08:17:04.118(4.5)? Process Finished for: test15
I20160803-08:17:04.289(4.5)? Process Finished for: test5
I20160803-08:17:05.607(4.5)? Process Finished for: test20
I20160803-08:17:05.702(4.5)? Process Finished for: test17
I20160803-08:17:07.251(4.5)? Process Finished for: test13
I20160803-08:17:07.658(4.5)? Process Finished for: test11
I20160803-08:17:09.805(4.5)? Process Finished for: test12

But I want something like this:

I20160803-08:17:00.009(4.5)? Process Start for: test
I20160803-08:17:00.010(4.5)? Process Start for: test2
I20160803-08:17:00.011(4.5)? Process Start for: test3
I20160803-08:17:00.011(4.5)? Process Start for: test4
I20160803-08:17:00.012(4.5)? Process Start for: test5
I20160803-08:17:00.735(4.5)? Process Finished for: test2
I20160803-08:17:00.012(4.5)? Process Start for: test6
I20160803-08:17:00.735(4.5)? Process Finished for: test5
I20160803-08:17:00.013(4.5)? Process Start for: test7
I20160803-08:17:00.735(4.5)? Process Finished for: test3
...
@orvb And this is my function:
 async heavyProcessSimulator(item) {
        console.log("Process Start for: " + item);
        Meteor._sleepForMs(Math.floor(Math.random() * 10000)); // some simple wait
        console.log("Process Finished for: " + item);
    }
Andrew Kay
@andrewjkay
Aug 03 2016 04:20
I need help with lookup. I'm not sure why this isn't working:

// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this lin

   val = {
    alpha:"Adams",
    bravo:"Boston",
    charlie:"Chicago",
    delta:"Denver",
    echo:"Easy",
    foxtrot:"Frank",
  };
  // Only change code above this line
}
// Change this value to test
phoneticLookup("charlie");
llamatarianism
@llamatarianism
Aug 03 2016 04:20
you're not returning anything
and you're reassigning val to the object
you're supposed to look up val inside that object
Andrew Kay
@andrewjkay
Aug 03 2016 04:21
It's supposed to be returning result but that didn't work either
val isn't in the object, the phonetic stuff is
oh
wait
what is this object even supposed to be a part of then? A new var?
llamatarianism
@llamatarianism
Aug 03 2016 04:23
yes
Andrew Kay
@andrewjkay
Aug 03 2016 04:24
so if I can only change code within those lines, how does the function access the new var?
llamatarianism
@llamatarianism
Aug 03 2016 04:24
what?
Andrew Kay
@andrewjkay
Aug 03 2016 04:25
I'm confused, but I think you mean that the object containing alpha, bravo, etc has to be a new var defined within the function
but I'm not sure how to get the information from the object into the console then, since I can't change the code above and below the comments
I'm about seven levels of confused right now so if this is gibberish I'm sure I'll see that eventually
Andrew Kay
@andrewjkay
Aug 03 2016 04:30
Screw it, I just changed the return line even though it said not to
@llamatarianism thanks for tolerating this nonsense!
CamperBot
@camperbot
Aug 03 2016 04:30
andrewjkay sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:warning: andrewjkay already gave llamatarianism points
Stephanie Chin
@stephaniejue
Aug 03 2016 04:34
@andrewjkay not sure if this helps... I got confused by the outisde pieces, but you're using the table to lookup the value and assign it to result
Does anyone know why myObj[checkProp] works and myObj.checkProp doesn't?
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
 if (myObj.hasOwnProperty(checkProp)== true) {
     return myObj[checkProp];
} else {
     return "Not Found";
     }
}

// Test your code by modifying these values
checkObj("gift");
Martialis39
@Martialis39
Aug 03 2016 04:39
@sjue Sorry im just jumping in
buw
but*, where is checkProp defined?
Norvin Burrus
@ndburrus
Aug 03 2016 04:41
@sjue
this may be helpful: :sparkles:
yoni chanowitz
@yonichanowitz
Aug 03 2016 04:45

HELP! i'm doing "Diff Two Arrays"

this is my code

function diff(arr1, arr2) {
  var a = [];

   for(var j = 0;j < arr2.length;j++){
 if(arr1.indexOf(arr2[j])===-1){
   a.push(arr2[j]);
 }}
 for(var i = 0;i < arr1.length;i++){
 if(arr2.indexOf(arr1[i])===-1){
   a.push(arr1[i]);
 }
 }
  // Same, same; but different.
  return a;
}

diff(["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]);

it should work, but doesnt

CamperBot
@camperbot
Aug 03 2016 04:45
no wiki entry for: im doing diff two arraysthis is my codefunction diffarr1 arr2 var a forvar j 0j arr2lengthj ifarr1indexofarr2j-1 apusharr2j forvar i 0i arr1lengthi ifarr2indexofarr1i-1 apusharr1i same same but different return adiffandesite grass dirt pink wool dead shrub diorite andesite grass dirt dead shrubit should work but doesnt
Justin Woodward
@jwoo92
Aug 03 2016 04:46
@yonichanowitz what is it you have to do?
Justin Steele
@JustinSteele02
Aug 03 2016 04:46
This was my solution for the Missing Letters intermediate algorithm challenge. It works but I'm just wondering if I have any "bad practice" in my code. Like for example should I have set str.charCodeAt(i) to a var instead of repeating it, does it matter? Anything else?
function fearNotLetter(str) {
  var undef = true;

  for (i = 0; i < str.length; i++) {
    if (str.charCodeAt(i + 1) - str.charCodeAt(i) > 1) {
      undef = false;
      return String.fromCharCode(str.charCodeAt(i) + 1);
    }
  }

  if (undef) {
    return undefined;
  }
}

fearNotLetter("abce");
Andrew Kay
@andrewjkay
Aug 03 2016 04:47
@sjue I think if you use dot notation it looks for checkProp in myObj instead of just taking the function value. I had the same problem
yoni chanowitz
@yonichanowitz
Aug 03 2016 04:47
@jwoo92 output an array with the items that are different in each of the two arrays passed to it
Justin Woodward
@jwoo92
Aug 03 2016 04:52
@yonichanowitz you could do a for loop inside of a for loop if you wanted.
Markus Kiili
@Masd925
Aug 03 2016 04:52
@sjue The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
Justin Woodward
@jwoo92
Aug 03 2016 04:53
@yonichanowitz find the largest array first then loop through each and compare through all of the second array. if not present, push into result array. i would believe this method would make sense in relation to how yours is set up currently.
silver537
@silver537
Aug 03 2016 04:54
@JustinSteele02 you can declare a variable inside the for loop that assigns and reassigns each iteration value into the variable. then an if statement that checks if that variable is equal to the next sequential number. if the value of the iteration skips the next sequential number, return that number(letter)
Stephanie Chin
@stephaniejue
Aug 03 2016 04:54
thanks all!
yoni chanowitz
@yonichanowitz
Aug 03 2016 04:55
@jwoo92 then it doesnt test the arrys individually. what it wants you to do is make a filter that finds what isnt in the other array and apply the filter to both arrays , then combine the results.
i chose to do it differently, but my results log correct, yet it doesn't let me pass
Justin Woodward
@jwoo92
Aug 03 2016 04:55
@yonichanowitz ohhh okay, my mistake.
what specifically is not passing?
yoni chanowitz
@yonichanowitz
Aug 03 2016 04:57
@jwoo92 any of them!
but when i log them to the console, i get the correct answer
Justin Woodward
@jwoo92
Aug 03 2016 04:57
@yonichanowitz okay, give me a moment and i will run your code through for you.
Markus Kiili
@Masd925
Aug 03 2016 04:59
@yonichanowitz The function name is wrong.
Justin Woodward
@jwoo92
Aug 03 2016 04:59
@yonichanowitz worked for me first try.
@yonichanowitz @Masd925 yes, your function name is incorrect.
silver537
@silver537
Aug 03 2016 05:00
@JustinSteele02 we know the exact number value at the 0 index of the str. so all we have to do is add 1 to that number to make sure the next value is sequential. for example A = 65, B = 66. C = 67. etc etc. if the variable(which is assigned to the iteration value i.e str.charCodeAt(i)) is NOT equal to the (str index at 0 + i) return the missing value.
Justin Steele
@JustinSteele02
Aug 03 2016 05:03
@silver537 Ah I understand, thanks! So is that technique more correct in some way than the code I currently have?
CamperBot
@camperbot
Aug 03 2016 05:03
justinsteele02 sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 457 | @silver537 |http://www.freecodecamp.com/silver537
yoni chanowitz
@yonichanowitz
Aug 03 2016 05:04
@jwoo92 @Masd925 ,what should it be?
Justin Woodward
@jwoo92
Aug 03 2016 05:04
@yonichanowitz function diffArray(arr1, arr2) {
yoni chanowitz
@yonichanowitz
Aug 03 2016 05:05
thanks @jwoo92
CamperBot
@camperbot
Aug 03 2016 05:05
yonichanowitz sends brownie points to @jwoo92 :sparkles: :thumbsup: :sparkles:
:cookie: 402 | @jwoo92 |http://www.freecodecamp.com/jwoo92
yoni chanowitz
@yonichanowitz
Aug 03 2016 05:06
thanks @Masd925
CamperBot
@camperbot
Aug 03 2016 05:06
yonichanowitz sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2220 | @masd925 |http://www.freecodecamp.com/masd925
silver537
@silver537
Aug 03 2016 05:06
@JustinSteele02
for(var x = 0; x < str.length; x++){
    var char = str.charCodeAt(x);  // assigns the iteration value a, b, c, or e = 97, 98, 99 , 101
    if(char !== str.charCodeAt(0)+x){  //if the variable does not equal to the first index + i: 97 + the current iteration number (0, 1, 2, 3)
      return String.fromCharCode(char-1);  // return the code of the failed variable test - 1.  in this case: 101 - 1
    }
  }
Justin Woodward
@jwoo92
Aug 03 2016 05:07
@yonichanowitz goodluck on the next one, it was the hardest one for me.
yoni chanowitz
@yonichanowitz
Aug 03 2016 05:07
@jwoo92 i've been at that for the past 5 days
Justin Woodward
@jwoo92
Aug 03 2016 05:08
@yonichanowitz sounds normal to me, i spent maybe a little over a week off and on to get it.
Justin Steele
@JustinSteele02
Aug 03 2016 05:09
@silver537 right, gotcha, you explained it very well. But is doing it the way you're describing better for any other reason besides that it obviously uses less code? Either way, I like your solution much better
Justin Woodward
@jwoo92
Aug 03 2016 05:09
@yonichanowitz mine was ugly and took 51 lines, but it got the job done.
silver537
@silver537
Aug 03 2016 05:10
you code wasn't very DRY, which you pointed out yourself. but in the end if it works, it works lol
@JustinSteele02
Justin Steele
@JustinSteele02
Aug 03 2016 05:11
alright cool. but yeah that's an ingenious solution @silver537 . Very nice I think
Ivan Aganin
@criativ
Aug 03 2016 05:14
Hello, I started to make "Validate US Telephone Numbers" thing - where should I start? :)
silver537
@silver537
Aug 03 2016 05:15
start of with regex
Justin Steele
@JustinSteele02
Aug 03 2016 05:15
@criativ with a US phone number regex?
silver537
@silver537
Aug 03 2016 05:15
checking out the validations they give you
its a tricky one
Ivan Aganin
@criativ
Aug 03 2016 05:17
@JustinSteele02 So in basic RegExp - removes everything you say it, and leaves everything else? :) I just remove letters and simbols and see does it match a Number?
silver537
@silver537
Aug 03 2016 05:17
no. you use the regex test method. /asdf/.test(str)
it will return true if it validates. or false is it doesn't
Justin Steele
@JustinSteele02
Aug 03 2016 05:18
@criativ I'm not the best person to explain, just starting to get a better handle of regex myself. But a regex simply matches what you tell it to, it doesn't automatically remove anything
silver537
@silver537
Aug 03 2016 05:18
it should only be one line really. return /numberchecker/.test(str);
inside numberchecker is the regex obviously hehe
Broozius
@Brucius
Aug 03 2016 05:19
hey guys there's another code testing website besides jsfiddle right
what's the name I forgot
Ivan Aganin
@criativ
Aug 03 2016 05:19
@silver537 @JustinSteele02 ok, thanks for your help... I'll get right on it :)
CamperBot
@camperbot
Aug 03 2016 05:19
criativ sends brownie points to @silver537 and @justinsteele02 :sparkles: :thumbsup: :sparkles:
:cookie: 458 | @silver537 |http://www.freecodecamp.com/silver537
:cookie: 367 | @justinsteele02 |http://www.freecodecamp.com/justinsteele02
Justin Steele
@JustinSteele02
Aug 03 2016 05:19
Regex is just a set of symbols that matches patterns in text. you have to use methods like test to determine what you want to do with the regex
Ivan Aganin
@criativ
Aug 03 2016 05:19
@JustinSteele02 got it
Justin Steele
@JustinSteele02
Aug 03 2016 05:20
I've never used this site but seen it recommended. Maybe it will help you @criativ http://regexone.com/
silver537
@silver537
Aug 03 2016 05:20
@criativ ill give you a hint.
return /[]-[]-[]/.test(str)
Ivan Aganin
@criativ
Aug 03 2016 05:20
@silver537 :)
silver537
@silver537
Aug 03 2016 05:21
@OakerMin as in javascript testing?
Broozius
@Brucius
Aug 03 2016 05:21
yeah just to console log some code snippets
@silver537
silver537
@silver537
Aug 03 2016 05:22
repl.it
Broozius
@Brucius
Aug 03 2016 05:22
oh yes!! that's the one @silver537 thanks m8
CamperBot
@camperbot
Aug 03 2016 05:22
oakermin sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 459 | @silver537 |http://www.freecodecamp.com/silver537
my favorite fucking site.
Broozius
@Brucius
Aug 03 2016 05:23
I KNOW! @silver537
silver537
@silver537
Aug 03 2016 05:23
imma go to sleep before someone bitches about my language. pussies. >.>
Richard Sithole
@Sliqric7053
Aug 03 2016 05:28
@sjue in order to traverse an object (or select its propety) which is assigned to a variable (myObjin your case), instead of dot notation, you must use [bracket ] notation for it to work.
Ismael Sanchez
@sanchez1179
Aug 03 2016 05:36
Hello everyone I am having trouble with the Using Objects for Lookups portion of JavaScript I have the table created but it isn't called anywhere
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 05:39
@sanchez1179 could you paste your code?
Jaren Escueta
@jarenescueta731
Aug 03 2016 05:43
hi can someone help me understand why adding <p> inside a <div> will change the div's position?
codepen for reference, it's the purple div that moves inside the calculator display when i add <p>:
http://codepen.io/jarenescueta/pen/vKaZxz
un-commenting the <p> in the html will move the div
Ismael Sanchez
@sanchez1179
Aug 03 2016 05:46

// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup = {
"alpha":"Adam",
"bravo":"Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot":"Frank"
};

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

// Change this value to test
phoneticLookup("charlie");

@stonefmagiecurata sorry for the delay I thought I had sent it earlier but did not press enter
Markus Kiili
@Masd925
Aug 03 2016 05:49
@sanchez1179 Access the object with syntax obj[key] and assign it to result variable.
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 05:49
@sanchez1179 you need to change the value of result,
Ramesh syangtan
@rameshsyn
Aug 03 2016 05:50
@jarenescueta731 <p> has default margin of 1em
venkateswar
@Vikavenkat
Aug 03 2016 05:50
hi frnds need help ...
Ramesh syangtan
@rameshsyn
Aug 03 2016 05:50
@Vikavenkat :D
Jaren Escueta
@jarenescueta731
Aug 03 2016 05:50
@rameshsyn so i just set margin: 0; ?
Ramesh syangtan
@rameshsyn
Aug 03 2016 05:50
yes
venkateswar
@Vikavenkat
Aug 03 2016 05:51
y dude how to do this convert celsius to fahrenheit pgm in js
Jaren Escueta
@jarenescueta731
Aug 03 2016 05:51
@rameshsyn thank you for responding
CamperBot
@camperbot
Aug 03 2016 05:51
jarenescueta731 sends brownie points to @rameshsyn :sparkles: :thumbsup: :sparkles:
:cookie: 753 | @rameshsyn |http://www.freecodecamp.com/rameshsyn
Ismael Sanchez
@sanchez1179
Aug 03 2016 05:51
@Masd925 oh ok the object is the phoneticLookup and the key is the lookup table?
Ramesh syangtan
@rameshsyn
Aug 03 2016 05:52
@jarenescueta731 w/c
#expression p {
  margin: 0;
}
Jaren Escueta
@jarenescueta731
Aug 03 2016 05:53
@rameshsyn thank you
CamperBot
@camperbot
Aug 03 2016 05:53
jarenescueta731 sends brownie points to @rameshsyn :sparkles: :thumbsup: :sparkles:
:warning: jarenescueta731 already gave rameshsyn points
Ismael Sanchez
@sanchez1179
Aug 03 2016 05:53

// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup = {
"alpha":"Adam",
"bravo":"Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot":"Frank"
};
result = phoneticLookup[val];

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

// Change this value to test
phoneticLookup("charlie");

@Masd925 still nothing
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 05:53
@sanchez1179 the object is the lookup
venkateswar
@Vikavenkat
Aug 03 2016 05:54
Thank u @rameshsyn
CamperBot
@camperbot
Aug 03 2016 05:54
vikavenkat sends brownie points to @rameshsyn :sparkles: :thumbsup: :sparkles:
:cookie: 754 | @rameshsyn |http://www.freecodecamp.com/rameshsyn
Ramesh syangtan
@rameshsyn
Aug 03 2016 05:54
@Vikavenkat here is formula to convert celsius to fahrnheti
T(°F) = T(°C) × 9/5 + 32
Ismael Sanchez
@sanchez1179
Aug 03 2016 05:54
@stonefmagiecurata @Masd925 OMG thank you so much got it now phew
CamperBot
@camperbot
Aug 03 2016 05:54
sanchez1179 sends brownie points to @stonefmagiecurata and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @stonefmagiecurata |http://www.freecodecamp.com/stonefmagiecurata
:star2: 2221 | @masd925 |http://www.freecodecamp.com/masd925
venkateswar
@Vikavenkat
Aug 03 2016 05:54
thank u@ramesh
stonefmagiecurata
@stonefmagiecurata
Aug 03 2016 05:55
@sanchez1179 the phoneticLookup is the function which takes a parameter, in this case the parameter will be one of the properties of your lookup object, with this function you'll return the value of that property
@sanchez1179 :+1:
Stanislav
@stasizon
Aug 03 2016 06:10
Hi, i have a little problem with Check for Palindromes. In console.log "almostomla" return false but the test does not pass the word. Can anyone help?
jamesmillerho
@jamesmillerho
Aug 03 2016 06:15
@stasizon post your code?
Stanislav
@stasizon
Aug 03 2016 06:17
@jamesmillerho simply insert the chat?
raditya putranto
@radityaputranto
Aug 03 2016 06:20
@stasizon use (```) for copy your code in chat
Stanislav
@stasizon
Aug 03 2016 06:20
function palindrome(str) {

  var changedStr = str.toLowerCase().replace(/[\W\s_]+/gi, '');
  var strLength = changedStr.length;

  function getFirstStrPart() {

    var firstStrPart = [];

    for (var i = 0; i < Math.floor(strLength/2); i++) {
      firstStrPart.push(changedStr[i]);
    }

    return firstStrPart.join('');

  }


  function getSecondStrPart() {

    var secondStrPart = [];

    var reversed = changedStr.split('').reverse();

    for (var i = 0; i < Math.floor(strLength/2); i++) {
      secondStrPart.push(reversed[i]);
    }

    return secondStrPart.join('');

  }

   console.log(str, getFirstStrPart() == getSecondStrPart());

  if (changedStr === "" || changedStr[changedStr.length - 1] != changedStr[0]) {
    return false;
  } else if (getFirstStrPart() == getSecondStrPart()) {
    return true;
  }

}



palindrome("almostomla");
CamperBot
@camperbot
Aug 03 2016 06:20
:bulb: to format code use backticks! ``` more info
raditya putranto
@radityaputranto
Aug 03 2016 06:21
hi, i want ask about golf code
this is my code
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!";
  }
jamesmillerho
@jamesmillerho
Aug 03 2016 06:22
@radityaputranto there is a reverse function to reverse an array. You turn a string into an array, reverse it , then turn it back to string
raditya putranto
@radityaputranto
Aug 03 2016 06:23
@jamesmillerho so i need declare an array and use push / shift and turn it to string ,right?
@jamesmillerho or i just use if else statment ?
jamesmillerho
@jamesmillerho
Aug 03 2016 06:24
@stasizon I think you don't need \s in regex
@radityaputranto str.split("") = array
@stasizon there is a reverse function to reverse an array. You turn a string into an array, reverse it , then turn it back to string
Andrew Kay
@andrewjkay
Aug 03 2016 06:27
This message was deleted
This message was deleted
Justin Woodward
@jwoo92
Aug 03 2016 06:28
@andrewjkay where is your comma?
Andrew Kay
@andrewjkay
Aug 03 2016 06:28
Yup just realized, thanks @jwoo92
CamperBot
@camperbot
Aug 03 2016 06:28
andrewjkay sends brownie points to @jwoo92 :sparkles: :thumbsup: :sparkles:
:cookie: 404 | @jwoo92 |http://www.freecodecamp.com/jwoo92
Justin Woodward
@jwoo92
Aug 03 2016 06:28
@andrewjkay Anytime :)
raditya putranto
@radityaputranto
Aug 03 2016 06:28
@jamesmillerho ok than you for your suggestion
@jamesmillerho i mean thanks
CamperBot
@camperbot
Aug 03 2016 06:29
radityaputranto sends brownie points to @jamesmillerho :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @jamesmillerho |http://www.freecodecamp.com/jamesmillerho
Justin Woodward
@jwoo92
Aug 03 2016 06:31
@stasizon are you still stuck?
@radityaputranto did you solve your issue?
jamesmillerho
@jamesmillerho
Aug 03 2016 06:31

@stasizon
I changed the last part of your code to

  if (getFirstStrPart() == getSecondStrPart()) {
    return true;
  }
  return false;

And it works fine

Daleon L
@Allwaysawake
Aug 03 2016 06:37
Ok so for Accessing Nested Objects what seems to be the problem on this

// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

myStorage.car.inside ["glove box"];
var gloveBoxContents = "maps";

jamesmillerho
@jamesmillerho
Aug 03 2016 06:39
myStorage.car.inside ["glove box"]; strictly no space between
@Allwaysawake myStorage.car.inside ["glove box"]; strictly no space between "inside" and "["glove box"]"
And var gloveBoxContents = myStorage.car.inside["glove box"]
Daleon L
@Allwaysawake
Aug 03 2016 06:40
no space
wow I missed that completely
Darth Skywalker
@adityaparab
Aug 03 2016 06:40

@Allwaysawake : Just a note,

if you type

```js
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

myStorage.car.inside ["glove box"];
var gloveBoxContents = "maps";
```

It will be displayed as

var myStorage = {
    "car": {
        "inside": {
            "glove box": "maps",
            "passenger seat": "crumbs"
        },
        "outside": {
            "trunk": "jack"
        }
    }
};

// Only change code below this line

myStorage.car.inside ["glove box"];
var gloveBoxContents = "maps";
Daleon L
@Allwaysawake
Aug 03 2016 06:45
Thanks @jamesmillerho and @adityaparab but still no Bueno
CamperBot
@camperbot
Aug 03 2016 06:45
allwaysawake sends brownie points to @jamesmillerho and @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 461 | @adityaparab |http://www.freecodecamp.com/adityaparab
:cookie: 309 | @jamesmillerho |http://www.freecodecamp.com/jamesmillerho
Daleon L
@Allwaysawake
Aug 03 2016 06:46

// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

myStorage.car.inside["glove box"];
var gloveBoxContents="maps";
venkateswar
@Vikavenkat
Aug 03 2016 06:46
send that pgm code
jamesmillerho
@jamesmillerho
Aug 03 2016 06:46
@Allwaysawake
Just
var gloveBoxContents = myStorage.car.inside["glove box"];
so it will automatically be "maps"
just 1 line
venkateswar
@Vikavenkat
Aug 03 2016 06:47
convert Celsius to Fahrenheit
Darth Skywalker
@adityaparab
Aug 03 2016 06:47
A pgm code?
venkateswar
@Vikavenkat
Aug 03 2016 06:47
hmm
Darth Skywalker
@adityaparab
Aug 03 2016 06:47
What's a pgm code?
venkateswar
@Vikavenkat
Aug 03 2016 06:48
convert Celsius to Fahrenheit
???
Darth Skywalker
@adityaparab
Aug 03 2016 06:48
yeah but what does pgm mean? and what does it have anything to do with convert celsius to fahrenheit
?
venkateswar
@Vikavenkat
Aug 03 2016 06:49
pgm is nothing means programm
Darth Skywalker
@adityaparab
Aug 03 2016 06:49
geez! okay :D
venkateswar
@Vikavenkat
Aug 03 2016 06:49
i need that pgm coding will u help me
Daleon L
@Allwaysawake
Aug 03 2016 06:49
@jamesmillerho ok that work but why couldn't we do that with a call function
Darth Skywalker
@adityaparab
Aug 03 2016 06:50
@Vikavenkat
function convertToF(celsius) {
  // Only change code below this line
  return (celsius * (9/5)) + 32;
  // Only change code above this line
}
jamesmillerho
@jamesmillerho
Aug 03 2016 06:50
@Allwaysawake we want to store the specific data in a variable, so just var XXX = XXX
venkateswar
@Vikavenkat
Aug 03 2016 06:50
hmm k i will try out
Daleon L
@Allwaysawake
Aug 03 2016 06:51
Gotcha thanks again man
@jamesmillerho
Norvin Burrus
@ndburrus
Aug 03 2016 06:52
@Vikavenkat :sparkles:
The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
we can rewrite the equation/formula to: Fahrenheit is (=) Celsius times() 9/5, plus (+) 32.
which is F = C
9/5 + 32,
or F = C(9/5) + 32.
alright, so we need to convert this formula to code!
Darth Skywalker
@adityaparab
Aug 03 2016 06:54
@ndburrus : Correct. I believe that is what I did
oh! Alright. you wanted to tag @Vikavenkat
Norvin Burrus
@ndburrus
Aug 03 2016 06:54
@adityaparab sorry, corrected post :+1:
jamesmillerho
@jamesmillerho
Aug 03 2016 06:56
so besides freecodecamp I should now start writing a blog and building up github portfolio
Daleon L
@Allwaysawake
Aug 03 2016 07:01
@jamesmillerho you should....!
@jamesmillerho you got my follow
I have to make another portfolio for my graphic design and my web coding I am not to sure if to just fuse em together
jamesmillerho
@jamesmillerho
Aug 03 2016 07:05
It can be together
any website is a combination of design + coding
Ghost
@ghost~575e5a9bc2f0db084a1d8e8b
Aug 03 2016 07:10

i am stuck with this challenge https://www.freecodecamp.com/challenges/record-collection

i don't know where is my mistake here is my code thanks for your help:


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

// Only change code below this line
function updateRecords(id, prop, value) {

  if(value === ""){
    delete collection[id][prop];
  }
  else if(prop === "tracks"){
    if(collection[id].hasOwnProperty("tracks")){
      collection[id][prop].push(value);
    }
    else{
      collection[id][prop] = [];
      colection[id][prop].push(value);
    }
  }
  else{
    collection[id][prop] = value;
  }
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
LaurenCodes
@LaurenCodes
Aug 03 2016 07:10
Anyone here working on react? =)
0b4cL
@0b4cL
Aug 03 2016 07:10
Can anyone explain how var myData = myArray[2][1]; equals 8?
Ghost
@ghost~575e5a9bc2f0db084a1d8e8b
Aug 03 2016 07:11
@0b4cL which challenge are you working on ?
0b4cL
@0b4cL
Aug 03 2016 07:12
Access MultiDimensional Arrays With Indexes I passed it but I don't know why.
Darth Skywalker
@adityaparab
Aug 03 2016 07:13
@0b4cL : What is your myArray ? Share code here
@LaurenCodes : I work on real IRL. Haven't started with React Challenges here yet but I know it pretty well.
0b4cL
@0b4cL
Aug 03 2016 07:13
var myData = myArray[2][1];
Darth Skywalker
@adityaparab
Aug 03 2016 07:14
@0b4cL : Not that.. You must have declare var myArray = .... somewhere
0b4cL
@0b4cL
Aug 03 2016 07:14
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
Mark Todd
@Knochenmark
Aug 03 2016 07:15
@0b4cL haha probably because the array in index 2 hast an 8 at index 1 :D
0b4cL
@0b4cL
Aug 03 2016 07:15
Damn.....
Mark Todd
@Knochenmark
Aug 03 2016 07:15
[7,8,9] because of the 8 at index 1
Darth Skywalker
@adityaparab
Aug 03 2016 07:15

@0b4cL :

Just a note, if you type

```js
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
```

it will be shown as

var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
0b4cL
@0b4cL
Aug 03 2016 07:15
Might be time for bed soon:) Thanks a million.
Mark Todd
@Knochenmark
Aug 03 2016 07:15
@0b4cL indices start at 0, remember that :P
0b4cL
@0b4cL
Aug 03 2016 07:16
I will. As usual, operator error.
Mark Todd
@Knochenmark
Aug 03 2016 07:17
@0b4cL myArray[3][0][1] is?
tasovacm
@tasovacm
Aug 03 2016 07:17
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
Ghost
@ghost~575e5a9bc2f0db084a1d8e8b
Aug 03 2016 07:18

anyoni am stuck with this challenge https://www.freecodecamp.com/challenges/record-collection

i don't know where is my mistake here is my code thanks for your help:


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

// Only change code below this line
function updateRecords(id, prop, value) {

  if(value === ""){
    delete collection[id][prop];
  }
  else if(prop === "tracks"){
    if(collection[id].hasOwnProperty("tracks")){
      collection[id][prop].push(value);
    }
    else{
      collection[id][prop] = [];
      colection[id][prop].push(value);
    }
  }
  else{
    collection[id][prop] = value;
  }
  return collection;
}

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

any help ?

Darth Skywalker
@adityaparab
Aug 03 2016 07:18

@0b4cL

Take a look at this


var myArray = [
    [1,2,3], //myArray[0]
    [4,5,6], //myArray[1]
    [7,8,9], // myArray[2]
     [             //myArray[3]
        [10,11,12], //myArray[3][0]
        13,               //myArray[3][1]
        14                //myArray[3][2]
      ]
];

So myArray[2] will be [7,8,9] and [7,8,9][1] will be 8

peibowl
@peibowl
Aug 03 2016 07:19
Hello, can anyone tell me why it is advising me about a possible infinite loop here???
jamesmillerho
@jamesmillerho
Aug 03 2016 07:19
@tasovacm array.shift() <- this, itself, means the first element of the array being removed.
So if you type
return array.shift();
It will return the removed element
peibowl
@peibowl
Aug 03 2016 07:19
function sumAll(arr) {
  var max = Math.max(...arr);
  var min = Math.min(...arr);
  var sum = 0;
  for (min; min++; min == max){
    sum += min;
  }
  return sum;
}
Darth Skywalker
@adityaparab
Aug 03 2016 07:20
@peibowl : The code is not correct.
peibowl
@peibowl
Aug 03 2016 07:20
why not?
where is the error?
Mark Todd
@Knochenmark
Aug 03 2016 07:20
@gimyboya could be an ordering problem, try to change the else if with else. kinda like if prop !== "tracks" just set value, and in else the track handling
Darth Skywalker
@adityaparab
Aug 03 2016 07:21
Run it, and you'll see.
@peibowl
peibowl
@peibowl
Aug 03 2016 07:21
I see that the browser crashes
but I do not understand why
jamesmillerho
@jamesmillerho
Aug 03 2016 07:21
@peibowl
for (var i=min; i<= max; i++){
sum += i;
}
Ghost
@ghost~575e5a9bc2f0db084a1d8e8b
Aug 03 2016 07:21
@Knochenmark okay noted thank you i will try it
CamperBot
@camperbot
Aug 03 2016 07:21
gimyboya sends brownie points to @knochenmark :sparkles: :thumbsup: :sparkles:
:cookie: 381 | @knochenmark |http://www.freecodecamp.com/knochenmark
peibowl
@peibowl
Aug 03 2016 07:22
lol, its just the order in the for loop!
Mark Todd
@Knochenmark
Aug 03 2016 07:22
@peibowl try resetting browser cache, had this issue too
peibowl
@peibowl
Aug 03 2016 07:23
thanks @jamesmillerho
CamperBot
@camperbot
Aug 03 2016 07:23
peibowl sends brownie points to @jamesmillerho :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @jamesmillerho |http://www.freecodecamp.com/jamesmillerho
Mark Todd
@Knochenmark
Aug 03 2016 07:23
@peibowl you might want to look into .reduce()
ZZPot
@ZZPot
Aug 03 2016 07:23
I have a function and I want to call it when data will be recieved. How to do it with .getJSON?
peibowl
@peibowl
Aug 03 2016 07:23
.reduce does not make sense to me
to use reduce first I need to build an array
and I can calculate the result while I build it, so it is redundant work, I think
jamesmillerho
@jamesmillerho
Aug 03 2016 07:24
@peibowl
or
while (min !== max){
    sum += min;
    min += 1;
  }
  return sum + max;
:D
Darth Skywalker
@adityaparab
Aug 03 2016 07:24

@peibowl

First this is syntax error

var max = Math.max(...arr);
var min = Math.min(...arr);

what is ...??? :smile:

it Should be
var max = Math.max.apply(null,arr);
var min = Math.min.apply(null,arr);
peibowl
@peibowl
Aug 03 2016 07:24
there is not sintax error, it returns the min and the max correctly
Mark Todd
@Knochenmark
Aug 03 2016 07:25
@adityaparab ... is ES6 syntax to split the arguments into an array
peibowl
@peibowl
Aug 03 2016 07:25
... its the spread operator as I have read
Darth Skywalker
@adityaparab
Aug 03 2016 07:25
Then your for loop is wrong
@peibowl : Spread operators are ES6 contructs.For ES5 syntax, ... is an error
Mark Todd
@Knochenmark
Aug 03 2016 07:25
function sumAll(arr) {
  arr.sort(function(a,b){
    return a>b;
  });
  var min = arr[0];
  var max = arr[1];
  return Array.apply(null, Array(max-min+1)).map(function (el, index) { 
    return min+index; 
  }).reduce(function(curr,prev){
    return curr+prev;
  });
}
Darth Skywalker
@adityaparab
Aug 03 2016 07:27

@Knochenmark

@adityaparab ... is ES6 syntax to split the arguments into an array

Even if that is correct, Math.max doesn't work on an array. If you pass array to Math.max you will get NaN

Mark Todd
@Knochenmark
Aug 03 2016 07:28
@adityaparab yeah i noticed that when i saw the challenge again
smdevpod
@smdevpod
Aug 03 2016 07:28
hey, I was wondering if someone could help me how to write my own logging in mongoddb?
Darth Skywalker
@adityaparab
Aug 03 2016 07:28
@smdevpod : Shoot
jamesmillerho
@jamesmillerho
Aug 03 2016 07:28
@adityaparab what's the difference between xx() and xx.apply()?
For example:
array.unshift("")
array.unshift.apply("","")
?
Darth Skywalker
@adityaparab
Aug 03 2016 07:29
@jamesmillerho : It will be a pain in the ass to explain it over chat :sweat_smile:
jamesmillerho
@jamesmillerho
Aug 03 2016 07:29
lol
smdevpod
@smdevpod
Aug 03 2016 07:29
@adityaparab I dont understand logging as I have never worked with it before, so what would be a good place to achieve this - the problem being here http://stackoverflow.com/questions/38480041/create-your-own-log-files-in-mongodb-node-js
Darth Skywalker
@adityaparab
Aug 03 2016 07:29
Hold on I'll create a tutorial in the evening
jamesmillerho
@jamesmillerho
Aug 03 2016 07:29
evening
1 pm in pune now
Darth Skywalker
@adityaparab
Aug 03 2016 07:30
I'm in IST to it's 1pm here and I'm in office
yes
@smdevpod : Logging is nothing but you need to keep track of what's your application has do so far.
Claudio Restifo
@Marmiz
Aug 03 2016 07:30
@ZZPot .getJson method accepts a callback parameter, so simply call your function.
Something like this:
$.getJSON("url",  function(json) {
 myFunction()  // feel free to pass every data you need
});
Darth Skywalker
@adityaparab
Aug 03 2016 07:30
You usually log your requests and response data in a text file
let me read your SO question
smdevpod
@smdevpod
Aug 03 2016 07:31
how to you log these requests and repsonses?
ZZPot
@ZZPot
Aug 03 2016 07:32
@Marmiz without inplace definition
Darth Skywalker
@adityaparab
Aug 03 2016 07:32
@smdevpod : I need more info.
What are you using Node/Express? Or some other language?
also, why do you want to store logs in the db? Logs better be stored in a text file.
Claudio Restifo
@Marmiz
Aug 03 2016 07:33
@ZZPot what do you mean by that?
Is your function defined somewhere else?
0b4cL
@0b4cL
Aug 03 2016 07:33
@adityaparab I get it now. So if it was [2], [0] the answer would be 7.
ZZPot
@ZZPot
Aug 03 2016 07:33
@Marmiz I have a function and i don't want to copy code
Darth Skywalker
@adityaparab
Aug 03 2016 07:34
@0b4cL : Correct
ZZPot
@ZZPot
Aug 03 2016 07:34
I already have function
is it hard to set a pointer to function?
tannerkovach
@tannerkovach
Aug 03 2016 07:34
Trouble with Counting Cards: what am I missing here?

var count = 0;

function cc(card) {
// Only change code below this line
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
var count = count + 1;
break;
case 7:
case 8:
case 9:
var count = count + 0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
var count = count - 1;
}
if (count < 0) {
console.log(count + " " + "Hold");
} else if (count > 0) {
console.log(count + " " + "Bet");

}else{
console.log("Hold");
}

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

ZZPot
@ZZPot
Aug 03 2016 07:34
Has javascript something like this?
jamesmillerho
@jamesmillerho
Aug 03 2016 07:34
sum all number in range a to b
( b (b+1) - a (a-1) ) /2
works magically
smdevpod
@smdevpod
Aug 03 2016 07:36
@adityaparab sure, so I am basically creating a monitoring app, that allows me to ping a api and get the data back (i.e. cpu, server name, etc etc), and iI store these value sin the dbs. Then the same call is done againn on 30 seconds, and any values that are changed I override them. But when a server is down, their values are not stored. So i want to create log files which log every call to the api, and return the date, time, success/error (if server is down) etc - I dont really know what to put in thes log files as I never done anything liek this before. They dont have to be stored in mongo, but I thought it would be easier and then to just extract them
Darth Skywalker
@adityaparab
Aug 03 2016 07:37
@smdevpod : Yes but what technology are you using to write your API?
Claudio Restifo
@Marmiz
Aug 03 2016 07:37
@ZZPot In my example I wasn't declaring a new function.
var myFunc = function() {
    //do something
}

$.getJSON("url", function(result){
            myFunc()   // this will call my function into action.
            });
ZZPot
@ZZPot
Aug 03 2016 07:39
ha
overvoding, I think
but this is javascript
damn
smdevpod
@smdevpod
Aug 03 2016 07:39
@adityaparab write my API? I am calling an API and just saving the response form it. I am using node js
ZZPot
@ZZPot
Aug 03 2016 07:39
overcoding*
Claudio Restifo
@Marmiz
Aug 03 2016 07:41
@tannerkovach Do you realize that you're calling the data on the console instead of returning it?
smdevpod
@smdevpod
Aug 03 2016 07:43
@adityaparab I was thinking to use the winston package for logging in node js? Any idea if that is a good move?
Claudio Restifo
@Marmiz
Aug 03 2016 07:44
@ZZPot be sure to check the documentation:
http://api.jquery.com/jQuery.getJSON/
Norvin Burrus
@ndburrus
Aug 03 2016 07:44
@tannerkovach why declare count (using var) multiple times? also the return should output (not just to the console). finally, the return should include 2 parts: the count and the play/ing action (bet/hold).
jadczakd
@jadczakd
Aug 03 2016 07:46
Hey guys! I am lost at this exercise - Stand in Line
ZZPot
@ZZPot
Aug 03 2016 07:46
@Marmiz what for? I don't understand more of it
most*
jadczakd
@jadczakd
Aug 03 2016 07:46
Ah, forget it I think I have it.
Claudio Restifo
@Marmiz
Aug 03 2016 07:47
@ZZPot We are here for this. What's the part you don't get?
Norvin Burrus
@ndburrus
Aug 03 2016 07:47
@jadczakd can you post?
Zhou-Jia-Heng
@Zhoujiaheng
Aug 03 2016 07:48

var x=(new Date()).getTime();
var t=setInterval(function(){
moveL();
},5000);
$(".mslide_content_box").hover(function(){
clearInterval(t);
},function(){
var b=new Date();
var y=b.getTime();
if((y-x)>=5000){
setTimeout(moveL);
}else{
setTimeout(moveL,5000-(y-x));
}
})

How to make y value only the last? Who knows?

ZZPot
@ZZPot
Aug 03 2016 07:48
@Marmiz everything
There is no calling getJson from getjson
and I don't know how to get an error message or error number to search for answer
firebug said that I make only one call
yeah, it successful
Claudio Restifo
@Marmiz
Aug 03 2016 07:49
@ZZPot can we see what you got? It's easier for us :D
ZZPot
@ZZPot
Aug 03 2016 07:52
ok, I can't get json beacuse of second getjson
from browser it's ok
maybe this again this shitti crossdoamin blockage
Darth Skywalker
@adityaparab
Aug 03 2016 07:53
@smdevpod : Can you share your nodejs code? I haven't worked with winston as such but it seems like an express middleware so it should be an easy integration.
ZZPot
@ZZPot
Aug 03 2016 07:54
I just stuck at every corner of it
openweathermap.org - how to use it?
Alexander Køpke
@alexanderkopke
Aug 03 2016 07:54
@ZZPot press f12 you should be able to see error messages in the console
ZZPot
@ZZPot
Aug 03 2016 07:54
I've made a url for request
Darth Skywalker
@adityaparab
Aug 03 2016 07:55
@ZZPot what's your url?
ZZPot
@ZZPot
Aug 03 2016 07:55
console didn't get an errors
Alexander Køpke
@alexanderkopke
Aug 03 2016 07:55
ok that links works and you should be able to use it
ZZPot
@ZZPot
Aug 03 2016 07:55
and when I request it via browser - everything ok
but .getJSON() with it just didn't send request
Claudio Restifo
@Marmiz
Aug 03 2016 07:56
@ZZPot so again, show us your code so we can help :)
Darth Skywalker
@adityaparab
Aug 03 2016 07:56
to use that with $.getJSON simply add &callback=? at the end of your url
http://api.openweathermap.org/data/2.5/weather?lat=53&lon=158&APPID=dda0d75f4c297dc5c7e65e1a9c955d20&callback=?
ZZPot
@ZZPot
Aug 03 2016 07:56
is there any official info about that? @adityaparab
Alexander Køpke
@alexanderkopke
Aug 03 2016 07:57
$.getJSON('http://api.openweathermap.org/data/2.5/weather?lat=53&lon=158&APPID=dda0d75f4c297dc5c7e65e1a9c955d20', function(data){
  console.log(data);
});
this works fine
Darth Skywalker
@adityaparab
Aug 03 2016 07:58

so you will have

var url = "http://api.openweathermap.org/data/2.5/weather?lat=53&lon=158&APPID=dda0d75f4c297dc5c7e65e1a9c955d20&callback=?";

$.getJSON(url, function(weatherJson){
    console.log(weatherJson);
});

You should see this on your console

{
    "coord": {
        "lon": 158.23,
        "lat": 52.95
    },
    "weather": [{
        "id": 802,
        "main": "Clouds",
        "description": "scattered clouds",
        "icon": "03d"
    }],
    "base": "stations",
    "main": {
        "temp": 291.02,
        "pressure": 1011,
        "humidity": 82,
        "temp_min": 290.93,
        "temp_max": 291.15
    },
    "visibility": 10000,
    "wind": {
        "speed": 4,
        "deg": 160
    },
    "clouds": {
        "all": 40
    },
    "dt": 1470210042,
    "sys": {
        "type": 1,
        "id": 7248,
        "message": 0.0167,
        "country": "RU",
        "sunrise": 1470160117,
        "sunset": 1470215805
    },
    "id": 2122229,
    "name": "Paratunka",
    "cod": 200
}
ZZPot
@ZZPot
Aug 03 2016 07:58
@adityaparab I know what I should see, but I won't happen
and I dunno why
Darth Skywalker
@adityaparab
Aug 03 2016 07:58

@ZZPot

is there any official info about that? @adityaparab

Yes. Take a look at

http://api.jquery.com/jquery.getjson/

ZZPot
@ZZPot
Aug 03 2016 07:59
if it only able to get an error code
Darth Skywalker
@adityaparab
Aug 03 2016 07:59
From official docs
JSONP

If the URL includes the string "callback=?" (or similar, as defined by the server-side API),
 the request is treated as JSONP instead. See the discussion of the jsonp data type in $.ajax() 
for more details.
ZZPot
@ZZPot
Aug 03 2016 07:59
it's not a jsonp
jamesmillerho
@jamesmillerho
Aug 03 2016 07:59
what's the difference between $.json and $.ajax?
Darth Skywalker
@adityaparab
Aug 03 2016 08:00

@ZZPot

it's not a jsonp

How? You're making cross-domain request. You have no other option than using ajax with JSONP

ZZPot
@ZZPot
Aug 03 2016 08:01
@adityaparab what? how about CORS?
Claudio Restifo
@Marmiz
Aug 03 2016 08:01
@jamesmillerho to make it simple: two different ways to ask for data from a server.
jamesmillerho
@jamesmillerho
Aug 03 2016 08:01
lol
thanks @Marmiz
CamperBot
@camperbot
Aug 03 2016 08:01
jamesmillerho sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 338 | @marmiz |http://www.freecodecamp.com/marmiz
smdevpod
@smdevpod
Aug 03 2016 08:02
@adityaparab did you get the private notification?
Darth Skywalker
@adityaparab
Aug 03 2016 08:03

@ZZPot

@adityaparab what? how about CORS?

That needs to be enabled from the server. If the server allows CORS then you don't need JSONP. However, you never know nature of the server while writing generic code. So you're better off writing code that supports JSONP than not supporting it.

ZZPot
@ZZPot
Aug 03 2016 08:03
it retursn answer with Access-Control-Allow-Credentials: true , so I don't need to make a jsonp trick
Darth Skywalker
@adityaparab
Aug 03 2016 08:04

@ZZPot

Access-Control-Allow-Credentials: true has nothing to do with Access-Control-Allow-Origin

ZZPot
@ZZPot
Aug 03 2016 08:04
@adityaparab if server doesn't support jsonp?
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST
that's what cors requires
these headers
Darth Skywalker
@adityaparab
Aug 03 2016 08:05
@ZZPot : Howe can be be sure that server has the same configuration?
ZZPot
@ZZPot
Aug 03 2016 08:05
and it sends them
what?
same to what?
Darth Skywalker
@adityaparab
Aug 03 2016 08:06
Have you worked on backend before?
@ZZPot
ZZPot
@ZZPot
Aug 03 2016 08:06
a little
anyway - a did everything that said in official API manual
an there is no words about jsonp
in fact I'm C++ coder
but there is no work for me, so I decide to try luck in this
Norvin Burrus
@ndburrus
Aug 03 2016 08:13
@jamesmillerho
this may be helpful: :sparkles:
ZZPot
@ZZPot
Aug 03 2016 08:15
test
Ghost
@ghost~575e5a9bc2f0db084a1d8e8b
Aug 03 2016 08:20
@adityaparab thanks for helping out
CamperBot
@camperbot
Aug 03 2016 08:20
gimyboya sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 465 | @adityaparab |http://www.freecodecamp.com/adityaparab
ZZPot
@ZZPot
Aug 03 2016 08:22
so, noone can help?
Darth Skywalker
@adityaparab
Aug 03 2016 08:23

@ZZPot

Not until you reveal your code

ZZPot
@ZZPot
Aug 03 2016 08:23
var wapi_url = 'http://api.openweathermap.org/data/2.5/weather?lat=53&lon=158&APPID=dda0d75f4c297dc5c7e65e1a9c955d20';
$.getJSON(wapi_url, function(weather_json)
{
showWeather(weather_json);
});
Darth Skywalker
@adityaparab
Aug 03 2016 08:24
and what is your weather_json?
You're gonna have to show your showWeather function as well
ZZPot
@ZZPot
Aug 03 2016 08:25
it didn't reach showWeather() function
it just didn't sent a request
Darth Skywalker
@adityaparab
Aug 03 2016 08:26
When I run it, I can see the response.
ZZPot
@ZZPot
Aug 03 2016 08:26
yeah?
Darth Skywalker
@adityaparab
Aug 03 2016 08:26
do you have a fiddle or something for this?
ZZPot
@ZZPot
Aug 03 2016 08:26
fiddle?
Darth Skywalker
@adityaparab
Aug 03 2016 08:26
codepen?
ZZPot
@ZZPot
Aug 03 2016 08:26
prefer notepad and firefox
Darth Skywalker
@adityaparab
Aug 03 2016 08:27
Have you included jQuery in your index.html?
ZZPot
@ZZPot
Aug 03 2016 08:27
sure
Teresa Garriot
@garriottteresa
Aug 03 2016 08:27

// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
    var lookup ={
    alpha: "Adams",
      bravo: "Boston",
    charlie: "Chicago",
delta:  "Denver",
echo: "Easy",
foxtrot:"Frank"
  };
result = lookup.val;

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

// Change this value to test
phoneticLookup("charlie");
What am I missing??
ZZPot
@ZZPot
Aug 03 2016 08:27
first getJSON works fine
Darth Skywalker
@adityaparab
Aug 03 2016 08:27

@garriottteresa

result = lookup.val;

should be

result = lookup[val];

@ZZPot

first getJSON works fine

I don't see more than one getJSON in your code for anything after one getJSON to fail :D

Teresa Garriot
@garriottteresa
Aug 03 2016 08:30
@adityaparab Thanks you . When do you use a "." and when do you use a "[]"
CamperBot
@camperbot
Aug 03 2016 08:30
garriottteresa sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 466 | @adityaparab |http://www.freecodecamp.com/adityaparab
Darth Skywalker
@adityaparab
Aug 03 2016 08:31

@ZZPot : Geez dude! You ar doing some horrible shit.

get rid of <script type="text/javascript"> from your html. Line 2, I believe

ZZPot
@ZZPot
Aug 03 2016 08:31
ok, it's because i just copy it from notepad
now it's ok
nearek
@nearek
Aug 03 2016 08:33
hello
i have problem
myVar should equal 88 myVar = myVar should be changed Use the ++ operator Do not change code above the line
myVar should equal 88
myVar = myVar should be changed
Use the ++ operator
Do not change code above the line
var myVar = 87;

// Only change code below this line
myVar = myVar + 1;
ZZPot
@ZZPot
Aug 03 2016 08:34
@nearek myVar++;
Pradeep Naraman
@prdpsn
Aug 03 2016 08:35
what does \r carriage return do?
ZZPot
@ZZPot
Aug 03 2016 08:36
@prdpsn jumping at the first symbol
position
Pradeep Naraman
@prdpsn
Aug 03 2016 08:36
example?
ZZPot
@ZZPot
Aug 03 2016 08:36
@prdpsn only in c++
Darth Skywalker
@adityaparab
Aug 03 2016 08:36

@garriottteresa :

when you know a name of the property on an object, you use .

For example


var obj = {
    prop1:"value 1",
    prop2:"value2"
}

//you can directly access prop1 like

obj.prop1 // value1

//but if you have name of property in different variable

var val = "prop2";

// you have to access it like

obj[val] // value 2

// if you do obj.val

obj.val // undefined

// because there is NO val:"some value" in your obj. 
//There is only prop1 and prop2

// Also if your key has a space (or any special character) in it, 
// you will have to use [] notation.

var obj = {
    "some key":"some value"
}

obj.some key // Error
obj["some key"] // some value
var key = "some key";
obj[key] // some value

Hope that is clear

ZZPot
@ZZPot
Aug 03 2016 08:36
hell\rshit gives shit
@prdpsn
jadczakd
@jadczakd
Aug 03 2016 08:41
NextInLine step
function nextInLine(arr, item) {
  arr.push(item);
  return arr.shift();
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));

console.log(nextInLine([5,6,7,8,9], 1));
console.log(nextInLine([],1));
console.log(nextInLine([2],1));
console.log(nextInLine(testArr,10));
console.log("After: " + JSON.stringify(testArr));
It took me forever to realise I can use the vars from the function, well that I am expected to, not the testArr one. Is it good? Could it have been done better?
CamperBot
@camperbot
Aug 03 2016 08:41
:bulb: to format code use backticks! ``` more info
jadczakd
@jadczakd
Aug 03 2016 08:42
Bah! That's better!
ZZPot
@ZZPot
Aug 03 2016 08:43
@jadczakd nextInLine([5,6,7,8,9], 1) useless, because after returning from function this array will disapear
jadczakd
@jadczakd
Aug 03 2016 08:44
@ZZPot True that the console.log are mine for when I was writing it I wanted to know what results I am getting.
Abis Mal
@abisthecodermal
Aug 03 2016 08:45
Guys, need help. I am stuck in my own code.
Darth Skywalker
@adityaparab
Aug 03 2016 08:45

Guys, need help. I am stuck in my own code.

Isn't that wonderful? :D

Abis Mal
@abisthecodermal
Aug 03 2016 08:45
:D
a completed challenge i baffling me
is^
Darth Skywalker
@adityaparab
Aug 03 2016 08:46
Show code
Abis Mal
@abisthecodermal
Aug 03 2016 08:46
Challenge "Record Collection"
Code

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

// Only change code below this line
function updateRecords(id, prop, value) {

  if(value==="")
    {
      delete collection[id][prop];
    }
  else
    {
      if(prop==="tracks")
        {
          if(!collection[id].hasOwnProperty("prop"))
            {
              var newArr=[];
              newArr.push(value);
              collection[id][prop]=newArr;
            }
          else
            {
              collection[id][prop].push(value);
            }
        }
      else
      {
        collection[id][prop]=value;
      }
    }  
}
// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

output

collection = 
{
  "1245": {
    "artist": "Robert Palmer",
    "tracks": []
  },
  "2468": {
    "album": "1999",
    "artist": "Prince",
    "tracks": [
      "1999",
      "Little Red Corvette"
    ]
  },
  "2548": {
    "album": "Slippery When Wet",
    "artist": "Bon Jovi",
    "tracks": [
      "Let It Rock",
      "You Give Love a Bad Name"
    ]
  },
  "5439": {
    "album": "ABBA Gold",
    "artist": "ABBA"
  }
}

Error: After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"

Blauelf
@Blauelf
Aug 03 2016 08:48

@manucpp Instead of

              var newArr=[];
              newArr.push(value);
              collection[id][prop]=newArr;

you could write

              collection[id][prop]=[value];
Abis Mal
@abisthecodermal
Aug 03 2016 08:48
so will this initialize an array if it doesn't exist? @Blauelf
and push value as its element?
Ademola Adegbuyi
@ooade
Aug 03 2016 08:49
@manucpp sure, it will.
Blauelf
@Blauelf
Aug 03 2016 08:49
It's creating a new array with the content of value as its only element.
Abis Mal
@abisthecodermal
Aug 03 2016 08:50
oh thanks @Blauelf @marhyorh. This is awesome!
CamperBot
@camperbot
Aug 03 2016 08:50
manucpp sends brownie points to @blauelf and @marhyorh :sparkles: :thumbsup: :sparkles:
:star2: 2307 | @blauelf |http://www.freecodecamp.com/blauelf
:cookie: 700 | @marhyorh |http://www.freecodecamp.com/marhyorh
Teresa Garriot
@garriottteresa
Aug 03 2016 08:50
@adityaparab clear as mud ;-) thanks
CamperBot
@camperbot
Aug 03 2016 08:50
garriottteresa sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:warning: garriottteresa already gave adityaparab points
Abis Mal
@abisthecodermal
Aug 03 2016 08:50
now the error: After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"
The output shows it, but there isn't the regular green check mark
Blauelf
@Blauelf
Aug 03 2016 08:51
@manucpp You are missing return collection; as the last statement of your function, or did you just not paste that?
Abis Mal
@abisthecodermal
Aug 03 2016 08:52
I haven't gotten to it yet. The code is incomplete. I was wondering as to why the above objective appears as incomplete
Blauelf
@Blauelf
Aug 03 2016 08:52
Have you tried adding the return?
Ian Mason
@IanMason
Aug 03 2016 08:52
Can anyone help with Drop It. Maybe I am misunderstanding but it seems that 2 of the test scripts are wrong. dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}) should return [3, 9, 2]
Should this only return 3 & 9?
Abis Mal
@abisthecodermal
Aug 03 2016 08:53
As per the output, artist is ABBA. But it still appears in red :(
Markus Kiili
@Masd925
Aug 03 2016 08:54
@IanMason Drop elements until...
So 2 should be there.
Ian Mason
@IanMason
Aug 03 2016 08:55
:-) Thank you. I have wasted ages on this. First time I have asked a question here, should have asked sooner. Thanks so much!!
Abis Mal
@abisthecodermal
Aug 03 2016 08:56
how do you send screenshots here?
Blauelf
@Blauelf
Aug 03 2016 08:56
@manucpp It won't work at all if you don't have return collection; as your last line. And you have a little bug in your hasOwnProperty call (the property name is not "prop" but either "tracks" or at that point equivalently prop without quotation marks, as it is the variable)
Markus Kiili
@Masd925
Aug 03 2016 08:56
@IanMason Yes, ask here if you get stuck.
Ian Mason
@IanMason
Aug 03 2016 08:57
@Masd925 Cheers.
Abis Mal
@abisthecodermal
Aug 03 2016 08:57
oh damn! thanks @Blauelf Thanks again....
CamperBot
@camperbot
Aug 03 2016 08:57
manucpp sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: manucpp already gave blauelf points
Abis Mal
@abisthecodermal
Aug 03 2016 08:58
This message was deleted
CamperBot
@camperbot
Aug 03 2016 08:58
manucpp sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: manucpp already gave blauelf points
Darth Skywalker
@adityaparab
Aug 03 2016 08:58

@adityaparab clear as mud ;-) thanks

Thats an interesting point of view on mud

CamperBot
@camperbot
Aug 03 2016 08:58
sorry adityaparab, you can't send brownie points to yourself! :sparkles: :sparkles:
Markus Kiili
@Masd925
Aug 03 2016 08:59
@manucpp Watch the language. There are some 4 year olds here coding.
Abis Mal
@abisthecodermal
Aug 03 2016 08:59
done
Darth Skywalker
@adityaparab
Aug 03 2016 08:59

sorry adityaparab, you can't send brownie points to yourself! :sparkles: :sparkles:

Go to hell @camperbot

Abis Mal
@abisthecodermal
Aug 03 2016 09:03
If only the world were sunshine and rainbows... and 4 year olds had only gitter for etiquettes...
waynelouie
@waynelouie
Aug 03 2016 09:17
how do i link the problem i'm having on fcc again?
couldn't find the bot
Brendan Kinahan
@BKinahan
Aug 03 2016 09:21
@waynelouie do you mean you want a link to the help article, or you want to share your code?
waynelouie
@waynelouie
Aug 03 2016 09:22
share the code
Brendan Kinahan
@BKinahan
Aug 03 2016 09:22
```js
your code here
```
waynelouie
@waynelouie
Aug 03 2016 09:23

//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line

  for(i=0; i<contacts.length; i++){
    if(firstName===contacts[i].firstName){
      return contacts[i].firstName;
    } else{ return "No such contact";}

     if (prop===contacts[i].prop){
      return contacts[i].prop;
    }else {return "No such property";}


// Only change code above this line
}
}

// Change these values to test your function
lookUpProfile("Kristian", "likes");
i hope i'm not too off track
could i get a hint please
Brendan Kinahan
@BKinahan
Aug 03 2016 09:23
@waynelouie awesome :thumbsup:
@waynelouie you will want to make sure that you don't return "No such contact" until you have checked all of the contacts and know there is no match found.
@waynelouie right now you check the first one, and either return its name if the name matches, or "No such contact" if the name doesn't match, so no other contacts are checked (the function exits and returns a value)
@waynelouie also, when accessing prop you will need bracket notation instead of dot notation, since prop is a variable and not a string.
JavarriL
@JavarriL
Aug 03 2016 09:25

function titleCase(str) {
  var a = str.toLowerCase();
  var b = a.split(" ");

  var letters;
  for(var i = 0; i < b.length; i++) {
    letters = b[i].split('');

  }
  return letters;
}

titleCase("I'm a little tea pot");
When I return letters, it only shows the last word in the i array. I wanted to know how I could go about returning all of the letters in the whole sentence. Thanks in advance
Blauelf
@Blauelf
Aug 03 2016 09:25
@waynelouie Your check on property should only be performed if the name matches, and the check itself is done wrong. You might want to review Testing Objects for Properties
Rico042002
@rico042002
Aug 03 2016 09:26
Has anybody just recently finished the "Counting Cards" Lesson
waynelouie
@waynelouie
Aug 03 2016 09:26
hrrmm
alright thanks!
Blauelf
@Blauelf
Aug 03 2016 09:27
@JavarriL Push the changed word to another array, or replace b[i] with a new string, and return a join(" ")ed array.
Rico042002
@rico042002
Aug 03 2016 09:29
Anybody
Brendan Kinahan
@BKinahan
Aug 03 2016 09:29
@rico042002 I've finished it recently enough to understand it :P
Rico042002
@rico042002
Aug 03 2016 09:29
Could you please show me your code too it
Anna
@Anntol
Aug 03 2016 09:29
@BKinahan :+1:
Brendan Kinahan
@BKinahan
Aug 03 2016 09:29
I will not sir. But I will answer a question about it if you have one :)
Rico042002
@rico042002
Aug 03 2016 09:30
I finished it too bro!
Brendan Kinahan
@BKinahan
Aug 03 2016 09:30
Don't wanna spoil it for anyone here :D
Rico042002
@rico042002
Aug 03 2016 09:30
Well PM it too me then
JavarriL
@JavarriL
Aug 03 2016 09:31
@Blauelf For the second solution you're saying to replace b[i] by creating a variable that joins it together?
Brendan Kinahan
@BKinahan
Aug 03 2016 09:31
@rico042002 check out the CodeReview chat room, it's perfect for this kind of situation.
周欣
@Maggie9468
Aug 03 2016 09:34

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result = [myNoun||"cat",myAdjective||"little",myVerb||"hit",myAdverb||"slowly"].join("")+".";

// Your code above this line
return result;
}

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

unsuccessful
help
CamperBot
@camperbot
Aug 03 2016 09:35

CamperBot

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

Basic Commands:

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

meet CamperBot in FreeCodeCamp/camperbotPlayground

:pencil: read more about camperbot on the FCC Wiki

周欣
@Maggie9468
Aug 03 2016 09:35
Word Blanks
JavarriL
@JavarriL
Aug 03 2016 09:36
@Blauelf Nevermind Thanks I got it with the first solution but I still want to learn how to go about doing the second solution
CamperBot
@camperbot
Aug 03 2016 09:36
javarril sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2308 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Aug 03 2016 09:37

@JavarriL What I am suggesting is

  var b = str.split(" ");
  for (var i = 0; i < b.length; i++) {
    b[i] = somehowTransform(b[i]);
  }
  return b.join(" ");

or, if you explicitly build a function somehowTransform that titlecases a single word, you can even do

  function somehowTransform(word) { ... }
  return str.split(" ").map(somehowTransform).join(" ");
JavarriL
@JavarriL
Aug 03 2016 09:40
@Blauelf Oh ok I understand the second solution thanks
CamperBot
@camperbot
Aug 03 2016 09:40
javarril sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: javarril already gave blauelf points
Jack Lyons
@JackEdwardLyons
Aug 03 2016 09:53
@JackEdwardLyons
hey guys im wondering if anyone can help me cut down on my jquery code to make it more elegant?
http://codepen.io/JackEdwardLyons/pen/wWEmQg
Brendan Kinahan
@BKinahan
Aug 03 2016 10:00
@JackEdwardLyons you might get better results in the HelpFrontEnd or CodeReview rooms :)
smdevpod
@smdevpod
Aug 03 2016 10:03
has anyone worked with the winston npm module?
Pablo
@Olbap14
Aug 03 2016 10:05
help Inventory Update
CamperBot
@camperbot
Aug 03 2016 10:05

:point_right: algorithm inventory update [wiki]

Algorithm Inventory Update

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

In this problem, you've to compare and update the inventory stored in a 2D array against a second 2D array of a fresh delivery. Update the current existing inventory item quantities (in arr1). If an item cannot be found, add the new item and quantity into the inventory array. The returned inventory array should be in alphabetical order by item.

The current as well as new inventory will be in this format: var newInv = [[2, "Item1 Name"], [3, "Item2 Name"], [67, "Item3 Name"], [7, "Item4 Name"]];.

Relevant Links

:pencil: read more about algorithm inventory update on the FCC Wiki

Marko Radosavljevic
@planetRock
Aug 03 2016 10:08
hello guys
can anyone help me
Dany Din
@danydin
Aug 03 2016 10:09
hey if strings are immutable how this is possible:
var s = "adeandacity";
s = s[1].toUpperCase() + s.slice(2);
smdevpod
@smdevpod
Aug 03 2016 10:09
@planetRock with what?
Marko Radosavljevic
@planetRock
Aug 03 2016 10:09
Do not change code above the line
a should have a value of 7
b should have a value of 7
a should be assigned to b with =

// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;
var b = 7;

Manish Giri
@Manish-Giri
Aug 03 2016 10:10
@planetRock remove the var keyword
Anna
@Anntol
Aug 03 2016 10:11
@planetRock a should be assigned to b, not value
Marko Radosavljevic
@planetRock
Aug 03 2016 10:11
@Manish-Giri write the answer
if you can:D
Dany Din
@danydin
Aug 03 2016 10:12
hey if strings are immutable how this is possible:
var s = "adeandacity";
s = s[1].toUpperCase() + s.slice(2);
Anna
@Anntol
Aug 03 2016 10:13
@danydin you can assign new value, but can't change some chars only
Manish Giri
@Manish-Giri
Aug 03 2016 10:13
@planetRock I can, but I don’t want to. That won’t help you learn.
Dany Din
@danydin
Aug 03 2016 10:13
@Anntol thanks what do you mean change some chars only
CamperBot
@camperbot
Aug 03 2016 10:13
danydin sends brownie points to @anntol :sparkles: :thumbsup: :sparkles:
:cookie: 301 | @anntol |http://www.freecodecamp.com/anntol
Sunil Rana
@sunil28rana
Aug 03 2016 10:14

Hey guys, i'm stuck
can anybody help me out

Chunky Monkey
Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.

chunkArrayInGroups(["a", "b", "c", "d"], 2) should return [["a", "b"], ["c", "d"]].
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3) should return [[0, 1, 2], [3, 4, 5]].
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2) should return [[0, 1], [2, 3], [4, 5]].
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4) should return [[0, 1, 2, 3], [4, 5]].
chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3) should return [[0, 1, 2], [3, 4, 5], [6]].
chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4) should return [[0, 1, 2, 3], [4, 5, 6, 7], [8]].
chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2) should return [[0, 1], [2, 3], [4, 5], [6, 7], [8]].
Marko Radosavljevic
@planetRock
Aug 03 2016 10:14
@Manish-Giri Yeah, but what will help me
:D
Anna
@Anntol
Aug 03 2016 10:14
@danydin s[1] = a, s[3]=c and etc
Mitul Islam
@MitulIslam
Aug 03 2016 10:15
stuck in Wherefore Art Thou
works for first two test case
https://repl.it/Cixn/6
can any one tell me what am I doing wrong
Dany Din
@danydin
Aug 03 2016 10:15
@Anntol so basically just use thier methods i can do one them but not reassign things right/? [without creating new var]