These are chat archives for FreeCodeCamp/HelpJavaScript

23rd
Feb 2016
Kenneth Yeung
@kencyyeung
Feb 23 2016 00:15
Hello
wkolee
@wkolee
Feb 23 2016 00:15

// 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"].gloveBoxContents;
var gloveBoxContents = 'maps';

can somebody help
Kenneth Yeung
@kencyyeung
Feb 23 2016 00:15
I'm having a hard time with the 'Stand in Line' Javascript lesson. queue function
I hear campers can find the answer somewhere...but I do not know where
Norman Dela Cruz
@dcnr
Feb 23 2016 00:16
@wkolee you don't need the gloveBoxContents part
wkolee
@wkolee
Feb 23 2016 00:16
@dcnr still not working
Norman Dela Cruz
@dcnr
Feb 23 2016 00:16
@wkolee I mean myStorage.car.inside['glove box'] will give you maps
@wkolee that's what you should assign to gloveBoxContents
@kencyyeung will you post your code?
wkolee
@wkolee
Feb 23 2016 00:17
@dcnr thanks now it make since
CamperBot
@camperbot
Feb 23 2016 00:17
wkolee sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 690 | @dcnr | http://www.freecodecamp.com/dcnr
Kenneth Yeung
@kencyyeung
Feb 23 2016 00:17

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

return arr + queue.remove(item);

  // Change this line

}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

@dcnr

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

Write a function queue 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 queue function should then return the element that was removed.

this is the first lesson I've ever been stuck on...newly released and created by freecampcode
would really appreciate your expertise
Norman Dela Cruz
@dcnr
Feb 23 2016 00:19

@kencyyeung ooh you're just emulating a queue so this part

Write a function queue 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 queue function should then return the element that was removed.

Is the one you should focus on.

@kencyyeung so you would need to
1) Insert item at the end of arr
2) Remove the first item of arr
3) Return that item
@kencyyeung there are array functions that deal with these, read about Array.prototype.push and Array.prototype.shift
@kencyyeung then you can solve the problem :D
Kenneth Yeung
@kencyyeung
Feb 23 2016 00:23
@dcnr thank you very much !!
CamperBot
@camperbot
Feb 23 2016 00:23
:star: 691 | @dcnr | http://www.freecodecamp.com/dcnr
kencyyeung sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
wkolee
@wkolee
Feb 23 2016 00:38

// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = myPlants.list1; // Change this line

1
Amanda
@invaderrizz
Feb 23 2016 00:39
Hi guys, I'm coming up against a TypeError with the Record Collection question.
eeflores
@eeflores
Feb 23 2016 00:40
@wkolee myPlants is an array, so you'll need myPlants[something]
Amanda
@invaderrizz
Feb 23 2016 00:40
@wkolee You need two sets of bracket notation.
David Godfrey
@dgodfrey95
Feb 23 2016 00:42
For some reason this MadLibs code isn't working. The tasks says the result should contain all of the passed words separated by non-word characters (and any additional words in my madlib). What did I do wrong...
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";

  result += "He " + myVerb + " as quickly as he could while his " + myNoun + " chased after him " + myAdverb + ".";
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Amanda
@invaderrizz
Feb 23 2016 00:42
@dgodfrey95 You need to use all four variables.
David Godfrey
@dgodfrey95
Feb 23 2016 00:43
@invaderrizz Wow thanks.
CamperBot
@camperbot
Feb 23 2016 00:43
dgodfrey95 sends brownie points to @invaderrizz :sparkles: :thumbsup: :sparkles:
:star: 220 | @invaderrizz | http://www.freecodecamp.com/invaderrizz
Amanda
@invaderrizz
Feb 23 2016 00:43
@dgodfrey95 NP :)
Greg
@gsc229
Feb 23 2016 00:46
wondering if some savvy coders out there could take a look at my code from the Pig Latin algorithm exercise?
Amanda
@invaderrizz
Feb 23 2016 00:46
function update(id, prop, value) {
if (value !== "" && prop !== "tracks") {
id[prop] = prop;
id.prop[value] = value;
}
Richard Corbett
@reacorbett
Feb 23 2016 00:46
@gsc229 i will take a gander
Norman Dela Cruz
@dcnr
Feb 23 2016 00:47
@gsc229 you could always post it here, there's also a dedicated codereview chat room :D
Greg
@gsc229
Feb 23 2016 00:47
okay, cool just trying to remember how to post code right quick
Norman Dela Cruz
@dcnr
Feb 23 2016 00:47
@invaderrizz you need to "work on" your collections object

@gsc229
you can format your code by doing
```js

<paste code here>
```

Those are 3 backquotes, the key above tab, left of 1, and below esc.
You can create a new line by shift+enter so to format it'll be:
```js (shift+enter)(paste code)(shift+enter) ```

David Godfrey
@dgodfrey95
Feb 23 2016 00:48
@invaderrizz Are you sure you didn't mean id[prop][value] = value?
Greg
@gsc229
Feb 23 2016 00:48
function translate(str) {

  var strToArr = str.split('');
  var toEnd = [];


      if(strToArr[0] !== 'a' || strToArr[0] !== 'e' || strToArr[0] !== 'i' || strToArr[0] !== 'o' || strToArr[0] !== 'u'){

        toEnd.push(strToArr.splice(0,1));
        strToArr.push(toEnd,'a', 'y');
        return strToArr.join('');


        } else if(strToArr[0] == 'a' || strToArr[0] == 'e' || strToArr[0] == 'i' || strToArr[0] == 'o' || strToArr[0] == 'u') {
          return false;
        }


  return strToArr;
} 

translate('algorithm');

//if(strToArr == 'a' ||
the else if does not return false in when passing 'algorithm' through the function.
David Godfrey
@dgodfrey95
Feb 23 2016 00:50
@gsc229 Replace the ||s in the first if statement with &&s.
Greg
@gsc229
Feb 23 2016 00:51
@dgodfrey95 Great thanks! I'll give that a try!
CamperBot
@camperbot
Feb 23 2016 00:51
gsc229 sends brownie points to @dgodfrey95 :sparkles: :thumbsup: :sparkles:
:star: 175 | @dgodfrey95 | http://www.freecodecamp.com/dgodfrey95
Richard Corbett
@reacorbett
Feb 23 2016 00:51
@gsc229 Replace the ||s in the first if statement with &&s.
oops.
Greg
@gsc229
Feb 23 2016 00:51
@reacorbett cool thanks!
CamperBot
@camperbot
Feb 23 2016 00:51
gsc229 sends brownie points to @reacorbett :sparkles: :thumbsup: :sparkles:
:star: 243 | @reacorbett | http://www.freecodecamp.com/reacorbett
Norman Dela Cruz
@dcnr
Feb 23 2016 01:01
@gsc229 you should check each letter from the start if it's a consonant until you reach a vowel, not just the first one (strToArr[0])
wkolee
@wkolee
Feb 23 2016 01:07

// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

return collection;
}

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

David Bruskin
@kidimi
Feb 23 2016 01:07
Hi. How do I post a screen grab here?
wkolee
@wkolee
Feb 23 2016 01:09

// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

return collection;
}

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

nvm know what to do now.
Norman Dela Cruz
@dcnr
Feb 23 2016 01:10
@kidimi just drag it over, but if it's just code, it would be better to paste it here formatted so we can run it

@kidimi you can format your code by doing
```js

<paste code here>
```

Those are 3 backquotes, the key above tab, left of 1, and below esc.
You can create a new line by shift+enter so to format it'll be:
```js (shift+enter)(paste code)(shift+enter) ```

David Bruskin
@kidimi
Feb 23 2016 01:10
Thanks!
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 01:13
I am baffled. Logistically, I’d think it should work but for some reason it doesn’t? I’m working on Smallest Common Multiple. Here’s code I’m working on.
function smallestCommons(arr) {
  var multiplied = 1;
  var number;
  var max;
  var arraynumber = [];
   //setting the high/low values to fixed variables...
  if (arr[0]>arr[1]){
     number =  arr[1];
    max = arr[0];
  }
  else{
    number = arr[0];
    max = arr[1];
  }
  while(number <= max){
    if (multiplied % number !== 0){multiplied *=number;}
    number++;
  }

  return multiplied; 

}

smallestCommons([1,5]);
David Bruskin
@kidimi
Feb 23 2016 01:13
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  result = ["The " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb];

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
I'm getting a red X for "wordBlanks("","","","") should return a string." What am I missing? I've reset the pages a few times, then repasted the code. Didn't help.
DJ
@qualitymanifest
Feb 23 2016 01:15
@kidimi the [ ]'s around your string make it an array
you don't want them there
David Bruskin
@kidimi
Feb 23 2016 01:16
Thanks very much!
Mafalda
@otmeek
Feb 23 2016 01:22
Is someone able to explain what || is doing in app.use(express.static(page || path.join(__dirname, 'public')));? Both page and path.join(__dirname, 'public') are directory paths, but what does it mean to give a function a || b as parameters?
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 01:22
@otmeek it’s “or"
Richard Corbett
@reacorbett
Feb 23 2016 01:23
var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 1;
};

// Only change code below this line.

var myCar = new Car();
myCar.driverType = "race car";
what am I doing wrong here? It is telling me "The property nickname of myCar should be a string". Is "race car" not the property nickname?
Mafalda
@otmeek
Feb 23 2016 01:23
@pkshreeman yea, but which parameter ends up getting used?
I know what || does in an if statement, but seeing it like this is new to me
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 01:24
I guess it depends on what system it is operating on?
@otmeek I misunderstood your question.
Norman Dela Cruz
@dcnr
Feb 23 2016 01:26
@otmeek it's short circuit evaluation so if page is falsy it would do path.join
Hereshk
@Hereshk
Feb 23 2016 01:26
@reacorbett You need to add the property "nickname", now you are adding the property "driverType"
Richard Corbett
@reacorbett
Feb 23 2016 01:26
oh I see. Thanks @Hereshk
CamperBot
@camperbot
Feb 23 2016 01:26
reacorbett sends brownie points to @hereshk :sparkles: :thumbsup: :sparkles:
:star: 257 | @hereshk | http://www.freecodecamp.com/hereshk
Mafalda
@otmeek
Feb 23 2016 01:27
@dcnr that makes complete sense, thanks!
CamperBot
@camperbot
Feb 23 2016 01:27
otmeek sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 692 | @dcnr | http://www.freecodecamp.com/dcnr
Hereshk
@Hereshk
Feb 23 2016 01:27
@reacorbett you're welcome
Norman Dela Cruz
@dcnr
Feb 23 2016 01:30

@otmeek it's really useful for variable initialization, something like

let env = process.env.TESTS || 'all';

or for setting an argument default value

function foo(bar) {
  bar = bar || baz;
}

that kind of stuff

Mafalda
@otmeek
Feb 23 2016 01:31
@dcnr yea I can see how it's useful
Tim Bell
@MindfulBell
Feb 23 2016 01:33
is | | es6?
Norman Dela Cruz
@dcnr
Feb 23 2016 01:35
@MindfulBell no, it's just a logical OR
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 01:35
This works up to a point..what am I missing here? for smallest common multiple
function smallestCommons(arr) {
  var multiplied = 1;
  var number;
  var max;
  var arraynumber = [];
   //setting the high/low values to fixed variables...
  if (arr[0]>arr[1]){
     number =  arr[1];
    max = arr[0];
  }
  else{
    number = arr[0];
    max = arr[1];
  }  
  while (max >= number){
    if (multiplied % max !==0){multiplied *= max;}
    max-=1;
  }

  return multiplied; 

}

smallestCommons([1,13]);
Amanda
@invaderrizz
Feb 23 2016 01:38
@dgodfrey95 @dcnr Thanks guys, I finally found it.
CamperBot
@camperbot
Feb 23 2016 01:38
invaderrizz sends brownie points to @dgodfrey95 and @dcnr :sparkles: :thumbsup: :sparkles:
:star: 194 | @dgodfrey95 | http://www.freecodecamp.com/dgodfrey95
:star: 693 | @dcnr | http://www.freecodecamp.com/dcnr
Tim Bell
@MindfulBell
Feb 23 2016 01:39
@dcnr i guess using it for variable assignment felt snazzy
Norman Dela Cruz
@dcnr
Feb 23 2016 01:41
@MindfulBell yeah fun stuff, you can do stuff like
function factorialize(num, acc) {
  acc = acc || 1;
  return num <= 1 ? acc : factorialize(num - 1, acc * num);
}
and start off factorialize with just num
Tim Bell
@MindfulBell
Feb 23 2016 01:42
yea, thats pretty sharp
Rex Schrader
@SaintPeter
Feb 23 2016 01:43
@dcnr I hardly recognize you without your peach
Tim Bell
@MindfulBell
Feb 23 2016 01:43
with es6 though can't you put a default value in the function?
Norman Dela Cruz
@dcnr
Feb 23 2016 01:43
@SaintPeter I ate it all :D
Tim Bell
@MindfulBell
Feb 23 2016 01:43
function factorialize(num, acc = 1) {
//code
}
J Lee
@SoYuMatic
Feb 23 2016 01:43
var myVar = 87;
myVar = myVar++;
Why does that return myVar has 87 and not 88?
Tim Bell
@MindfulBell
Feb 23 2016 01:44
@SoYuMatic you are combining the two ways to do it
Norman Dela Cruz
@dcnr
Feb 23 2016 01:44
@MindfulBell yeah with ES6, dunno why it took so long, almost every other language I know has default values
Tim Bell
@MindfulBell
Feb 23 2016 01:44
@SoYuMatic either:
myVar++ // 88
myVar += 1 //88
myVar = myVar + 1 //88
@dcnr JS is special man, don't take that away
let it go at its own pace
Norman Dela Cruz
@dcnr
Feb 23 2016 01:45
ahah
Tim Bell
@MindfulBell
Feb 23 2016 01:45
ok i'm going to go on a stupid commute home which is stupid
J Lee
@SoYuMatic
Feb 23 2016 01:45
God, I feel stupid, Thank@mindfulbell
Tim Bell
@MindfulBell
Feb 23 2016 01:45
if you don't feel stupid while coding, you are doing it wrong
J Lee
@SoYuMatic
Feb 23 2016 01:45
thanks @ mindfulbell
Tim Bell
@MindfulBell
Feb 23 2016 01:45
@SoYuMatic no problem
MindfulBell @MindfulBell vanishes like @SaintPeter taught him
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 01:46
Can someone help out with smallest common multiple algorithm?
Norman Dela Cruz
@dcnr
Feb 23 2016 01:48
@MindfulBell take cares~
@pkshreeman I've been having a go at your code, but I guess my math isn't up to par :P
@pkshreeman I just did it like pen and paper lcm/gcd
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 01:50
@dcnr multiple all and find common lowest number in array?
What I am trying to do is to use mod (%) to only multiply numbers that it is not divisble by. Seems that misses some numbers.
Norman Dela Cruz
@dcnr
Feb 23 2016 01:57
@pkshreeman hmm I just made the range of numbers from arr
@pkshreeman and get their lcd with the formula
lcm(a,b)=(agcd(a,b))b=(bgcd(a,b))a.{lcm}(a,b)=\left(\frac{| a |}{{gcd}(a, b)}\right)\cdot | b | = \left(\frac{| b |}{{gcd}(a, b)}\right)\cdot | a |.
@pkshreeman so I take em by pairs

something like

function lcm(a, b) {
    return a / gcd(a, b) * b;
}

I don't really know how to make my own algorithm for this so I just took the math formula

and converted it to code
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 01:59
interesting! thanks @dcnr
CamperBot
@camperbot
Feb 23 2016 01:59
pkshreeman sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 694 | @dcnr | http://www.freecodecamp.com/dcnr
bitgrower
@bitgrower
Feb 23 2016 02:00
@pkshreeman -- yeah, it took me a bit to find an algo that made sense to me, and that I could easily program ...
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 02:01
@dcnr that’s probably what FCC staff had in mind..convert the formula …I was doing it hard way..as usual…develop my own algorithm for it...
bitgrower
@bitgrower
Feb 23 2016 02:01
it basically comes down to this ... your answer will be a product of all the primes, and sometimes you use one of the primes more than once ...
Norman Dela Cruz
@dcnr
Feb 23 2016 02:01
@pkshreeman I used this Euclidean Algo pseudocode for the gcd part too
bitgrower
@bitgrower
Feb 23 2016 02:02
ouch @pkshreeman -- that def would be the hard way ... I kept running into the wrong algos ... the ones which would have made you go create a HUGE array (or more) of values ...
Norman Dela Cruz
@dcnr
Feb 23 2016 02:02
@pkshreeman would be really satisfying to come up with your own algo though
bitgrower
@bitgrower
Feb 23 2016 02:02
@dcnr ... did you document your code to indicate what algo you were using ? :)
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 02:03
@bitgrower lol…well, I HAVE thought about creating 15*15 arrays...
Norman Dela Cruz
@dcnr
Feb 23 2016 02:03
@bitgrower SOME :P like Heap's Algo. :P
Otman Bouchari
@obouchari
Feb 23 2016 02:03
Hello people !
bitgrower
@bitgrower
Feb 23 2016 02:03
I'm thinking the Euclidean Algo pseudocode would be a nice reference ... :)
Norman Dela Cruz
@dcnr
Feb 23 2016 02:04
no people here, just peaches! :shipit:
bitgrower
@bitgrower
Feb 23 2016 02:04
good evening @obouchari
Otman Bouchari
@obouchari
Feb 23 2016 02:05
@bitgrower Did you finish all advanced js challenges?
bitgrower @bitgrower was lazy, just figured the first thing it was easy to do was find all the prime #s .. since you need 'em all ... then it's a matter of determining which non-primes require use of a prime more than once...
bitgrower
@bitgrower
Feb 23 2016 02:06
@obouchari -- not yet ... I'm on a bit of programming break because I have some number crunching I need to finish ... working on the remaining 3 would use up the energy I'm using for that vital number chasing ...
Norman Dela Cruz
@dcnr
Feb 23 2016 02:06
@bitgrower maybe you can help me implement Miller-Rabin or Solovay-Strassen primality test :( I'm stuck lol
Otman Bouchari
@obouchari
Feb 23 2016 02:07
I see
This message was deleted
This challange is giving me a headache “No Repeat please"
Norman Dela Cruz
@dcnr
Feb 23 2016 02:09
knew it!
Otman Bouchari
@obouchari
Feb 23 2016 02:10
hahaha How?
bitgrower
@bitgrower
Feb 23 2016 02:10
@dcnr hahahahahaha
you with all those fancy ES6 algos & terms ...
Norman Dela Cruz
@dcnr
Feb 23 2016 02:11
@obouchari It's one of the annoying ones, and I just mentioned it too! I just used Heap's Algo and brute force counted :P
@bitgrower eh it's not fancy! I'm rewriting my stuffs now! :D
Otman Bouchari
@obouchari
Feb 23 2016 02:12
I went a complete diffrent path, I’m using the probability to solve it
Norman Dela Cruz
@dcnr
Feb 23 2016 02:12
@obouchari wish I can devise my own formula for that :(
bitgrower
@bitgrower
Feb 23 2016 02:12
probabililty ? how do you do that ?
oh ...
for no repeat
Otman Bouchari
@obouchari
Feb 23 2016 02:13
Yep “No repeat” challenge
I came with this wiered ALgo to solve it I still didn’t finish yet :p
bitgrower
@bitgrower
Feb 23 2016 02:14
yeah ... bugged me that you can have two letters which are the same, but they are "distinct" for the problem ...
Otman Bouchari
@obouchari
Feb 23 2016 02:14
The formula works I’m just trying to turn it into ALgo
Norman Dela Cruz
@dcnr
Feb 23 2016 02:14
ooh that's awesome!
bitgrower
@bitgrower
Feb 23 2016 02:14
coolness, @obouchari
Otman Bouchari
@obouchari
Feb 23 2016 02:15
I just shearched for a while and trying to remember some of HighSchool stuff
Richard Corbett
@reacorbett
Feb 23 2016 02:16
A google search of this waypoint (Make Object Properties Private
) has pulled up a bunch of post about how FCC doesn't really help teach them a whole lot about javascript. It is really discouraging me, because I kind of feel the same way. Do most of you feel the same way, or am I just a complete idiot?
Derek Y.
@yangd01234
Feb 23 2016 02:16
Whoops I posted in the wrong chat earlier
I was wondering if i could get help on a challenege the nesting for loops

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

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

not sure whats going on with my code
Antoine Leclercq
@antoineLeclercq
Feb 23 2016 02:17
This message was deleted
bitgrower
@bitgrower
Feb 23 2016 02:17
I don't think you are a complete idiot at all @reacorbett ... however, you are HEAVILY encouraged to use outside resources ... like these:
help js resources
Richard Corbett
@reacorbett
Feb 23 2016 02:18
@bitgrower thanks
CamperBot
@camperbot
Feb 23 2016 02:18
reacorbett sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Feb 23 2016 02:18
I believe part of FCC's agenda is not to just teach you how to program ... but how to seek out, find, and understand what you need in order to solve a particular challenge ...
CamperBot
@camperbot
Feb 23 2016 02:18
:star: 608 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 23 2016 02:19
there are all kinds of little light switches that have to come on for folks ... and they are not all the same ...
for everyone ...
Otman Bouchari
@obouchari
Feb 23 2016 02:19
@reacorbett It will not give everything you still have to look for other ressources/ articles etc… But you benefit from people helping you and networking with others that may have some different experiences
bitgrower
@bitgrower
Feb 23 2016 02:20
so, for some people ... stand in line is super simple; for others, it can be painful ...
that, too, @obouchari -- software is more and more and more a team effort ...
Norman Dela Cruz
@dcnr
Feb 23 2016 02:20
thanks for the links @bitgrower
CamperBot
@camperbot
Feb 23 2016 02:20
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 609 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 23 2016 02:21
you are welcome, @dcnr ... thanks for all those crazy algo names I'll have to go off & research at some point ...
CamperBot
@camperbot
Feb 23 2016 02:21
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 695 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 23 2016 02:21
@reacorbett it also helps that the majority of the time you spend "coding" is not coding at all, but preparing how to code
bitgrower
@bitgrower
Feb 23 2016 02:22
one thing I DON'T think FCC does well is to teach you to think about the problem and sketch out an approach before you EVER try to code it ... that little screen half filled with code is too inviting and makes you want to write code right away ...
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 02:22
@yangd01234 you are only two indexes deep..the multiplyall has three arrays.
Norman Dela Cruz
@dcnr
Feb 23 2016 02:24
@yangd01234 @pkshreeman aah no he got it right, but multiplyAll is the function @yangd01234 should be working on arr
bitgrower
@bitgrower
Feb 23 2016 02:24
eh @pkshreeman ?
Otman Bouchari
@obouchari
Feb 23 2016 02:24
@bitgrower @dcnr By the way how you stream for FCC on twitch.tv?
Anyone have an idea?
bitgrower
@bitgrower
Feb 23 2016 02:26
dunno ... for some reason, I haven't even been able to access the site ... I know there is a room you might be able to ask more about it ... think it's called "Live Code" or "live coding" or something like that ...
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 02:26
@bitgrower @dcnr I missed the arr, my bad, I obivously need to sleep. I saw three arrays, assumed need i,j,k indexes...
Otman Bouchari
@obouchari
Feb 23 2016 02:26
@bitgrower I’ll check that out, thanks
CamperBot
@camperbot
Feb 23 2016 02:26
obouchari sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 610 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 23 2016 02:27
yw
Norman Dela Cruz
@dcnr
Feb 23 2016 02:27
@pkshreeman go get some rest! smallest common multiple getting to you :P
bitgrower
@bitgrower
Feb 23 2016 02:28
@dcnr -- what was that regex tutorial you sent me to the other day ... the first part wasn't new ... but then it went on to some more advanced tests ... now that got a bit more challenging ... :)
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 02:28
@dcnr yep! has been a week..going nuts here..and I still want to make MY algorithm.
Richard Corbett
@reacorbett
Feb 23 2016 02:28
This message was deleted
Norman Dela Cruz
@dcnr
Feb 23 2016 02:29
@pkshreeman I've been telling myself that, make my own one! I'm slowly reworking my stuffs now
@bitgrower which one? the interactive one?
Richard Corbett
@reacorbett
Feb 23 2016 02:29
var Bike = function() {

  // Only change code below this line.
  var gear = 0;

  this.getGear =function(){

  };

  this.setGear = function(){

  };

};

var myCar = new Car();

var myBike = new Bike();
Now try it yourself! Modify the Bike constructor to have a private property called gear and two public methods called getGear and setGear to get and set that value.
Can someone help me understand this before I through my computer out the window?
bitgrower
@bitgrower
Feb 23 2016 02:29
hint reacorbett -- look at what they did with Car ...
CamperBot
@camperbot
Feb 23 2016 02:29
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Ghost
@ghost~56c733f2e610378809c24d2c
Feb 23 2016 02:30
if i remember a private is within a function and public are outside of one?
bitgrower
@bitgrower
Feb 23 2016 02:30
basically .. you need to create 2 methods ... a getter method and a setter method to access the private variable ...
@travisboss -- more like this. precedes your public functions, and without it, they would be private ...
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 02:31
@dcnr there’s something about not “reinventing” the wheel, tho…that’s where I am wondering if I’m wasting my time trying to do a complex algorithms that isn’t really designed by FCC’ers in mind.
bitgrower
@bitgrower
Feb 23 2016 02:31
I believe ...
@pkshreeman -- sorta depends on what your objective is ... :)
personally -- it might be more worthwhile to figure out how to create cool eye candy for your front end projects ...
Norman Dela Cruz
@dcnr
Feb 23 2016 02:33
@pkshreeman I just try to follow "make something that works then refactor later"
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 02:34
@bitgrower true….get a paying job…….exactly…eye candies… I already have PhD in Nanoscale doing insanely complex algorithms for statistical x-ray diffraction for thin films, and it got me no where.
bitgrower
@bitgrower
Feb 23 2016 02:34
oooh cool, does that mean you can understand Roz Franklin's stuff ?
Norman Dela Cruz
@dcnr
Feb 23 2016 02:34
@pkshreeman many things gets us nowhere nowadays :(
bitgrower
@bitgrower
Feb 23 2016 02:35
@pkshreeman -- sounds like you should be well-suited to getting into Big Data ... :)
Richard Corbett
@reacorbett
Feb 23 2016 02:35

@bitgrower i dont understand what to do with the setGear function.

this.getGear = function(){
return gear;
}

That, I beleive, is right.

bitgrower
@bitgrower
Feb 23 2016 02:35
yep
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 02:35
@bitgrower lol…not familiar with R.Franklin…seems she does DNA crystallography…..@dcnr true… I’d be glad to get started on Big Data, but not sure where to start
bitgrower
@bitgrower
Feb 23 2016 02:36
(did -- died too soon to be part of the Nobel Prize for it, though her student Wilkins shared in the prize) ...
Norman Dela Cruz
@dcnr
Feb 23 2016 02:36
@pkshreeman @bitgrower said that big data part :P
though I thought data oriented people are all learning python, or R
bitgrower
@bitgrower
Feb 23 2016 02:37
I was gonna do my tribute on her ... but I've decided I'm gonna change and do it on the guy who came up with PGP ... it seems particularly apropos right now ...
Norman Dela Cruz
@dcnr
Feb 23 2016 02:37
python has great scientific/math libs
bitgrower
@bitgrower
Feb 23 2016 02:37
@dncr -- and hadoop ...
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 02:38
what happened to C++?
Norman Dela Cruz
@dcnr
Feb 23 2016 02:38
dunno, got eaten by C#?
died at c11?
Otman Bouchari
@obouchari
Feb 23 2016 02:38
Hhaha
bitgrower
@bitgrower
Feb 23 2016 02:39
there's a great yt video out there -- something like the 10 languages you should learn in 2016 -- it has good breakdown of various languages and why you might want to learn one over another ... as in ... which specific companies, industries want which languages ...
Otman Bouchari
@obouchari
Feb 23 2016 02:39
They ruined C by adding ++
bitgrower
@bitgrower
Feb 23 2016 02:39
swift won't get you a job at Google, most likely ... :)
Otman Bouchari
@obouchari
Feb 23 2016 02:40
Python maybe will ;)
bitgrower
@bitgrower
Feb 23 2016 02:40
hahahahaha @obouchari -- I used to tell people who complained about C++ that we should all go back to assembly ... :)
Norman Dela Cruz
@dcnr
Feb 23 2016 02:40
@bitgrower just you wait, we'll get swift on android
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 02:40
Introducing C--
Norman Dela Cruz
@dcnr
Feb 23 2016 02:40
@bitgrower and kill kotlin off
bitgrower
@bitgrower
Feb 23 2016 02:40
hey I bought my first copy of Kernigan & Ritchie for $17 ...
Norman Dela Cruz
@dcnr
Feb 23 2016 02:41
must have been expensive back then lol
bitgrower
@bitgrower
Feb 23 2016 02:41
before you had to type your parameters ... :)
actually @dcnr -- I think it was pretty reasonably priced ...
Norman Dela Cruz
@dcnr
Feb 23 2016 02:42
@bitgrower paid off in the long run eh
shrug ... I guess ...
golfguy1984
@golfguy1984
Feb 23 2016 02:42
Screen Shot 2016-02-22 at 9.42.02 PM.png
where do i start
?
bitgrower
@bitgrower
Feb 23 2016 02:42
@reacorbett -- how ya doing ...
Otman Bouchari
@obouchari
Feb 23 2016 02:42
@pkshreeman Try Udacity they have some good courses
All courses are free
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 02:43
@obouchari yeah? Thanks for tip.
CamperBot
@camperbot
Feb 23 2016 02:43
pkshreeman sends brownie points to @obouchari :sparkles: :thumbsup: :sparkles:
:star: 372 | @obouchari | http://www.freecodecamp.com/obouchari
Richard Corbett
@reacorbett
Feb 23 2016 02:43
var Bike = function() {

  // Only change code below this line.
  var gear = 0;

  this.getGear =function(){
    return gear;
  };

  this.setGear = function(){

  };

};

var myCar = new Car();

var myBike = new Bike();
I really have no idea what to do with setGear. That is the only thing I am not understanding.
bitgrower
@bitgrower
Feb 23 2016 02:43
what does the Car object methods do ?
golfguy1984
@golfguy1984
Feb 23 2016 02:43
also how do you guys add screenshots from your challenges i dont think i did it right
bitgrower
@bitgrower
Feb 23 2016 02:44
like the this.accelerate function ?
@golfguy ... watch below
explain format
CamperBot
@camperbot
Feb 23 2016 02:44

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

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

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

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

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

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

Otman Bouchari
@obouchari
Feb 23 2016 02:44
@golfguy1984 you don’t do screenshot just copy/paste the code here
bitgrower
@bitgrower
Feb 23 2016 02:44
you will need to follow the insstructions EXACTLY or it won't work ... so pay close attention ...
golfguy1984
@golfguy1984
Feb 23 2016 02:45
thanks @obouchari
CamperBot
@camperbot
Feb 23 2016 02:45
golfguy1984 sends brownie points to @obouchari :sparkles: :thumbsup: :sparkles:
:star: 373 | @obouchari | http://www.freecodecamp.com/obouchari
bitgrower
@bitgrower
Feb 23 2016 02:45
the last time I suggested it as a prelimary "what is your potential as a programmer" test, the camper got it first time, right off the bat ... but most of the time people don't read carefully enough ...
Norman Dela Cruz
@dcnr
Feb 23 2016 02:45

@golfguy1984
yeah have to be this format, you can replace the js with html or css too if that's your code
```js

<paste code here>
```

Those are 3 backquotes, the key above tab, left of 1, and below esc.
You can create a new line by shift+enter so to format it'll be:
```js (shift+enter)(paste code)(shift+enter) ```

@reacorbett just think of setGear as a separate function, it should accept a parameter and you are setting gear's value to that
bitgrower
@bitgrower
Feb 23 2016 02:46
ahh ... dang, @dcnr ... :(
golfguy1984
@golfguy1984
Feb 23 2016 02:46
This message was deleted
Norman Dela Cruz
@dcnr
Feb 23 2016 02:47
@bitgrower eh why
bitgrower
@bitgrower
Feb 23 2016 02:47
wanted to see if he'd get it by looking at the Car this.accelerate method
Norman Dela Cruz
@dcnr
Feb 23 2016 02:48
@bitgrower I think @reacorbett should read up on what objects in js really are before moving on with this one
bitgrower
@bitgrower
Feb 23 2016 02:49
well, the info IS dense in the instructions .... but it does seem to be there ...
now ... what was the site with the regex tutorial you gave me the other day ? Eh, my friend, @dcnr ?
btw cool eye candy, @reacorbett -- http://codepen.io/reacorbett/full/EPzmqY/
Richard Corbett
@reacorbett
Feb 23 2016 02:51
@bitgrower thanks.
CamperBot
@camperbot
Feb 23 2016 02:51
reacorbett sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: reacorbett already gave bitgrower points
Norman Dela Cruz
@dcnr
Feb 23 2016 02:52
@bitgrower I only remember giving you these two
http://www.regular-expressions.info/
http://regexone.com/
Richard Corbett
@reacorbett
Feb 23 2016 02:52
@bitgrower @dcnr I think I am going to take a couple of steps back.
Norman Dela Cruz
@dcnr
Feb 23 2016 02:53
@reacorbett good luck! if you get frustrated, take a break too!
Otman Bouchari
@obouchari
Feb 23 2016 02:54
@reacorbett There is also FrontEnd Masters you pay monthly but they have some greate workshops
bitgrower
@bitgrower
Feb 23 2016 02:55
@reacorbett -- what are you using to get the parallax effect ?
Otman Bouchari
@obouchari
Feb 23 2016 02:56
@bitgrower I don’t think there is a parallax its just fixed BG
bitgrower
@bitgrower
Feb 23 2016 02:56
ah, okay ... thanks @obouchari ...
CamperBot
@camperbot
Feb 23 2016 02:56
bitgrower sends brownie points to @obouchari :sparkles: :thumbsup: :sparkles:
:star: 374 | @obouchari | http://www.freecodecamp.com/obouchari
Richard Corbett
@reacorbett
Feb 23 2016 02:56
@bitgrower they are two different images.
bitgrower
@bitgrower
Feb 23 2016 02:57
got it ...
thanks @reacorbett
CamperBot
@camperbot
Feb 23 2016 02:57
bitgrower sends brownie points to @reacorbett :sparkles: :thumbsup: :sparkles:
:star: 252 | @reacorbett | http://www.freecodecamp.com/reacorbett
Norman Dela Cruz
@dcnr
Feb 23 2016 02:58
for the ziplines, must it be on codepen?
Otman Bouchari
@obouchari
Feb 23 2016 02:59
@reacorbett Good job!
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 02:59
@dcnr it says "Objective: Build a CodePen.io app that is functionally similar to this:"
bitgrower
@bitgrower
Feb 23 2016 02:59
dunno ... I think it makes it easier ... and you don't have to worry about someone hacking your website, and people can fork it -- or you can fork theirs, if you want ...
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 03:00
I think the whole point is to keep the whole FCC resume open…including your ziplines….if you look at your profile, you have option to disable your solution viewing by public but lose your certificate as result.
and I learn lot using it.
although if you do it on your own (either using github or other hosting website), it is a bit different..just a little.
Norman Dela Cruz
@dcnr
Feb 23 2016 03:02
@pkshreeman @bitgrower I mean, if you can do it on your own server, will that be accepted? I haven't done any of the front end projects on codepen but I did the c9.io ones locally instead of on c9. How does FCC check? It feels like they just trust you that you've done it.
Richard Corbett
@reacorbett
Feb 23 2016 03:03
var Bike = function() {
  var gear =0;
  // Only change code below this line.
  this.getGear = function(){
    return gear;
  };
  this.setGear = function(set){
    gear += set;
  };
};

var myCar = new Car();

var myBike = new Bike();
ok, I am getting closer here.
Norman Dela Cruz
@dcnr
Feb 23 2016 03:03
@reacorbett real close! the keyword is set :D
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 03:03
@dcnr I did see some comments about “checking the work” when you apply for certificate…but not sure if they are able to sustain the amount of volunteer hours or...
Norman Dela Cruz
@dcnr
Feb 23 2016 03:06
@pkshreeman hmm maybe it's in one of the wikis or something
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 03:07
ask SaintPeter?
Norman Dela Cruz
@dcnr
Feb 23 2016 03:08
yeah I should! thanks @pkshreeman
CamperBot
@camperbot
Feb 23 2016 03:08
dcnr sends brownie points to @pkshreeman :sparkles: :thumbsup: :sparkles:
:star: 316 | @pkshreeman | http://www.freecodecamp.com/pkshreeman
Dr. Paul Kenneth Shreeman
@pkshreeman
Feb 23 2016 03:09
Np
Otman Bouchari
@obouchari
Feb 23 2016 03:09
@reacorbett You want to set a new value to gear not to increment it :)
Richard Corbett
@reacorbett
Feb 23 2016 03:09
You can't be down to earth if you never sit on the ground.
var Bike = function() {
  var gear =0;
  // Only change code below this line.
  this.getGear = function(){
    return gear;
  };
  this.setGear = function(set){
    gear = set;
  };
};

var myCar = new Car();

var myBike = new Bike();
Marc
@wumpafruits
Feb 23 2016 03:09
function myFunction() {
  'use strict';

  var myVar = "foo";
  console.log(myVar);
}
myFunction();

// run and check the console 
// myVar is not defined outside of myFunction

console.log(myVar);
// now remove the console log line to pass the test

Instructions:

Instructions
Declare a local variable myVar inside myFunction

I've tried removing the console logs

jdenver90
@jdenver90
Feb 23 2016 03:12
Has anybody finished this one:

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

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty('gift')) {
return myObj.gift;
}
return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");

can I check for multiple properties in the one if statement?
DJ
@qualitymanifest
Feb 23 2016 03:12
@wumpafruits if you remove the console logs and its not working still, try refreshing the page and trying again
@jdenver90 don't hardcode a property like "gift", use the checkProp parameter to the function.
Marc
@wumpafruits
Feb 23 2016 03:13
@qualitymanifest that worked, thankyou
Richard Corbett
@reacorbett
Feb 23 2016 03:15
@dcnr thanks
CamperBot
@camperbot
Feb 23 2016 03:15
reacorbett sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 696 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 23 2016 03:15
you did all the work :D but thanks too @reacorbett
CamperBot
@camperbot
Feb 23 2016 03:15
dcnr sends brownie points to @reacorbett :sparkles: :thumbsup: :sparkles:
:star: 254 | @reacorbett | http://www.freecodecamp.com/reacorbett
jdenver90
@jdenver90
Feb 23 2016 03:16
@qualitymanifest can you elaborate for me, im like a total idiot when it comes to javascript
@qualitymanifest just replace 'gift' with the checkProp parameter?
DJ
@qualitymanifest
Feb 23 2016 03:17
@jdenver90 yes, in hasOwnProperty()
your return will have to be modified a little as well
@jdenver90 i made this example about dot notation vs bracket notation: https://repl.it/BiMh/6 hit "run" and look at the examples where i used the function parameter
golfguy1984
@golfguy1984
Feb 23 2016 03:21
could someone help me with this i dont think im anywhere close

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
var madLib = "The " + myAdjective + myNoun + myVerb + myAdverb + " down the road.";

// Your code above this line
return result;
}

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

Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:22
@golfguy1984 add spaces between the words in your madlib
@golfguy1984 like string1 + " " + string2
golfguy1984
@golfguy1984
Feb 23 2016 03:23
AHHHHH ok let me try that @NickEU
@NickEU I added them and it still didn’t pass the test
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:25
@golfguy1984 you have to change the result variable
@golfguy1984 not add your your madlib variable :)
golfguy1984
@golfguy1984
Feb 23 2016 03:28
@NickEU that worked thanks so much
CamperBot
@camperbot
Feb 23 2016 03:28
golfguy1984 sends brownie points to @nickeu :sparkles: :thumbsup: :sparkles:
:star: 381 | @nickeu | http://www.freecodecamp.com/nickeu
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:28
@golfguy1984 np, always pay attention to what the function is returning and what u actually have to change ;)
jdenver90
@jdenver90
Feb 23 2016 03:31
@qualitymanifest is the if statement appropriate for the function? I can get one of them to pass but I dont know to test all of them
DJ
@qualitymanifest
Feb 23 2016 03:32
@jdenver90 can you paste your current code?
joh9694
@joh9694
Feb 23 2016 03:33
Hey everyone! I'm having a really tough time wrapping my head around converting celsius to farenheit for java script. I feel like I really understand the concept of java but I'm not sure how to use multiple variables and the the inputs to test my code. Can someone please help me?
jdenver90
@jdenver90
Feb 23 2016 03:35

@qualitymanifest
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if(checkObj.hasOwnProperty('checkProp')) {
console.log(myObj.gift);
console.log(myObj.pet);
console.log(myObj.bed);
}

return "Not Found";

}

// Test your code by modifying these values
checkObj("gift");

im sure none of its correct
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:35
@joh9694 java and javascript have pretty much nothing in common, just FYI.. what seems to be the problem?
DJ
@qualitymanifest
Feb 23 2016 03:35

@jdenver90 you're still hardcoding things here

console.log(myObj.gift);
console.log(myObj.pet);
console.log(myObj.bed);

use checkProp, and don't console.log those, return them

Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:35
@jdenver90 checkprop is a variable, you don't need to enclose it in " "
DJ
@qualitymanifest
Feb 23 2016 03:36
@jdenver90 currently your function returns "Not Found" regardless
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:36
@jdenver90 what u're doing is checking for a string literal 'checkProp', not the variable checkProp
DJ
@qualitymanifest
Feb 23 2016 03:36
that too
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:36
lol
joh9694
@joh9694
Feb 23 2016 03:37
oh, thank you for that. I didn't realize there were two things @NickEU So here's what I'm doing so far. I don't feel confident at all with any of it though so don't be afraid to critique harshly. I'm really trying to learn and appreciate your help! var fahrenheit = a;
a = (celsius - 32) * 9/5;
CamperBot
@camperbot
Feb 23 2016 03:37
joh9694 sends brownie points to @nickeu :sparkles: :thumbsup: :sparkles:
:star: 382 | @nickeu | http://www.freecodecamp.com/nickeu
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:38
help formatting
CamperBot
@camperbot
Feb 23 2016 03:38

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

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

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

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

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

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

Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:38
@joh9694 post your function/exercise code here
joh9694
@joh9694
Feb 23 2016 03:39

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

var fahrenheit = a;
a = (celsius - 32) * 9/5;

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

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

Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:39
@joh9694 why are you using variable a?
joh9694
@joh9694
Feb 23 2016 03:39
@NickEU like that or into that thing that popped up?
@NickEU I have no idea. To be honest. I am just trying to figure out how to make it work lol
Norman Dela Cruz
@dcnr
Feb 23 2016 03:39

@joh9694
you can format your code by doing
```js

<paste code here>
```

Those are 3 backquotes, the key above tab, left of 1, and below esc.
You can create a new line by shift+enter so to format it'll be:
```js (shift+enter)(paste code)(shift+enter) ```

AlonzaThompson
@alonzathompson
Feb 23 2016 03:40

String Mutations

function mutation(arr) {
 var str = arr[0].toLowerCase();
 var str1 = arr[1].toLowerCase();
 var pos = str.indexOf(str1);
 for (var i = 0, strlen = str.length; i < strlen; i++){
   pos = str.indexOf(str1[i], pos + 1);
   if(pos == str){
     return true;

   }
 }
}

mutation(["hello", "hey"]);

I pass the majority haven't quite figured what im doing wrong

Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:40
@joh9694 assign the result of your conversion to the fahrenheit variable, not some other variable
AlonzaThompson
@alonzathompson
Feb 23 2016 03:40
I passed the majority of the test dont know what im doing wrong
joh9694
@joh9694
Feb 23 2016 03:41
@NickEU so if I do that but just take out a?
AlonzaThompson
@alonzathompson
Feb 23 2016 03:41
soory wrong code
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:41
@joh9694 you haven't been able to provide a good explanation for why do you need a in the first place... so maybe you don't need it after all?
joh9694
@joh9694
Feb 23 2016 03:41

'''js function convert(celsius) {
// Only change code below this line

var fahrenheit = (celsius - 32) * 9/5;

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

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

CamperBot
@camperbot
Feb 23 2016 03:41
:bulb: to format code use backticks! ``` more info
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:42
also T(°F) = T(°C) × 9/5 + 32
or T(°F) = T(°C) × 1.8 + 32
joh9694
@joh9694
Feb 23 2016 03:43
@NickEU I really don't think I need it at all. I think I was using it just to understand the code. I do see how just assigning it to f would work but then how OHHHH
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:43
@joh9694 it would not work, because that's not how value types work.. u're assigning a value, not a reference to a value
joh9694
@joh9694
Feb 23 2016 03:43
@NickEU That's EXACTLY what I needed lol
I just didn't understand how you can make them related
@NickEU how do you tell it to take it from celsius to F? IF that makes sense like that would be me telling it to compare apples and oranges without me telling it they are both fruits. how to do you let it know they're both temperatues/fruits
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:46
@joh9694 tell it = tell who again? :D
joh9694
@joh9694
Feb 23 2016 03:47
@NickEU I'm useless hahaha I'm so sorry. Tell javascript. Is that a thing? Like I have to let it know what we are working with before it understands the algorithm? or no?
@NickEU I wouldn't be mad if you were laughing at me right now. I have no idea what I'm doing at the present hahahah
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:49
@joh9694 i'm really having a hard time understanding what you mean... maybe you're trying it to make a little too complicated? you have a function, it accepts one argument when it's being called = the number that's storing the temperature in celsius.... You can work with that celsius variable in your function body... Your job is to make that function do the conversion and return the temperature in fahrenheit.... you're creating a new fahrenheit variable, you're doing the conversion with the celsius variable and assigning the result of that conversion to your fahrenheit variable which you later return
joh9694
@joh9694
Feb 23 2016 03:51
@NickEU if you were to create the code for it. what would it look like or just an example. I don't remember doing any functions that were relative to one another and when i google it makes it way more complex than I've seen yet
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:51
@joh9694 what do you mean relative to one another?
Marc
@wumpafruits
Feb 23 2016 03:52
I feel like I'm not going to understand JavaScript until I work on the projects for awhile
I'm halfway through the Basics
joh9694
@joh9694
Feb 23 2016 03:52
@NickEU like making a=b I know how to make b equal things and a equal things but how do you make them relative to one another
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:53
@joh9694 why would you want to do that? that's not how the language works value types don't work like that... numbers/strings are value types... only reference types work like that.. arrays and objects
@joh9694 there's no need for a second variable in your particular example anyway
joh9694
@joh9694
Feb 23 2016 03:54
@NickEU I'm gonna review things and see if I can get it. Thank you for your help lol I'm just at a way lower level in understanding /:
CamperBot
@camperbot
Feb 23 2016 03:54
joh9694 sends brownie points to @nickeu :sparkles: :thumbsup: :sparkles:
:warning: joh9694 already gave nickeu points
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:54
@joh9694 look just message me in private chat, let's go over shit
joh9694
@joh9694
Feb 23 2016 03:55
@NickEU how do you private chat?
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:55
@joh9694 click my picture to bring up the menu
joh9694
@joh9694
Feb 23 2016 03:56
@NickEU Should it bring up a seperate page? or do you want me to email you?
Nikolajs Korolkovs
@NickEU
Feb 23 2016 03:57
@joh9694 it brings up a bunch of menu buttons
Greg D
@mosaic-greg
Feb 23 2016 04:13
hi i've made some progress with profile lookup but have error
TypeError: can't convert undefined to object
Nikolajs Korolkovs
@NickEU
Feb 23 2016 04:13
show it
the code, not the error ;)
Greg D
@mosaic-greg
Feb 23 2016 04:13
function lookUp(firstName, prop) {

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

    //below loop should be Object.keys(contacts[i]).length
    for (j = 0; j <Object.keys(contacts[i]).length; i++) {
     \\ console.log("ok")
     console.log(contacts[i].firstName == (firstName) + " and " + contacts[i].hasOwnProperty(prop))
    };
  }
}
edited
ok. at the testing phase
Nikolajs Korolkovs
@NickEU
Feb 23 2016 04:15
@mosaic-greg contacts variable is.... what exactly? :D
Greg D
@mosaic-greg
Feb 23 2016 04:15
ok ill post the whole code
Nikolajs Korolkovs
@NickEU
Feb 23 2016 04:16
nvm, found it
Greg D
@mosaic-greg
Feb 23 2016 04:17
cool
i just corrected the i to j at the end of the j loop
Nikolajs Korolkovs
@NickEU
Feb 23 2016 04:21
@mosaic-greg ye, that was the reason
Greg D
@mosaic-greg
Feb 23 2016 04:21
:) that's a nice cat there
thanks @NickEU
CamperBot
@camperbot
Feb 23 2016 04:21
mosaic-greg sends brownie points to @nickeu :sparkles: :thumbsup: :sparkles:
:star: 383 | @nickeu | http://www.freecodecamp.com/nickeu
Nikolajs Korolkovs
@NickEU
Feb 23 2016 04:21
@mosaic-greg declare your for loop variables with var btw
Greg D
@mosaic-greg
Feb 23 2016 04:22
aw yeah localise the scope
just in case
ok putting brackets around (contacts[i].firstName == (firstName)) gave me result i was after
Greg D
@mosaic-greg
Feb 23 2016 04:27
forking is proving very useful for debugging while coding
mitch
@mitchxps
Feb 23 2016 04:27
stuck on " Mutations" can somebody lend a hand....i dont want the answer just a hint at which part i have wrong

function mutation(arr) {

var lower = []; //string converted to lower case

for(i = 0;i < arr.length;i++){  //loop that converts string to lower case
lower.push(arr[i].toLowerCase());
}

var cut1 = lower.splice(0,1); //cut string in half to compare
var cut2 = lower.splice(cut1,2); // other half of string to compare
var final = cut2.indexOf(cut1);

if (final !== 1){
return false;
}
else {
return true;
}

return final;

}

mutation(["hello", "hey"]);

dogsdogsdogs123
@dogsdogsdogs123
Feb 23 2016 04:32

can somebody tell me what i'm doing wrong for Accessing Objects Properties with Variables

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var player = testObj[16]; // Change this Line
var playerNumber = testObj[player]; // Change this Line

V Arun Kumar
@arunvkumr
Feb 23 2016 04:33
@mitchxps indexOf method returns the index value if it find the value in array, -1 otherwise if not found.
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf
cannelflow
@cannelflow
Feb 23 2016 04:34
@dogsdogsdogs123 you need to create playerNumber variable you created player
Antoine Leclercq
@antoineLeclercq
Feb 23 2016 04:35
@dogsdogsdogs123 var playerNumber = testObj[player]; this will not work, if you want the number depending on the player you’re gonna have to use some conditional expression I think. What do you want playerNumber to be exactly?
dogsdogsdogs123
@dogsdogsdogs123
Feb 23 2016 04:35
player number should be 16
mitch
@mitchxps
Feb 23 2016 04:35
thanks ill read up on it @arunkumrv
CamperBot
@camperbot
Feb 23 2016 04:35
mitchxps sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 281 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Monty
@webdev8183
Feb 23 2016 04:36
return boolean values from functions javascript seems broken..
Antoine Leclercq
@antoineLeclercq
Feb 23 2016 04:36
@dogsdogsdogs123 the problem is that you want to access the key via the value
@dogsdogsdogs123 with the way javascript works, objects are only accessible by keys, not by values obj[key]
dogsdogsdogs123
@dogsdogsdogs123
Feb 23 2016 04:37
hmm
Oscar Sanchez
@rubyRune
Feb 23 2016 04:37
Would anyone know why I'm not getting my code to return "No such contact" ?
//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 lookUp(firstName, prop){
// Only change code below this line
     for (var i = 0 ; i < contacts.length++; i++){
        if (contacts[i].firstName === firstName){
            if (contacts[i][prop]){
                return contacts[i][prop];
            }else{
                return "No such property";
            }    
        }
}
  return "No such contact";

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
Antoine Leclercq
@antoineLeclercq
Feb 23 2016 04:38
@rubyRune i < contacts.length++ ? in your for loop
dogsdogsdogs123
@dogsdogsdogs123
Feb 23 2016 04:39
so how would i use 16 as a key?
Rex Schrader
@SaintPeter
Feb 23 2016 04:39
@webdev8183 It is probably not broken.
Oscar Sanchez
@rubyRune
Feb 23 2016 04:39
@antoineLeclercq omg thank you so much haha I thought I was crazy thanks bud.
CamperBot
@camperbot
Feb 23 2016 04:39
rubyrune sends brownie points to @antoineleclercq :sparkles: :thumbsup: :sparkles:
:star: 352 | @antoineleclercq | http://www.freecodecamp.com/antoineleclercq
Antoine Leclercq
@antoineLeclercq
Feb 23 2016 04:40
@dogsdogsdogs123 in the object you used in your example, the numbers are the keys:
var object = {
  key1 : value1,
  key2: value2,
  key3: value3
};
Monty
@webdev8183
Feb 23 2016 04:40

maybe not, not sure what I am missing looks like it should be working but its failing on a test case. function isLess(a, b) {
// Fix this code
return a === b;

}

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

Antoine Leclercq
@antoineLeclercq
Feb 23 2016 04:40
@rubyRune no problem :)
dogsdogsdogs123
@dogsdogsdogs123
Feb 23 2016 04:41
yes I understand
Antoine Leclercq
@antoineLeclercq
Feb 23 2016 04:41
@webdev8183 you want to return true if a is less than b?
dogsdogsdogs123
@dogsdogsdogs123
Feb 23 2016 04:42
also how do I paste my code so that it comes into the chat like you guys?
Monty
@webdev8183
Feb 23 2016 04:42
it wants me too do that but its not working, I thought maybe my () were messing it up this waypoint checkpoint thing is kinda buggy on here..
Antoine Leclercq
@antoineLeclercq
Feb 23 2016 04:43
@dogsdogsdogs123 let me give you a link
V Arun Kumar
@arunvkumr
Feb 23 2016 04:43
help format
CamperBot
@camperbot
Feb 23 2016 04:43

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

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

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

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

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

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

dogsdogsdogs123
@dogsdogsdogs123
Feb 23 2016 04:44

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

   // Change this Line

var player = testObj[16]; // Change this Line
var playerNumber = testObj[player];

'''
// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

   // Change this Line

var player = testObj[16]; // Change this Line
var playerNumber = testObj[player];
'''

CamperBot
@camperbot
Feb 23 2016 04:44
:bulb: to format code use backticks! ``` more info
Antoine Leclercq
@antoineLeclercq
Feb 23 2016 04:45
@webdev8183 I think you’re not checking for the right thing
dogsdogsdogs123
@dogsdogsdogs123
Feb 23 2016 04:45
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

       // Change this Line
var player = testObj[16];   // Change this Line
var playerNumber = testObj[player];
Antoine Leclercq
@antoineLeclercq
Feb 23 2016 04:45
@webdev8183 your code states a === b what you want is a less than b
dogsdogsdogs123
@dogsdogsdogs123
Feb 23 2016 04:46
ok so how am I not using the correct key to retrieve 16 from testObj?
because player retrieves "Montana" but playerNumber does not retrieve 16
Antoine Leclercq
@antoineLeclercq
Feb 23 2016 04:46
@dogsdogsdogs123 16 is a key, Montana is a value
V Arun Kumar
@arunvkumr
Feb 23 2016 04:46
@dogsdogsdogs123 testObj[16] return Montana. and your using Montana as key to find value in testObj which doesn't exist.
Monty
@webdev8183
Feb 23 2016 04:47
um the directions say Since === returns true or false, we can simply return the result of the comparison:
maybe they have secret javascript powers they aren't sharing with the rest of the class, since my javascript doesn't work lol
Antoine Leclercq
@antoineLeclercq
Feb 23 2016 04:48
@webdev8183 which challenge are you on
Rex Schrader
@SaintPeter
Feb 23 2016 04:48
@dogsdogsdogs123 I think you may have reversed the order of the sample code. You should reset your code and try again.
dogsdogsdogs123
@dogsdogsdogs123
Feb 23 2016 04:50
var playerNumber = testObj;       // Change this Line
var player = testObj[16];   // Change this Line
So which operator can I use to get the key instead of the value?
Tim Bell
@MindfulBell
Feb 23 2016 04:52
@dogsdogsdogs123 if you want to grab keys from an object I believe you have to use Object.keys
V Arun Kumar
@arunvkumr
Feb 23 2016 04:52
@dogsdogsdogs123 assign value to playeNumber and use the playerNumber value as key to get Montana.
dogsdogsdogs123
@dogsdogsdogs123
Feb 23 2016 04:53
Okay it works, but I dont see how accessing objects this way is useful...
Antoine Leclercq
@antoineLeclercq
Feb 23 2016 04:56
@dogsdogsdogs123 well you have to define your object the way you think it should be accessed. So if what you know is the name of the player and you want to get the number of the player you should define your object the other way around, the keys should be the players name and the value their associated number.
@dogsdogsdogs123 example ’Montana’ : 16
AlonzaThompson
@alonzathompson
Feb 23 2016 05:23

String Mutation I get them all right except for one.

function mutation(arr) {
 var str1 = arr[1].toLowerCase();
 var str = arr[0].toLowerCase();

  for (var i = 0; i < str.length; i++){
    if(str.indexOf(str1[i]) < 0){
      return false; 
    }
     return true;
  }
}

mutation(["hello", "hey"]);

Any help I gladly appreciate it

this is the one that I get wrong
mutation(["hello", "hey"]) should return false.
philipsiu
@philipsiu
Feb 23 2016 05:30
@alonzothompson Move the return true; outside of the for loop.
DJ
@qualitymanifest
Feb 23 2016 05:31
@alonzothompson that :point_up: and you will need to change for (var i = 0; i < str.length; i++){
you need to loop over the characters in the second argument, not the first
chaya
@chayakrishnaprasad
Feb 23 2016 05:36
find Make a Person
CamperBot
@camperbot
Feb 23 2016 05:36

find make a person

:zero: algorithm make a person

philipsiu
@philipsiu
Feb 23 2016 05:38
find Seek and Destroy
CamperBot
@camperbot
Feb 23 2016 05:38

find seek and destroy

:zero: algorithm seek and destroy

AlonzaThompson
@alonzathompson
Feb 23 2016 05:40
@qualitymanifest & @philthyfill thanks for the help
CamperBot
@camperbot
Feb 23 2016 05:40
alonzothompson sends brownie points to @qualitymanifest and @philthyfill :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for philthyfill
:star: 993 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
AlonzaThompson
@alonzathompson
Feb 23 2016 05:40
@philthyfill thanks
Monty
@webdev8183
Feb 23 2016 05:44
apparently its too late to count cards, I am getting nowhere with this one.. anyone got any tips aside from avoid blackjack lol
sudheerswamy
@sudheerswamy
Feb 23 2016 05:44
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Change the provided string from double to single quotes and remove the escaping.
sudheerswamy
@sudheerswamy
Feb 23 2016 05:50
need help.
Ken
@phanlinhkhuong
Feb 23 2016 05:55
@sudheerswamy here is your answer: var myStr = '<a href="http://www.example.com" target="_blank">Link</a>'
Richard Corbett
@reacorbett
Feb 23 2016 06:02
help javascript
CamperBot
@camperbot
Feb 23 2016 06:02

:point_right: challenge add new properties to a javascript object [wiki]

Add New Properties to a JavaScript Object

You can add new properties to existing JavaScript objects the same way you would modify them. Here is how: myDog.bark = "woof-woof";

:pencil: read more about challenge add new properties to a javascript object on the FCC Wiki

Caleb Martin
@caleb272
Feb 23 2016 06:05
```
  function getLocation() {
    var myLocation = ["failed"];

    if (navigator.geolocation) {
      myLocation = navigator.geolocation.getCurrentPosition(function (position) {
        return [position.coords.latitude, position.coords.longitude];
      });

    }

    return myLocation;
  }
can someone tell me how to set myLocation to the array the function is returning
Olawale Akinseye
@brainyfarm
Feb 23 2016 06:24
@caleb272 everything you do should be done inside your getCurrentPosition function.
chaya
@chayakrishnaprasad
Feb 23 2016 06:24
find exact change
CamperBot
@camperbot
Feb 23 2016 06:24

find exact change

:zero: algorithm exact change

Caleb Martin
@caleb272
Feb 23 2016 06:24
ok thanks @brainyfarm
CamperBot
@camperbot
Feb 23 2016 06:24
caleb272 sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1533 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
JackeL
@jackel27
Feb 23 2016 06:38
herrow
Rdevs
@Rdevs
Feb 23 2016 06:41
Hey guys , how do i complete this challenge
v
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
andreicostin
@andreicostin
Feb 23 2016 06:42
Hello Everybody. I am at the Profile Lookup Chalange and I got to a point where I don't get why its happening what's happening... :) Maybe some of you can help

`//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 lookUp(firstName, prop){
// Only change code below this line
for (i =0; i < contacts.length; i++) {
if(firstName === contacts[i].firstName) {
thisContact = contacts[i][prop];
for (j=0; j < thisContact.length; j++) {
return thisContact[j];
}
}
}

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");'`

I don't understand why the second loop returns only the first value
andreicostin
@andreicostin
Feb 23 2016 06:48
Pizza in my case
Bartek
@dyczol
Feb 23 2016 06:48
hey guys, working on "return longest string". any suggestions or hints please ? thanks in advance
function findLongestWord(str) {
  var strSplit = str.split(" ");
  var final = 0;
  for(var i = 0; i < strSplit[i].length; i++){
    if(final < strSplit[i].length){
      strSplit[i].length = final;
    }
  }
  return final;
}
@Rdevs paste your code
Rdevs
@Rdevs
Feb 23 2016 06:50
@dyczol i sorted it out. Thanks anyways :smile:
CamperBot
@camperbot
Feb 23 2016 06:50
rdevs sends brownie points to @dyczol :sparkles: :thumbsup: :sparkles:
:star: 253 | @dyczol | http://www.freecodecamp.com/dyczol
Bartek
@dyczol
Feb 23 2016 06:50
thanks for brownies :D
Praneeth
@praneethkumarpidugu
Feb 23 2016 06:50
Hi guys
sudheerswamy
@sudheerswamy
Feb 23 2016 06:51
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Praneeth
@praneethkumarpidugu
Feb 23 2016 06:51
function repeat(str, num) {
  // repeat after me
  //somenumber = -num;
  if(num == (num * -1)){
    return "";
  }
  else{
    return str.repeat(num);
  }
  //return str.repeat(num);
}

repeat("abc", 3);
I get the else condition pass the tests
But I’m unable to represent empty string
The above is challenge “repeat a string repeat a string"
sudheerswamy
@sudheerswamy
Feb 23 2016 06:51
Change the provided string from double to single quotes and remove the escaping
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Rdevs
@Rdevs
Feb 23 2016 06:51
@dyczol :D I
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 06:52
@dyczol try final=strSplit[i].length in the if condition not the other way around
uriznik
@uriznik
Feb 23 2016 06:52
@dyczol check where you should update the 'final' var
andreicostin
@andreicostin
Feb 23 2016 06:54
code
test
code
//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 lookUp(firstName, prop){
// Only change code below this line
  for (i =0; i < contacts.length; i++) {
    if(firstName === contacts[i].firstName) {
        thisContact = contacts[i][prop];    
        for (j=0; j < thisContact.length; j++) {
          return thisContact[j];
        }
    }
}


// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
finally managed to wrap it
sorry :)
Bartek
@dyczol
Feb 23 2016 06:55
@abhishekKumar1 @uriznik works except for when im calling:
  1. findLongestWord("The quick brown fox jumped over the lazy dog") AND
  2. findLongestWord("What if we try a super-long word such as otorhinolaryngology") should return 19.
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 06:56
@dyczol post your updated code
uriznik
@uriznik
Feb 23 2016 06:57
@dyczol check the loop condition, what is getting the length of?
Bartek
@dyczol
Feb 23 2016 06:58
@abhishekKumar1 @uriznik
function findLongestWord(str) {
  var strSplit = str.split(" ");
  var final = 0;
  for(var i = 0; i < strSplit[i].length; i++){
    if(final < strSplit[i].length){
      final = strSplit[i].length;
    }
  }
  return final;
@uriznik it is getting the length of each element of split string
?
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 06:59
ok check your for loop the ending condition is wrong
think when the for loop should end
@andreicostin which problem was this?
Bartek
@dyczol
Feb 23 2016 07:01
it should end at the end of the "new" array...(thinking out loud)
Thomas Honeyman
@thomashoneyman
Feb 23 2016 07:01
@dyczol you might be missing an extra curly brace after “return final;"
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 07:02
so what should be the i< condition in the for loop @dyczol (haha I feel like a teacher :smile: )
Thomas Honeyman
@thomashoneyman
Feb 23 2016 07:03
oh god haha @abhishekKumar1 you’re right
didn’t notice that
Bartek
@dyczol
Feb 23 2016 07:05
@abhishekKumar1 and you're doing grear
*t
got it. so the final correction was
for(var i = 0; i < strSplit.length; i++){
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 07:06
:smile:
Thomas Honeyman
@thomashoneyman
Feb 23 2016 07:06
:clap:
andreicostin
@andreicostin
Feb 23 2016 07:06
don't worry, I found a solution! Thanks all
Bartek
@dyczol
Feb 23 2016 07:06
@saylu @abhishekKumar1 @uriznik thank you
CamperBot
@camperbot
Feb 23 2016 07:06
dyczol sends brownie points to @saylu and @abhishekkumar1 and @uriznik :sparkles: :thumbsup: :sparkles:
:star: 287 | @saylu | http://www.freecodecamp.com/saylu
:star: 310 | @uriznik | http://www.freecodecamp.com/uriznik
:star: 348 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Bartek
@dyczol
Feb 23 2016 07:08
to clarify "strSplit[i].length" is the length of each element of an array, where "strSplit.length" is just the length of an array, correct ?
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 07:09
yup strSplit[i].length is the length of (i+1)-th element in the array
Bartek
@dyczol
Feb 23 2016 07:10
great, just want to make sure i understand what im doing haha
thanks again
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 07:10
np
Ken
@phanlinhkhuong
Feb 23 2016 07:13
code
Bartek
@dyczol
Feb 23 2016 07:21
nocturnally!
Timothy Musimbi
@tmusimbi
Feb 23 2016 07:43

function myTest(val) {
// Only change code below this line

if (val <= 10 || val >= 20) {
return "Outside";
}

// Only change code above this line
return "Inside";
}

// Change this value to test
myTest(15);

why doesnt this code output "Outside"? Any help
Markus Kiili
@Masd925
Feb 23 2016 07:46
@tmusimbi Because 15 is not <=10 or >=20.
Timothy Musimbi
@tmusimbi
Feb 23 2016 07:50
@Masd925 .. Both sides should be false for it to output outside. I cant see a better way to put it. Have tried all possible combinations
Alessandro Bacchiega
@Alessandro994
Feb 23 2016 07:50
I don't remember how to delete a property of a JS object as it is asked in the Record Collection challenge of Javascript.
Can anybody help me please?
Markus Kiili
@Masd925
Feb 23 2016 07:51
@Alessandro994 delete obj[key]
Cam
@CamMakoJ
Feb 23 2016 07:51
working on the weather app
i have everything running except my toggle switch... it's losing the object and returning NaN values after the initial update
Caleb Martin
@caleb272
Feb 23 2016 07:52
do you have to login with your key to use the weather app
Markus Kiili
@Masd925
Feb 23 2016 07:52
@tmusimbi if (val <= 10 || val >= 20) {...} will run the code block if either of the conditions is true.
Alessandro Bacchiega
@Alessandro994
Feb 23 2016 07:53
@Masd925 Oh great! Actually I was dealing with nested objects and I was a bit confused. Thank you a lot!
CamperBot
@camperbot
Feb 23 2016 07:53
alessandro994 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1026 | @masd925 | http://www.freecodecamp.com/masd925
Cam
@CamMakoJ
Feb 23 2016 07:53
@caleb272 yeah i use an api key and it updates the first run
but then if i toggle
it doesnt
Caleb Martin
@caleb272
Feb 23 2016 07:53
what call do you have to make to login
or do you do it with the call to get weather data
Cam
@CamMakoJ
Feb 23 2016 07:54
its not running in the applet because it needs location daata
so i have access to the json
and it loads the location and description
Markus Kiili
@Masd925
Feb 23 2016 07:54
@tmusimbi If val is between 10 and 20, the code block is not run, and code will return "Inside".
Caleb Martin
@caleb272
Feb 23 2016 07:55
I’m on the same challenge as you i don’t know if i make the call to login with my key before i call for the weather data or just put it in the call for the data
Cam
@CamMakoJ
Feb 23 2016 07:57
ahh yeah
i have a simliar scenario
i think we either need to do a promise or a callback...
Caleb Martin
@caleb272
Feb 23 2016 07:57
what do you mean promise
Richard Corbett
@reacorbett
Feb 23 2016 08:01
Has anyone read Eloquent JavaSript by Marijn Haverbeke?
Timothy Musimbi
@tmusimbi
Feb 23 2016 08:09
@Masd925 ... it just doesn't add up. The solution below managed to run but it just doesn't seem right because 10 and 20 are not inclusive.
@Masd925

function myTest(val) {
// Only change code below this line

if (val > 20 || val < 10 ) {
return "Outside";
}

// Only change code above this line
return "Inside";
}

// Change this value to test
myTest(15);

JackeL
@jackel27
Feb 23 2016 08:20
Anyone give some feedback on my code for Sum all primes?
not working for all test cases
but working for most
function sumPrimes(num) {
    var temp = 0;

    function isPrime(p) {
        var c = 0;
        for (var x = 0; x < p; x++) {
            if (p % x === 0) {
                c++;
            }
        }
        if (c === 1) {
            temp += p;
        }
    }
    for (var x = 0; x < num; x++) {
        if (x > 1) {
            isPrime(x);
        }
    }
    return temp;
    // return num;
}
sumPrimes(70);
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 08:27
@jackel27 u r not including the number num in ur code.
JackeL
@jackel27
Feb 23 2016 08:28
@abhishekKumar1 sure I am
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 08:28
nope ur for loop should say for(var x=0;x<=num;x++)
it shold be "<=" not "<"
JackeL
@jackel27
Feb 23 2016 08:29
whaaat
really thats what I missed lol
one sec
hahaha
oh man. thanks
Caleb Martin
@caleb272
Feb 23 2016 08:29
@abhishekKumar1 what am i missing http://codepen.io/thecoder15/pen/mVNywj?editors=0010
JackeL
@jackel27
Feb 23 2016 08:30
@abhishekKumar1 thanks!
CamperBot
@camperbot
Feb 23 2016 08:30
jackel27 sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 349 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 08:31
@caleb272 sorry haven't done that yet so don't know :smile:
RyanKim01
@RyanKim01
Feb 23 2016 08:52
anyone here?
Nicky
@nickyjt16
Feb 23 2016 08:53
Can anyone tell me what I'm doing wrong here please. Its only the first branch of the if statement I'm stuggling with, I think its the output (but the condition could be wrong too for all I know.)
//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 lookUp(firstName, prop){
// Only change code below this line
  for (var contact in contacts) {
    if ((contact.hasOwnProperty(firstName)) && (contact.hasOwnProperty(prop))) {
      return (contact.firstName.prop);
    } else if (contact.hasOwnProperty(firstName) === false) {
      return ("No such contact");
    } else if (contact.hasOwnProperty(property) === false) {
      return ("No such property");
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "shoes");
Nicky
@nickyjt16
Feb 23 2016 08:59
I've just realised, my other if branches arent returning the right output either...
J Player
@Heyjp
Feb 23 2016 09:00
@nickyjt16 "property" doesn't exist, prop does though, but you want to check to see if firstName is in the object before you see if the property doesnt exist.
Nicky
@nickyjt16
Feb 23 2016 09:02
@Heyjp is that not what I'm doing with the first part of my if? I'm confused
I've fixed else if (contact.hasOwnProperty(prop) === false)
Blauelf
@Blauelf
Feb 23 2016 09:08
You should compare contact.firstName and firstName, if those are not equal, testing for property prop does not make much sense.
J Player
@Heyjp
Feb 23 2016 09:09
@nickyjt16 also the loop isn't actually accessing any of the objects
Blauelf
@Blauelf
Feb 23 2016 09:10
Yes, that would be for (var contact of contacts) { (that's ES6, for-of loops an iterable)
Nicky
@nickyjt16
Feb 23 2016 09:12
Ok, back to the drawing board
thanks everyone
JackeL
@jackel27
Feb 23 2016 09:13
hi @Blauelf
Blauelf
@Blauelf
Feb 23 2016 09:13
hi @jackel27
JackeL
@jackel27
Feb 23 2016 09:13
@Blauelf finished sum all primes with no arrays. :D I'm happy.
Blauelf
@Blauelf
Feb 23 2016 09:14
Pretty easy to do so, using two for-loops. What was your approach that makes it special?
JackeL
@jackel27
Feb 23 2016 09:15
I don't know hahaha.
I did....
@Blauelf i'll pm you my solution
sigursiguros
@sigursiguros
Feb 23 2016 09:36
  var register = cid.reduce(function(name,value){
    name.total += value[1];
    name[value[0]] = value[1];
    return name;  
    },{total:0});
}
Hi guys, why is it that if I remove "return name" form this function
return register no longer work?
fluffystub
@RakshithNM
Feb 23 2016 09:40
guys how do i generate a tweet on a click of a button?
is there a place to learn about it
Richard Andrews
@Whiplash5057
Feb 23 2016 09:40
Need help guys ...Im trying the random quote project
fluffystub
@RakshithNM
Feb 23 2016 09:40
?
Richard Andrews
@Whiplash5057
Feb 23 2016 09:41
My JS might wrong ..
Olawale Akinseye
@brainyfarm
Feb 23 2016 09:47
fluffystub
@RakshithNM
Feb 23 2016 09:48
@brainyfarm i am learning at college and cyberoam blocks twitter
@brainyfarm i am learning at college and cyberoam blocks twitter
Olawale Akinseye
@brainyfarm
Feb 23 2016 09:49
You generate a new href for your a element whenever the quote changes @RakshithNM
HHenry88
@HHenry88
Feb 23 2016 09:49
This message was deleted
This message was deleted
CamperBot
@camperbot
Feb 23 2016 09:50
:bulb: to format code use backticks! ``` more info
HHenry88
@HHenry88
Feb 23 2016 09:51

Trying to reverse an array, but not working. Can anyone point out what I'm doing wrong?

```var array = [1,2,3,4,5,6,7];
var newArray = [];

// Only change code below this line.

newArray = array.reverse();```

This message was deleted
Olawale Akinseye
@brainyfarm
Feb 23 2016 09:53
@HHenry88, let the backticks be on a separate line.
HHenry88
@HHenry88
Feb 23 2016 09:53
var array = [1,2,3,4,5,6,7];
var newArray = [];

// Only change code below this line.

newArray = array.reverse();
ah thanks @brainyfarm
CamperBot
@camperbot
Feb 23 2016 09:53
hhenry88 sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
Olawale Akinseye
@brainyfarm
Feb 23 2016 09:53
Nice!
CamperBot
@camperbot
Feb 23 2016 09:53
:star: 1534 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Olawale Akinseye
@brainyfarm
Feb 23 2016 09:54
@HHenry88, your code looks good.
What error are you getting?
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 09:55
@HHenry88 i don't think .reverse returns anything
so instead just write array.reverse()
HHenry88
@HHenry88
Feb 23 2016 09:55
yea, but it keeps saying "you should reverse the array." and "you sohuld use the reverse method"
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 09:55
and then return array
HHenry88
@HHenry88
Feb 23 2016 09:55
okay i'll try that
Blauelf
@Blauelf
Feb 23 2016 09:55
@HHenry88 First backticks should be ```js for javascript (or use html or css instead of js for other code) for nicer colours :)
What is the task in that challenge, as it looks about right?
HHenry88
@HHenry88
Feb 23 2016 09:56
it's reverse Arrays with reverse. javascript
Blauelf
@Blauelf
Feb 23 2016 09:56
No return in those challenges I think. Was the "newArray" part of the code?
HHenry88
@HHenry88
Feb 23 2016 09:56
yes
Neeraj Jha
@Jonsnow21
Feb 23 2016 09:56
hey guys need help with caesars Cipher
HHenry88
@HHenry88
Feb 23 2016 09:56
var array = [1,2,3,4,5,6,7];
var newArray = [];

// Only change code below this line.

newArray = array;
this was the default given
Fredrik E
@freddjah
Feb 23 2016 09:57
@Jonsnow21 what do you have so far?
Neeraj Jha
@Jonsnow21
Feb 23 2016 09:57
can i construct string from a arr by String.fromCharCode(); ?
Blauelf
@Blauelf
Feb 23 2016 09:57
@HHenry88 Are you sure? I get another default code.
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 09:57
just write array.reverse() then
Blauelf
@Blauelf
Feb 23 2016 09:57
Oh, was old code.
Neeraj Jha
@Jonsnow21
Feb 23 2016 09:57
function rot13(str) { // LBH QVQ VG!
  var arr = [];
  for( var i = 0; i < str.length; i++ ){
    if( str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 90 ){
      if( str.charCodeAt(i) > 77 ){
        arr.push(str.charCodeAt(i) - 13);
      } else {
        arr.push(90 - (65 - (str.charCodeAt(i) - 13)) + 1);
      }
    } else {
      arr.push(str.charCodeAt(i));
    }
  }
  return String.fromCharCode(arr);
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Blauelf
@Blauelf
Feb 23 2016 09:59
@HHenry88 So your code from :point_up: 23. Februar 2016 10:53 works for me. Maybe reload the page?
HHenry88
@HHenry88
Feb 23 2016 09:59
i tried, the only error now says "you should reverse the array" after using array.reverse();
Neeraj Jha
@Jonsnow21
Feb 23 2016 09:59
@freddjah u still there?
hey @Blauelf sup?
HHenry88
@HHenry88
Feb 23 2016 09:59
refreshing the page did the trick. oh lord, i worked on that for an hour looking it up
Fredrik E
@freddjah
Feb 23 2016 09:59
@Jonsnow21 You cannot call .fromCharCode like that unforturnately.
HHenry88
@HHenry88
Feb 23 2016 10:00
haha thanks for the help guys
Blauelf
@Blauelf
Feb 23 2016 10:00
@Jonsnow21 fromCharCode does not work like that. Would be String.fromCharCode(...arr) in ES6, or String.fromCharCode.apply(null,arr) in ES5.
Olawale Akinseye
@brainyfarm
Feb 23 2016 10:00
@Jonsnow21, return String.fromCharCode(arr);, it needs a character code and not an array.
Richard Andrews
@Whiplash5057
Feb 23 2016 10:00
Hey guys if I have to change a style like background-color on JS ....How could I do that ....??
Neeraj Jha
@Jonsnow21
Feb 23 2016 10:00
kk
@Blauelf thnx it worked
CamperBot
@camperbot
Feb 23 2016 10:01
jonsnow21 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1279 | @blauelf | http://www.freecodecamp.com/blauelf
Neeraj Jha
@Jonsnow21
Feb 23 2016 10:02
but can u explain .apply(null,arr) part?
hey anyone there?
Fredrik E
@freddjah
Feb 23 2016 10:07
I'm not to sure about that part, sorry @Jonsnow21 but if you still have problems with the code what I would do is rethink the array part of it and focus on directly appending the decoded letters to a string.
fluffystub
@RakshithNM
Feb 23 2016 10:07
@brainyfarm can you check my code?
Neeraj Jha
@Jonsnow21
Feb 23 2016 10:08
ohh that's a smart way to think about it @freddjah
Fredrik E
@freddjah
Feb 23 2016 10:10
@Jonsnow21 Here's a part of my code that might help you on the way decoded += String.fromCharCode(str.charCodeAt(i
Blauelf
@Blauelf
Feb 23 2016 10:10
@Jonsnow21 fn.apply(obj,arr) calls the function fn with the arguments specified by arr (like fn(arr[0],arr[1],arr[2],arr[3],arr[4],...) ), setting the this object to obj. If the object is null or undefined, the global object will be passed instead. I think this is a lot faster than using individual calls to String.fromCharCode, but otherwise, with the individual calls you have no need to store the values in an array.
Fredrik E
@freddjah
Feb 23 2016 10:10
decoded += String.fromCharCode(str.charCodeAt(i)-13);
Neeraj Jha
@Jonsnow21
Feb 23 2016 10:11
function rot13(str) { // LBH QVQ VG!
  var str2 = '';
  for( var i = 0; i < str.length; i++ ){
    if( str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 90 ){
      if( str.charCodeAt(i) > 77 ){
        str2 += String.fromCharCode(str.charCodeAt(i) - 13);
      } else {
        str2 += String.fromCharCode(90 - (65 - (str.charCodeAt(i) - 13)) + 1);
      }
    } else {
      str2 += String.fromCharCode(str.charCodeAt(i));
    }
  }
  return str2;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
yup that's it
thnx @freddjah
CamperBot
@camperbot
Feb 23 2016 10:11
jonsnow21 sends brownie points to @freddjah :sparkles: :thumbsup: :sparkles:
:star: 305 | @freddjah | http://www.freecodecamp.com/freddjah
Olawale Akinseye
@brainyfarm
Feb 23 2016 10:12
@RakshithNM "http://twitter.com/intent/tweet?text=" + randomQuote;
Fredrik E
@freddjah
Feb 23 2016 10:12
@RakshithNM One thing, but not really essential for the challenge I believe, is that you might want to remove the possibility of randomizing the same quote x-times in a row.
@Jonsnow21 Nice! Hope it worked out well!
Neeraj Jha
@Jonsnow21
Feb 23 2016 10:13
hmm
@Blauelf ok i see what u r saying
Blauelf
@Blauelf
Feb 23 2016 10:18

@Jonsnow21 ES6 introduces the spread operator (...), which spreads arrays into individual arguments:

var arr1=[47,11];
var arr2=[];
arr2.push("08", ...arr1, "15"); // same as arr2.push("08"); Array.prototype.push.apply(arr2, arr1); arr2.push("15");
console.log(arr2); // ["08", 47, 11, "15"]

Array.prototype here can be replaced by any array (shorter is for example [].push.apply(...)), as they inherit their push method from Array.prototype.

fluffystub
@RakshithNM
Feb 23 2016 10:31
@freddjah how do i not do it?
can you help me with tweeting on a click
i am trying to give the button the attribute href on click
i have set target"_blank
target="_blank"
it doesnt seem to work
Fredrik E
@freddjah
Feb 23 2016 10:35
@RakshithNM What I did with mine was just that I added an if statement saying that if I get the same random number, randomize the number again, until I get a new value. :)
@RakshithNM With the tweet button, one way of doing it is just wrapping an a element around the button.
@RakshithNM And you can then remove target="_blank" href = "http://twitter.com/intent/tweet?text=.quote" that you have inside your button and paste it to your a-element.
fluffystub
@RakshithNM
Feb 23 2016 10:51
@freddjah i get that and now i am able to open up twitter
@freddjah how do i put in the random quotes as text?
Olawale Akinseye
@brainyfarm
Feb 23 2016 10:51
@RakshithNM, did you see my message?
fluffystub
@RakshithNM
Feb 23 2016 10:52
$("#butt2").on("click",function(){
   $(this).attr('href','http://twitter.com/intent/tweet?text= $(param) = randomQuote ');
 });
Olawale Akinseye
@brainyfarm
Feb 23 2016 10:52
randomQuote is a variable and you put it into a string.
@RakshithNM.
Blauelf
@Blauelf
Feb 23 2016 10:52
This message was deleted
fluffystub
@RakshithNM
Feb 23 2016 10:53
@brainyfarm "generate a new href for your a element whenever the quote changes"
Olawale Akinseye
@brainyfarm
Feb 23 2016 10:53
It is your a element.
When you generate a new quote, you change the href of the a element immediately.
Blauelf
@Blauelf
Feb 23 2016 10:54
@RakshithNM You could give your a-element some ID and use it inside your nextOne function.
Something like .attr('href','http://twitter.com/intent/tweet?text=' + randomQuote) (where randomQuote is defined, so inside nextOne())
Olawale Akinseye
@brainyfarm
Feb 23 2016 10:55
Referring to this means you are selecting #butt2.
@RakshithNM
fluffystub
@RakshithNM
Feb 23 2016 10:56
k...ill try
Olawale Akinseye
@brainyfarm
Feb 23 2016 10:58
Again, randomQuote is a variable @RakshithNM.
You do not enclose it within a string.
Blauelf
@Blauelf
Feb 23 2016 10:59
It is a variable only defined inside nextOne, so only there you can use it.
Prashant Gupta
@darkpasanger
Feb 23 2016 11:01
Can someone please explain me "Word Blanks" Challenges from JavaScript i can not understand it..
fluffystub
@RakshithNM
Feb 23 2016 11:02
@Blauelf @brainyfarm what can i enclose within a string?
Olawale Akinseye
@brainyfarm
Feb 23 2016 11:02
@darkpasanger, add a blank space after each argument and return everything.
Aleksander Gębicki
@Takumar
Feb 23 2016 11:03
@darkpasanger you have to create sentence using given arguments. Words in sentence are usually separated with space, so create variable containing all words, and return it.
Prashant Gupta
@darkpasanger
Feb 23 2016 11:06
@Takumar @brainyfarm thank u guys for the help..
CamperBot
@camperbot
Feb 23 2016 11:06
darkpasanger sends brownie points to @takumar and @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1535 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
:star: 2373 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Feb 23 2016 11:06
@darkpasanger you are welcome :-)
Vera Dordevic
@veradordevic
Feb 23 2016 11:20

var myStr = ("I am a \"double quoted\" string inside \"double quotes\"."); // Change this line

Variable myStr should equal to ("I am a "double quoted" string inside "double quotes""). What did I mess up? :worried:

Neeraj Jha
@Jonsnow21
Feb 23 2016 11:20
@Blauelf i see thanx btw
CamperBot
@camperbot
Feb 23 2016 11:20
jonsnow21 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1280 | @blauelf | http://www.freecodecamp.com/blauelf
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 11:22
@veradordevic it looks all right but no full stop i guess :smile:
James
@jamesgraham10
Feb 23 2016 11:22
hey guys has anyone done the advanced algorithym challenges
J Player
@Heyjp
Feb 23 2016 11:23
@veradordevic you do not need parentheses ()
James
@jamesgraham10
Feb 23 2016 11:24
On the "Exact Change" problem, the third argument is a “2d array listing available currency”, e.g. [“NICKEL”, 2.05] I’m just wondering what the number means. Is that how many Nickels there are in the till? How can there be 2.05 nickels? Confused :worried:
Vera Dordevic
@veradordevic
Feb 23 2016 11:24
@abhishekKumar1 it was that! thanks a lot dude :)
CamperBot
@camperbot
Feb 23 2016 11:24
veradordevic sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 350 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 11:25
@jamesgraham10 no it means how much amount is there in nickels
@veradordevic np
James
@jamesgraham10
Feb 23 2016 11:26
so a Nickel is equivalent to $2.05?
J Player
@Heyjp
Feb 23 2016 11:26
I think its 5 cents
so thats 41 nickels
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 11:27
a nickel is 5 cents so $0.05 and it meant 41 nickels are there
James
@jamesgraham10
Feb 23 2016 11:28
Ah okay I get it! Thanks @abhishekKumar1 @Heyjp :)
CamperBot
@camperbot
Feb 23 2016 11:28
jamesgraham10 sends brownie points to @abhishekkumar1 and @heyjp :sparkles: :thumbsup: :sparkles:
:star: 273 | @heyjp | http://www.freecodecamp.com/heyjp
:star: 351 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Gaurav Singh
@the07
Feb 23 2016 11:28
Hello, i need someone to look at my palindrome function. Though i have got it working, i am not sure if this is the best solution.
Rita Alfonso
@alfonsotech
Feb 23 2016 11:29
@the07 Post your code and I'll take a look
Gaurav Singh
@the07
Feb 23 2016 11:30

function palindrome(str) {
// Good luck!
str = str.toLowerCase();
var array = [];
var i = 0;
while ( i < str.length) {
array.push(str[i]);
i += 1;
}

var newArray = array.filter(function(val){
if (/^[a-z0-9]+$/i.test(val))
return val;
});

str = newArray.join("");
var revstr = newArray.join(newArray.reverse());
if (str === revstr) {
return true;
} else {
return false;
}

}

Rita Alfonso
@alfonsotech
Feb 23 2016 11:30
help formatting
CamperBot
@camperbot
Feb 23 2016 11:30

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

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

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

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

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

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

Mitsis Grigorios
@GMitsis
Feb 23 2016 11:30
Hello
Rita Alfonso
@alfonsotech
Feb 23 2016 11:31
@the07 ^
Gaurav Singh
@the07
Feb 23 2016 11:31
function palindrome(str) {
  // Good luck!
  str = str.toLowerCase();
  var array = [];
  var i = 0;
  while ( i < str.length) {
    array.push(str[i]);
    i += 1;
  }

  var newArray = array.filter(function(val){
    if (/^[a-z0-9]+$/i.test(val))
      return val;
  });

  str = newArray.join("");
  var revstr =  newArray.join(newArray.reverse());
  if (str === revstr) {
    return true;
  } else {
    return false;
  }

}
Sorry about that.
Mitsis Grigorios
@GMitsis
Feb 23 2016 11:32
Can anyone tell me why this is not working

function update (id, prop, value) {

collection[id][prop] = value;

function update (4, onoma, itlos);

Rita Alfonso
@alfonsotech
Feb 23 2016 11:32
This message was deleted
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 11:32
@the07 your code is nice just remove the while loop and try array=str.split("")
Gaurav Singh
@the07
Feb 23 2016 11:33
Thanks, let me try.
Thank you for the suggestion @abhishekKumar1
CamperBot
@camperbot
Feb 23 2016 11:34
the07 sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:star: 352 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 11:35
np @the07
Rita Alfonso
@alfonsotech
Feb 23 2016 11:37
@the07 You could simplify your use of new variables
Abhishek Kumar
@abhishekKumar1
Feb 23 2016 11:38
@the07 i wrote it in a more c like manner if you want u can check it
function palindrome(str) {
  // Good luck!
  var arr=[];
  str=str.toUpperCase();
  arr=str.split("");
  arr=arr.filter(function(val){ return ((val.charCodeAt(0)>=65 && val.charCodeAt(0)<=90)||(val.charCodeAt(0)>=48 && val.charCodeAt(0)<=57)); });
  for(i=0;i<(arr.length/2);i++)
    {
      if(arr[i]!=arr[arr.length-i-1])
        {
          return false;
        }
    }
  return true;
}
Rita Alfonso
@alfonsotech
Feb 23 2016 11:39
You declare new variables 4 times. Can you think of how you might make this more simple?
Gaurav Singh
@the07
Feb 23 2016 11:40
@abhishekKumar1 @alfonsotech
'''js
CamperBot
@camperbot
Feb 23 2016 11:40
:bulb: to format code use backticks! ``` more info
Rita Alfonso
@alfonsotech
Feb 23 2016 11:40
This solution uses the replace method
function palindrome(str) {

  //take original string and perform methods to lowercase and replace unwanted characters with nada
  str = str.toLowerCase().replace(/\s|\W|[0,2-9]|\_/g, "");

  //create a var newString to store our original string transformed by splittings, reversing and joining it back in reverse
  var newString = str.split("").reverse().join("");

  //checking to if original string is the same as our newString
 if (str === newString){
   //if yes, return true
    return true;
   //obvs, if no, return false
  } else return false;  
}
palindrome("1 eye for of 1 eye.");
Gaurav Singh
@the07
Feb 23 2016 11:41
'''
CamperBot
@camperbot
Feb 23 2016 11:41
:bulb: to format code use backticks! ``` more info
Gaurav Singh
@the07
Feb 23 2016 11:41
function palindrome(str) {
  // Good luck!
  str = str.toLowerCase();
  var array = [];
  array = str.split("");

  array = array.filter(function(val){
    if (/^[a-z0-9]+$/i.test(val))
      return val;
  });

  str = array.join("");
  var revstr =  array.join(array.reverse());
  if (str === revstr) {
    return true;
  } else {
    return false;
  }

}
Rita Alfonso
@alfonsotech
Feb 23 2016 11:42
SImpler version, no comments
function palindrome(str) {
  str = str.toLowerCase().replace(/\s|\W|[0,2-9]|\_/g, "");
  var newString = str.split("").reverse().join("");
 if (str === newString){
    return true;
  } else return false;  
}
palindrome("1 eye for of 1 eye.");
Gaurav Singh
@the07
Feb 23 2016 11:43
@alfonsotech Your code is so simple ! :) This happens with me so often, that I manage to find a solution, but its not you know, like yours.
@alfonsotech Thanks !
CamperBot
@camperbot
Feb 23 2016 11:43
the07 sends brownie points to @alfonsotech :sparkles: :thumbsup: :sparkles:
:star: 288 | @alfonsotech | http://www.freecodecamp.com/alfonsotech
Rita Alfonso
@alfonsotech
Feb 23 2016 11:44
@the07 It takes a few passes through to arrive at better solutions. I've done this one 3x.
You're most welcome
Solberg
@BuLbaR
Feb 23 2016 12:12
I am stuck in "nesting for loops" i need some serious pointers.
Hereshk
@Hereshk
Feb 23 2016 12:16
@BuLbaR What you have so far?
Alessandro Giordo
@bovas85
Feb 23 2016 12:16
@BuLbaR what are you finding difficult?
Markus Kiili
@Masd925
Feb 23 2016 12:16
@alfonsotech You can simplify the code by returning return str === newString
Alessandro Giordo
@bovas85
Feb 23 2016 12:17
@RakshithNM var presQuote = 'http://twitter.com/intent/tweet?text='+ randomQuote + by + randomAuth ; by should be " by "
Solberg
@BuLbaR
Feb 23 2016 12:17
@Hereshk
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

  for (var i=1; i<=3; i++) {
    for (var j=5; j<=3; j++) {
      console.log(product[i][j]);
    }
  }


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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
@bovas85 i dont understand. the whole thing.
Alessandro Giordo
@bovas85
Feb 23 2016 12:18
what was the task?
Solberg
@BuLbaR
Feb 23 2016 12:19
multiplyAll([[1],[2],[3]]); should return 6
multiplyAll([[1,2],[3,4],[5,6,7]]) should return 5040
multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]);) should return 54
Javascript is so hard.
Alessandro Giordo
@bovas85
Feb 23 2016 12:19
ah ok
so the best thing you can do is use console.log everywhere
to understand exactly what does for loops are doing
for example console.log(arr[i]); should return [1,2] at it's first iteration
Solberg
@BuLbaR
Feb 23 2016 12:21
I just wrote console.log to test something. what excactly does console.log do and how do i use it?
Alessandro Giordo
@bovas85
Feb 23 2016 12:21
if you do console.log(arr[i][j]); you'll get something else
Solberg
@BuLbaR
Feb 23 2016 12:21
@bovas85 thanks i will try
CamperBot
@camperbot
Feb 23 2016 12:21
bulbar sends brownie points to @bovas85 :sparkles: :thumbsup: :sparkles:
Alessandro Giordo
@bovas85
Feb 23 2016 12:21
to see console log you have to open the console in your browser
CamperBot
@camperbot
Feb 23 2016 12:21
:star: 288 | @bovas85 | http://www.freecodecamp.com/bovas85
Solberg
@BuLbaR
Feb 23 2016 12:21
f12 ?
Alessandro Giordo
@bovas85
Feb 23 2016 12:21
and you will see a log message there
depends on the browser
but usually it's F12
Solberg
@BuLbaR
Feb 23 2016 12:22
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

  for (var i=1; i<=3; i++) {
    for (var j=5; j<=3; j++) {
      console.log(product);
    }
  }


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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
This shows me nothing new.
im not frustrated but i feel i need a break :P
I have been helping ppl yesterday and today because im stuck at this task
so i dont loose my motivational streak
Fredrik E
@freddjah
Feb 23 2016 12:23
Anyone who can help me with a little bit of regex, I just know that it must be possible to write my code in one regex, but I just cannot find how. var name = $(this).text().replace(/\W/g, ' ').replace(/\s\s+/g, ' ').replace(/(^\s|\s$)/g, '');
Alessandro Giordo
@bovas85
Feb 23 2016 12:23
@BuLbaR look at what you are logging
if you check for product you will get it's value
which is 1 because you haven't changed it
Fredrik E
@freddjah
Feb 23 2016 12:24
@BuLbaR You haven't changed product since you first declared it.
Solberg
@BuLbaR
Feb 23 2016 12:27
@freddjah how do i change product in this setting
Gabriele Sani
@gabryatfendor
Feb 23 2016 12:27
I need help with map method for iterating array
Alessandro Giordo
@bovas85
Feb 23 2016 12:27
@BuLbaR product = something
= assigns a value on the right to product
Gabriele Sani
@gabryatfendor
Feb 23 2016 12:28
var oldArray = [1,2,3,4,5];
var newArray = oldArray;
newArray.map(function(val,index)
{newArray[index] = val+3;}
);
why the site says i have not to change oldArray? I'm not touching it...
Fredrik E
@freddjah
Feb 23 2016 12:28
@BuLbaR Well, you need to really understand what you want to do. My tip is visualizing the problem by writing it down och drawing some sort of mind-map. Because right now, your code is only two loops iterating over a couple of times and logging the same value.
Solberg
@BuLbaR
Feb 23 2016 12:30
@freddjah okey! thanks!
CamperBot
@camperbot
Feb 23 2016 12:30
bulbar sends brownie points to @freddjah :sparkles: :thumbsup: :sparkles:
:star: 306 | @freddjah | http://www.freecodecamp.com/freddjah
Solberg
@BuLbaR
Feb 23 2016 12:30
@freddjah är du svenska?
Fredrik E
@freddjah
Feb 23 2016 12:30
@BuLbaR Ja. :)
Solberg
@BuLbaR
Feb 23 2016 12:30
Norsk her :P
But i guess English is the main chatroom language =)
Codemzy
@codemzy
Feb 23 2016 12:31
@gabryatfendor is it at the bottom? You can do it something like this...
var oldArray = [1,2,3,4,5];
var addThree = oldArray.map(function(val) {
  return val+3;
});
var newArray = addThree;
Fredrik E
@freddjah
Feb 23 2016 12:31
@BuLbaR Nice. :) Yeah, we better keep the norweigian and swedish private :)
Gabriele Sani
@gabryatfendor
Feb 23 2016 12:33
@codemzy ok, so var addThree is a sort of temp array I create where I store every value +3?
Codemzy
@codemzy
Feb 23 2016 12:34

yeah... you could probably just do

var oldArray = [1,2,3,4,5];
var newArray = oldArray.map(function(val) {
  return val+3;
});

But I think the first way is the way the challenge asks for it

@gabryatfendor
Gabriele Sani
@gabryatfendor
Feb 23 2016 12:35
exactly what I thought, thanks a lot @codemzy
CamperBot
@camperbot
Feb 23 2016 12:35
gabryatfendor sends brownie points to @codemzy :sparkles: :thumbsup: :sparkles:
:star: 629 | @codemzy | http://www.freecodecamp.com/codemzy
Codemzy
@codemzy
Feb 23 2016 12:36
@gabryatfendor :thumbsup:
Yash Vardhan
@blankyash
Feb 23 2016 12:41
what's wrong here?
Really hard explanation in the page
function myTest(val) {
  var answer = "";
  // Only change code below this line

  switch(val){
    case 1:
      val = 'alpha';
      break;
    case 2:
      val = 'beta';
      break;
    case 3:
      val = 'gamma';
      break;
    case 4:
      val = 'delta';
      break;


  }

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

// Change this value to test
myTest(1);
Solberg
@BuLbaR
Feb 23 2016 12:42
why does this return 15,6,7
```js
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
product = product+arr[[2]];
  for (var i=1; i<=3; i++) {
    for (var j=5; j<=3; j++) {
      console.log(product[i][j]);
    }
  }


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

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

and multiplyAll([1,2,[3]]);

Return 13.

Yash Vardhan
@blankyash
Feb 23 2016 12:43
??
anyone who can help?
No need rectified the problem
thanks anyways people
Ken Haduch
@khaduch
Feb 23 2016 12:53
@BuLbaR , you need to be multiplying the terms and adding to the result as you go along. (I'm just looking on my phone, I might not be seeing everything?)
Hereshk
@Hereshk
Feb 23 2016 12:53
@BuLbaR You try to update "product" before the loop, "product" should be updated from the loop. I'm not sure where the "arr[[2]]" comes from, but in your actual code "arr" is not a defined variable. Also be sure to understand how the "for" loop works. The expressions in the loops don't look right. (for ([initialization]; [condition]; [final-expression])).
aaww nevermind the "arr" part, I see it in the function now
but the other studd I said is good haha
*stuff
Blauelf
@Blauelf
Feb 23 2016 12:54
@BuLbaR You are returning the string "15,6,7", which is the result of 1+[5,6,7]. Your loops are useless that way, you should use arr.length and arr[i].length for the upper bounds (remember to use < for not including them as index is from 0 to arr.length-1), and 0 for the lower bounds.
Gaurav Singh
@the07
Feb 23 2016 12:56
@BuLbaR also i think, product[i][j] is invalid since it is a string.
Blauelf
@Blauelf
Feb 23 2016 12:59
It's made a string by conversion from array (number plus array makes string). When removing that line, it stays a number. But product[i][j] is wrong for another reason, as not elements of product (which is a number) should be found but elements of arr.
Gaurav Singh
@the07
Feb 23 2016 13:02
@BuLbaR you are returning product which it seems you have evaluated before your nested for loop. So every time you call the function, this expression is evaluated - product = 1 + arr[[2]]. in case of [[1,2],[3,4],[5,6,7]], arr[2]] is [5,6,7] so product = 1 + [5,6,7] and likewise for the other array
@Blauelf thanks for pointing that out.
CamperBot
@camperbot
Feb 23 2016 13:02
the07 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1281 | @blauelf | http://www.freecodecamp.com/blauelf
Alessandro Giordo
@bovas85
Feb 23 2016 13:04
@BuLbaR
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
product = product+arr[[2]];        // this is wrong. You have to do this in the for loop  below
  for (var i=1; i<=3; i++) {                // this loops the whole array although you should start from i = 0 not i = 1 as you will skip the first element of the array ([1,2])
    for (var j=5; j<=3; j++) {              // this is wrong. Go back to the explanation on the exercises before. You should loop the for loop again to get the value for each subarray
      console.log(product[i][j]);   
    }
  }


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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
sigursiguros
@sigursiguros
Feb 23 2016 13:06
  var register = cid.reduce(function(faceOfBill, value) {
    faceOfBill.total += value[1];
    faceOfBill[value[0]] = value[1];
    return faceOfBill;
  }, {total: 0});
Hi guys, why is it that when I remove "return faceOfBill" from this function, it no longer works?
Vantrav
@vantrav
Feb 23 2016 13:08
help Palindromes
CamperBot
@camperbot
Feb 23 2016 13:08

:point_right: algorithm check for palindromes [wiki]

Explanation:

Our goal for solving this problem is tidying up the string passed in, and checking whether it is in fact a palindrome.

  • If you are unsure of what a palindrome is, it is a word or phrase that when reversed spells the same thing forwards or backwards. A simple example is mom, when you reverse the letters, it spells the same thing! Another example of a palindrome is race car. When we take out anything that is not a character it becomes racecar which is the same spelled forwards or backwards!

Once we have determined whether it is a palindrome or not we want to return either true or false based on our findings.

:pencil: read more about algorithm check for palindromes on the FCC Wiki

Gaurav Singh
@the07
Feb 23 2016 13:09
@vantrav post your code, where are you stuck ?
Vantrav
@vantrav
Feb 23 2016 13:10
@the07 how to start? :smile:
function palindrome(str) {
  // Good luck!
  return true;
}



palindrome("eye”);
Aleksander Gębicki
@Takumar
Feb 23 2016 13:11
@vantrav you have to do two things. Create reversed version of your str string and compare it with str.
But first you have to remove unnecessary characters from your string.
@vantrav for sure you reversed strings earlier, because there was such challenge earlier.
The whole difficulty is with removing unnecessary characters.
@vantrav read about regular expressions first to complete this challenge.
explain regexp
CamperBot
@camperbot
Feb 23 2016 13:12
no wiki entry for: regexp
egglearn
@egglearn
Feb 23 2016 13:13
hi everyone, how do i paste my code like above into here ?
Aleksander Gębicki
@Takumar
Feb 23 2016 13:14
@egglearn use backticks ``` for formatting
Vantrav
@vantrav
Feb 23 2016 13:14
@Takumar am going to give it a try! Thanks
Aleksander Gębicki
@Takumar
Feb 23 2016 13:14
wiki format
CamperBot
@camperbot
Feb 23 2016 13:14
vantrav sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

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

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

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

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

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

:star: 2374 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Feb 23 2016 13:14
@vantrav you are welcome. Check this page: http://regexone.com/
Blauelf
@Blauelf
Feb 23 2016 13:17
@sigursiguros reduce uses the return value of your callback as the first argument to the next call to the callback. If you don't return, you implicitly return undefined, so your callback will try to access undefined.total, which does not exist.
egglearn
@egglearn
Feb 23 2016 13:17
var count = 0;

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

    case 1: 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";

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

  return "Change Me";
  // 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');
messed it up, sry
Blauelf
@Blauelf
Feb 23 2016 13:17
@egglearn Needs closing triple backticks, too. You can edit your code (use the three dots that appear when you hover over your post) for about 10 minutes after posting.
Armin
@ArminTalovic
Feb 23 2016 13:18
sometimes code formatting just doesn't work...
Blauelf
@Blauelf
Feb 23 2016 13:18
And sometimes it would work if done right (or edited to do so)
Armin
@ArminTalovic
Feb 23 2016 13:18

function myTest(val) {
  var answer = "";
  // Only change code below this line
  case 1:
  answer = "alpha";
  break;


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

// Change this value to test
myTest(1);
what am I doing wrong?
Blauelf
@Blauelf
Feb 23 2016 13:19
There is no switch statement.
cannelflow
@cannelflow
Feb 23 2016 13:19
@ArminTalovic you need switch statement
Blauelf
@Blauelf
Feb 23 2016 13:19
What happened to the other answers (they should probably be other switch cases)?
Armin
@ArminTalovic
Feb 23 2016 13:19
yep obvious :D
other answers I add up later
sigursiguros
@sigursiguros
Feb 23 2016 13:20
@Blauelf so is it basically a loop calling on whatever element I return on?
egglearn
@egglearn
Feb 23 2016 13:21
@Blauelf thanks, my code seems to work on all but one test , i think when a number gets repeated in a sequence it fails.
CamperBot
@camperbot
Feb 23 2016 13:21
egglearn sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1282 | @blauelf | http://www.freecodecamp.com/blauelf
zivce_
@zivce
Feb 23 2016 13:21
hey there guys
I am at nesting for loops
Aleksander Gębicki
@Takumar
Feb 23 2016 13:21
@egglearn think about this line: case 7: case 8: case 9: count = 0; do you think you are doing good setting this variable to 0? Please read instruction again :-)
Blauelf
@Blauelf
Feb 23 2016 13:21
@sigursiguros The MDN docs on reduce try to explain it, does that explaination work for you?
zivce_
@zivce
Feb 23 2016 13:21
and it isn't working can somebody help me out?
´´´
Aleksander Gębicki
@Takumar
Feb 23 2016 13:22
Hi @Blauelf :-)
zivce_
@zivce
Feb 23 2016 13:22

´´´
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i< arr.length; i++){
for (var j=0; i< arr[i].length; j++){
product*=arr[i][j];

}

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

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

Aleksander Gębicki
@Takumar
Feb 23 2016 13:22
@zivce-gopro don't put anything in line with backticks:
```
your code
```
Oh, and backticks are below Esc key on most keyboards.
Blauelf
@Blauelf
Feb 23 2016 13:23
@zivce-gopro i< arr[i].length should be j < arr[i].length (otherwise infinite loop)
egglearn
@egglearn
Feb 23 2016 13:23
@Takumar thankyou , i changed the line from count = 0 which now you pointed out would reset the whole count to 0 to count = count and now i can pass the test
Aleksander Gębicki
@Takumar
Feb 23 2016 13:24
@egglearn you are welcome
zivce_
@zivce
Feb 23 2016 13:24
yep thanks @Blauelf
CamperBot
@camperbot
Feb 23 2016 13:24
zivce-gopro sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1283 | @blauelf | http://www.freecodecamp.com/blauelf
Armin
@ArminTalovic
Feb 23 2016 13:24
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch(answer){
    case 1:
  answer = "alpha";
  break;
    case 2:
      answer = "beta";
      break;
    case 3:
      answer = "gamma";
      break;
    case 4:
      answer = "delta";
      break;
  }
  // Only change code above this line  
  return answer;  
}

// Change this value to test
myTest(1);
nothing is happening, why?
Blauelf
@Blauelf
Feb 23 2016 13:25
@egglearn You don't even need those cases for 7,8,9 (if removing, these will be included in the default case, which is empty, so nothing lost there)
sigursiguros
@sigursiguros
Feb 23 2016 13:25
@Blauelf I don't quite get what it's saying, if it's got more examples it'd be good
I mean in my case they are applying reduce on an array, instead of a simple a+b function
Blauelf
@Blauelf
Feb 23 2016 13:26
@ArminTalovic Is answer the variable you want to test for deciding which case is right?
@sigursiguros They simply pass an object as the first argument, and pass it through the whole looping while processing elements of the array.
Armin
@ArminTalovic
Feb 23 2016 13:28
@Blauelf yes, I'm using this as help http://www.w3schools.com/js/js_switch.asp
Maxfirer
@Maxfirer
Feb 23 2016 13:28
ur answer val is null. u testing wrong val.
Armin
@ArminTalovic
Feb 23 2016 13:29
null?
Blauelf
@Blauelf
Feb 23 2016 13:29
@ArminTalovic Does it say switch(day){case 1: day="Monday";}?
sigursiguros
@sigursiguros
Feb 23 2016 13:30
help exact change
CamperBot
@camperbot
Feb 23 2016 13:30

:point_right: algorithm exact change [wiki]

Problem Explanation:

  • You have to create a program that will handle when the register does not have enough cash or will have no cash after the transaction. Other than that it needs to return an array of the change in the form of an array, so that will be a 2D array.
:pencil: read more about algorithm exact change on the FCC Wiki
Gaurav Singh
@the07
Feb 23 2016 13:30
@ArminTalovic switch(val) - not switch(answer)
Maxfirer
@Maxfirer
Feb 23 2016 13:30
u passing ur val to ur function (function myTest(val)) so u should write switch to test tat val, not test "answer"
sigursiguros
@sigursiguros
Feb 23 2016 13:30
@Blauelf I can't understand the second reduce function in this algo solution
Gaurav Singh
@the07
Feb 23 2016 13:30
@ArminTalovic switch(val)
Blauelf
@Blauelf
Feb 23 2016 13:30
@ArminTalovic switch evaluates the expression in parentheses and uses that to test against the cases. answer is always empty string at that moment, but there is also val ;)
Gaurav Singh
@the07
Feb 23 2016 13:31
not switch(answer)
Armin
@ArminTalovic
Feb 23 2016 13:31
thanks guys :D
John Roman
@jrroman
Feb 23 2016 13:32
help js resources
Blauelf
@Blauelf
Feb 23 2016 13:32
@sigursiguros Which second reduce function?
sigursiguros
@sigursiguros
Feb 23 2016 13:33
var change_arr = denom.reduce(function(acc, curr) {
        var value = 0;
        // While there is still money of this type in the drawer
        // And while the denomination is larger than the change reminaing
        while(register[curr.name] > 0 && change >= curr.val) {
            change -= curr.val;
            register[curr.name] -= curr.val;
            value += curr.val;

            // Round change to the nearest hundreth to deal with precision errors
            change = Math.round(change * 100) / 100;
        }
        // Add this denomination to the output only if any was used.
        if(value > 0) {
            acc.push([ curr.name, value ]);
        }
        return acc; // Return the current Change Array
    }, []); // Initial value of empty array for reduce
Blauelf
@Blauelf
Feb 23 2016 13:37
Clearly that runs on the denom array, adding as many coins/bills of that type to the array while reducing the change accordingly. The elements of denom have properties name and val that correspond to name and unit size of that type.
Won't stand my own challenge "Return 0.30 while having quarters and at least 3 dimes, but no nickels or cents" :P
sigursiguros
@sigursiguros
Feb 23 2016 13:38
@Blauelf so it's not a good solution?
it's from FCC WIKI
Blauelf
@Blauelf
Feb 23 2016 13:40
Most solutions here work exactly the same, written in different ways. They all are unable to solve that, while I think they should be able to (but then it's probably too complicated, I solved it using some simple recursion, but some people almost hate recursion)
Gaurav Singh
@the07
Feb 23 2016 13:48
Can someone again help me improve this code, I am getting the result but I am not sure(again) that this is the best way.
```js
function findLongestWord(str) {

  var longest = 0;

  var array = str.split(/\W/gi);
  var i = 0;
  while (i < array.length) {
    if (longest < array[i].length) {
      longest = array[i].length;
    }
    i +=1 ;
  }
  return longest;

}
Codemzy
@codemzy
Feb 23 2016 13:52
@the07 looks fine to me, you can also split the string without regex, based on a space like this... str.split(" "); , not saying that your way is better or worse, I just usually do it the other way if its something simple like a space
Gaurav Singh
@the07
Feb 23 2016 13:57
I managed to reduce some variables and used a built-in max() method.
```js
```js
JackeL
@jackel27
Feb 23 2016 13:57
@the07 you can also replace i+=1 with '''i++'''
CamperBot
@camperbot
Feb 23 2016 13:57
:bulb: to format code use backticks! ``` more info
Gaurav Singh
@the07
Feb 23 2016 13:57
function findLongestWord(str) {

  var longest = 0;

  str = str.split(/\W/gi);
  for (var i = 0; i < str.length; i++) {
    longest = Math.max(str[i].length,longest);
  }
  return longest;
}
JackeL
@jackel27
Feb 23 2016 14:00
Or just...

return Math.max (...str);
Bartosz
@CataciD
Feb 23 2016 14:02
holy damn anyone got any resoruces on objects ?
cause the helper one aint helpin
im stuck on the Make a Person thing
Gaurav Singh
@the07
Feb 23 2016 14:07
@jackel27 could you explain ?
JackeL
@jackel27
Feb 23 2016 14:08
@the07 well, after you split into array, try calling return Math.max (...arr); what do you get?
Oops. I meant to type (...str)
Actually nm. I forgot u currently have words not int
Stanley
@stanleyyylau
Feb 23 2016 14:10
function sumPrimes(num) {
  var allnum=[];
  var allprimenum=[];
  var ifNum=0;
  var allnumsum=0;
  for (a=1;a<=num;a++){
    allnum.push(a);
  }

   for(i=1;i<=num;i++){
     ifNum=0;
     for(x=1;x<=allnum[i];x++){
       if(allnum[i]%x ===0){
         ifNum=ifNum+1;
       }     
     }    
    if(ifNum===2){
         allprimenum.push(allnum[i]);
       }

  }


  for(b=0;b<allprimenum.lenth;b++){
    allnumsum=allnumsum+allprimenum[b];
  }
  return allnumsum;
}

sumPrimes(5);
i donno why this don't work, i look at the console. still foundnothing
can someone help?
i'm on chanlenge Sum All Primes
Gaurav Singh
@the07
Feb 23 2016 14:12
@jackel27 could you show me the function if it was int ?
JackeL
@jackel27
Feb 23 2016 14:13
@stanleyyylau declare your variable i as var i=0 not just i=0
Stanley
@stanleyyylau
Feb 23 2016 14:14
ok, thanks i'll try
Markus Kiili
@Masd925
Feb 23 2016 14:15
@the07 You can use Math.max if you first map words to lengths:
function findLongestWord(str) {
    return Math.max.apply(null,str.split(" ").map(function(word){return word.length;}));
}
JackeL
@jackel27
Feb 23 2016 14:15
@the07 wont work with this es version.
Stanley
@stanleyyylau
Feb 23 2016 14:15
@jackel27 still dont work
JackeL
@jackel27
Feb 23 2016 14:17
@stanleyyylau what about x?
Gaurav Singh
@the07
Feb 23 2016 14:17
@Masd925 Awesome ! thanks !
CamperBot
@camperbot
Feb 23 2016 14:17
the07 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1027 | @masd925 | http://www.freecodecamp.com/masd925
JackeL
@jackel27
Feb 23 2016 14:18
Want to make sure you are not limiting the scope of the var in cases you want to use it outside your scope
Or not that, but. Well.. i guess good habbit.
Shouldnt make a differencee in this case.
Stanley
@stanleyyylau
Feb 23 2016 14:19
@jackel27 yes, i add var x = 1 to it, don't still don't work
Bartosz
@CataciD
Feb 23 2016 14:20
is anyone able to help me with Make a Person ?
Stanley
@stanleyyylau
Feb 23 2016 14:21
```
```
function sumPrimes(num) {
  var allnum=[];
  var allprimenum=[];
  var ifNum=0;
  var allnumsum=0;
  for (var a=1;a<=num;a++){
    allnum.push(a);
  }

   for(var i=1;i<=num;i++){
     ifNum=0;
     for(var x=1;x<=allnum[i];x++){
       if(allnum[i]%x ===0){
         ifNum=ifNum+1;
       }     
     }    
    if(ifNum===2){
         allprimenum.push(allnum[i]);
       }

  }


  for(var b=0;b<allprimenum.lenth;b++){
    allnumsum=allnumsum+allprimenum[b];
  }
  return allnumsum;
}

sumPrimes(5);
now my code looks like this
@jackel27
sigursiguros
@sigursiguros
Feb 23 2016 14:22
@Blauelf I copied and pasted the solution from wiki help again and it works
but I don't understand why
help exact change
CamperBot
@camperbot
Feb 23 2016 14:22

:point_right: algorithm exact change [wiki]

Problem Explanation:

  • You have to create a program that will handle when the register does not have enough cash or will have no cash after the transaction. Other than that it needs to return an array of the change in the form of an array, so that will be a 2D array.
:pencil: read more about algorithm exact change on the FCC Wiki
Blauelf
@Blauelf
Feb 23 2016 14:22

@sigursiguros My version of that code from the wiki would look like

    var found = false;
    var change_arr = [];
    function recursive(stage) {
        if (change === 0) {
            found = true;
            return;
        }
        if (stage === denom.length)
            return;
        var curr = denom[stage];
        var value = 0;
        // While there is still money of this type in the drawer
        // And while the denomination is larger than the change reminaing
        while(register[curr.name] > 0 && change >= curr.val) {
            change -= curr.val;
            register[curr.name] -= curr.val;
            value += curr.val;

            // Round change to the nearest hundreth to deal with precision errors
            change = Math.round(change * 100) / 100;
            value = Math.round(value * 100) / 100;
        }
        recursive(stage+1);
        while(!found && value>0) { // if no solution possible with maximum amount, lower it and try again
            change += curr.val;
            register[curr.name] += curr.val;
            value -= curr.val;

            // Round change to the nearest hundreth to deal with precision errors
            change = Math.round(change * 100) / 100;
            value = Math.round(value * 100) / 100;
            recursive(stage+1);
        }
        // Add this denomination to the output only if any was used.
        if(value > 0) {
            change_arr.unshift([ curr.name, value ]);
        }
    }
    recursive(0);

(not tested, but you might get the idea, my actual code is very different)

JackeL
@jackel27
Feb 23 2016 14:23
@stanleyyylau you could say after ifnum===2 x+=allnum [i]
Where x is your variable name u choose with value of 0 to start...
@Blauelf you mispelt remaining in your 2nd comment line :)
Blauelf
@Blauelf
Feb 23 2016 14:27
@sigursiguros reduce is something one has to get used to, best is to step through it (if you understand the description, then manually, if not, for example using http://pythontutor.com/javascript.html on some simple example).
@jackel27 The only comment I added is the one // if no solution possible with maximum amount, lower it and try again
JackeL
@jackel27
Feb 23 2016 14:27
(Rare to correct @Blauelf ) I feel like a million bucks.
Dangit
Blauelf
@Blauelf
Feb 23 2016 14:28
Rest is copy&pasted from @sigursiguros , who copy&pasted from FCC wiki. I changed some code, though.
<