These are chat archives for FreeCodeCamp/HelpJavaScript

27th
Nov 2016
Aiden
@AidenMead
Nov 27 2016 00:01
Hey everyone!
So as a break from some of the challenges, I'm just trying to create a standard bootstrap carousel in Codepen just to try it. I'm hitting a wall with it, it's not wokring as it should. It won't actually toggle between images and I'm a little confused as to why. Anyone willing to take a look?
JaySnel
@JaylanSnelson
Nov 27 2016 00:03
Hey everyone, new this whole javascript thing and am stuck on a problem that should work but is giving me an error, anyone down to help me out?
Robbie
@robsli
Nov 27 2016 00:06
Hi guys - having trouble with the OpenWeather API for the weather app. Anyone got a few minutes to take a look at my code?
JaySnel
@JaylanSnelson
Nov 27 2016 00:06

@coy17a
// Example
function ourTrueOrFalse(isItTrue) {
if (isItTrue) {
return "Yes, it's true";
}
return "No, it's false";
}

// Setup
function trueOrFalse(wasThatTrue) {

// Only change code below this line.
if (15 < 20) {
return "Yes, that was true";
}

return "No, that was false";

// Only change code above this line.

}

// Change this value to test
trueOrFalse(true);

Jay Kumar
@jaykch
Nov 27 2016 00:07
@robsli where is it? codepen?
Robbie
@robsli
Nov 27 2016 00:07
@jaykch yep - i’ll DM it to you
coy17a
@coy17a
Nov 27 2016 00:07
@JaylanSnelson use the ``` at the beginning and the end so it is easy to read the code https://discourse-user-assets.s3.amazonaws.com/optimized/2X/4/470db50cc014204906db4a54e53a7442df544643_1_690x205.gif
Jay Kumar
@jaykch
Nov 27 2016 00:07
cool
JaySnel
@JaylanSnelson
Nov 27 2016 00:08
@coy17a it is giving me the error that trueOrFalse(false) should return a string.....tells me it is correct......then says trueOrFalse(false) should return "No, that was false"....but tells me it is incorrect
Vu Phung
@VDPhung
Nov 27 2016 00:10
never mind, figure it out needs to add '&hashtags=...'
Can anyone take a look and see why the carousel isn't working?
coy17a
@coy17a
Nov 27 2016 00:13
check your if @JaylanSnelson . You should use the argument that is giivng to your funciton
@JaylanSnelson in other words, use your wasThatTrue variable in your code.
Matt
@mattbag
Nov 27 2016 00:15
@AidenMead because you are loading bootstrap before jquery
!help
Blaz3gaming
@Blaz3gaming
Nov 27 2016 00:15
im currently on Escape Sequences in Strings. i have 3 of the 4 checkpoints. the only checkpoint i dont have is mystr should have encoded text with the proper escape sequences and no spacing. my code is var myStr="\FirstLine\nSecondLine\rThirdLine\";
Aiden
@AidenMead
Nov 27 2016 00:15
@mattbag you can change the order in which codepen loads libraries?
i added a couple of libraries from maxcdn and now they seem to work
JaySnel
@JaylanSnelson
Nov 27 2016 00:19
@coy17a okay cool thanks for the help!
CamperBot
@camperbot
Nov 27 2016 00:19
jaylansnelson sends brownie points to @coy17a :sparkles: :thumbsup: :sparkles:
:cookie: 256 | @coy17a |http://www.freecodecamp.com/coy17a
Nicolas Nielsen
@niconielsen
Nov 27 2016 00:28
'''
CamperBot
@camperbot
Nov 27 2016 00:28
:bulb: to format code use backticks! ``` more info
Nicolas Nielsen
@niconielsen
Nov 27 2016 00:28
hi;
If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.
function updateRecords(id, prop, value) {
  if (prop!=="tracks" && value!==""){

  }
with what criteria do i have to update value
Your function must always return the entire collection object.
Vladimir Logachev
@VladimirLogachev
Nov 27 2016 00:35
Check it out! My Simon rocks on my Gibson Les Paul guitar! Hahahah)) http://codepen.io/vl-doit/full/ENvvbO
Jenky W. Nolasco
@jenkynolasco11
Nov 27 2016 00:37
@vl-doit I like the concept xD
Walid Ashri
@walidashri
Nov 27 2016 00:46
@niconielsen you got it?
Robbie
@robsli
Nov 27 2016 00:46
thanks @jaykch
CamperBot
@camperbot
Nov 27 2016 00:46
:cookie: 320 | @jaykch |http://www.freecodecamp.com/jaykch
robsli sends brownie points to @jaykch :sparkles: :thumbsup: :sparkles:
Vladimir Logachev
@VladimirLogachev
Nov 27 2016 00:48
@jenkynolasco11 Thanks man!
CamperBot
@camperbot
Nov 27 2016 00:48
vl-doit sends brownie points to @jenkynolasco11 :sparkles: :thumbsup: :sparkles:
:cookie: 417 | @jenkynolasco11 |http://www.freecodecamp.com/jenkynolasco11
Nicolas Nielsen
@niconielsen
Nov 27 2016 00:50
@walidashri almost
function updateRecords(id, prop, value) {
  if (prop==="tracks" && value!==""){
    if(collection[id][prop]) {
    collection[id][prop].push(value);}
    else{
      collection[id][prop]=[value];
    }
  }else if(value===""){
    delete collection[id][prop];
  }

  return collection;
}
passing all test except for this
After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"
Walid Ashri
@walidashri
Nov 27 2016 00:54
what if prop isn't tracks and values isn't empty?
@niconielsen
itsthomas
@itsthomas
Nov 27 2016 00:59
Are
if(document.getElementByld('footer') == true)
andif(document.getElementByid('footer'))
The same
?
@itsthomas
Are
if(document.getElementByld('footer') == true)
and
if(document.getElementByid('footer'))
The same?
Manish Giri
@Manish-Giri
Nov 27 2016 01:06
@itsthomas yep
Somia ♡
@somiajagadish
Nov 27 2016 01:06

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = "apple";
break;

case b:
  answer = "bird";
  break;

case c:
  answer = "cat";
  break;

default:
  answer = "stuff"
  break;

}

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

// Change this value to test
switchOfStuff(1);

Manish Giri
@Manish-Giri
Nov 27 2016 01:07
@somiajagadish the alphabets inside each case should be in quotes, since they are strings
itsthomas
@itsthomas
Nov 27 2016 01:07
But this page is saying something else:
Manish Giri
@Manish-Giri
Nov 27 2016 01:07
case "a", etc
Walid Ashri
@walidashri
Nov 27 2016 01:07
@itsthomas you only have typos there
Somia ♡
@somiajagadish
Nov 27 2016 01:07
so like case"b"
itsthomas
@itsthomas
Nov 27 2016 01:07
Those new to JavaScript often think the following would do the same:
if(document.getElementByld('footer') == true) and if(document.getElementByid('footer'))
      but document.getElementByld('header') would return an object which is a truthy value but it is not equal to a Boolean value of true.
Manish Giri
@Manish-Giri
Nov 27 2016 01:08
right
Somia ♡
@somiajagadish
Nov 27 2016 01:08

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case "a":
answer = "apple";
break;

case "b":
  answer = "bird";
  break;

case "c":
  answer = "cat";
  break;

default:
  answer = "stuff"
  break;

}

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

// Change this value to test
switchOfStuff(1);

Like this?
Manish Giri
@Manish-Giri
Nov 27 2016 01:08
I was just saying you can eliminate the == true in such ifs
what you're fetching inside that if, I never saw that
@itsthomas
itsthomas
@itsthomas
Nov 27 2016 01:09
ok
Manish Giri
@Manish-Giri
Nov 27 2016 01:09
@somiajagadish seems right
Somia ♡
@somiajagadish
Nov 27 2016 01:10
It said its wrong :/
Manish Giri
@Manish-Giri
Nov 27 2016 01:10
@somiajagadish post your challenge url here
Manish Giri
@Manish-Giri
Nov 27 2016 01:12
@somiajagadish answer = "stuff";
the editor says where you're wrong - missing semicolon
Walid Ashri
@walidashri
Nov 27 2016 01:14
@itsthomas
console.log(document.getElementById('footer'));
// returns the element it self not true or false
if(document.getElementById('footer') == true){
  console.log("hi")// won't excute
}
if(document.getElementById('footer')){
  console.log("higt"); // this work
}
Bled A
@TUcode
Nov 27 2016 01:14

// Example
function ourRandomRange(ourMin, ourMax) {

  return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourRandomRange(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {

  return Math.floor(Math.random * (myMax - myMin + 1)) + myMin; // Change this line

}

// Change these values to test your function
var myRandom = randomRange(5, 15);
result: myrandom = NaN
what is the problem in my code
could someone help me
Manish Giri
@Manish-Giri
Nov 27 2016 01:15
@TUcode Math.random is a function, needs the ()
Bled A
@TUcode
Nov 27 2016 01:16
@Manish-Giri OOhh Thanks i have tried that one too but now just worked
CamperBot
@camperbot
Nov 27 2016 01:16
tucode sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 2512 | @manish-giri |http://www.freecodecamp.com/manish-giri
Bled A
@TUcode
Nov 27 2016 01:16
Thank you
Manish Giri
@Manish-Giri
Nov 27 2016 01:16
@TUcode :+1:
Somia ♡
@somiajagadish
Nov 27 2016 01:17
@Manish-Giri THANKS!!!
CamperBot
@camperbot
Nov 27 2016 01:17
somiajagadish sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 2513 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Nov 27 2016 01:18
@somiajagadish :+1:
Prashis Raghuwanshi
@prashish14
Nov 27 2016 01:21

Error :
function golfScore(par, strokes) {
// Only change code below this line
if (strokes ==1) {

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

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

Tomasz
@robssson
Nov 27 2016 01:25
hello guys
```

function destroyer(arr) {
  // Remove all the values

  var args = arr.slice.call(arguments);
  for (var i=0; i<=arr.length; i++)
    {
      for (var y=1; y<args.length; y++){
        if (arr[i] === args[y])
          {
           arr.splice(arr[i], 1);
          }
      }

    }
  return arr;

}


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
can anyone give ma a tip?
nredona
@nredona
Nov 27 2016 01:36
how do you do word blanks

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

// Your code above this line
return result;
}

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

Walid Ashri
@walidashri
Nov 27 2016 01:37
@robssson notice that args = [arr,2,3]
Tomasz
@robssson
Nov 27 2016 01:37
@walidashri yes this is reason why i started from y=1
but i see that i hav problem with number 3
Gilbert
@GilTorch
Nov 27 2016 01:37
I'm stuck at the same place @nredona I tried creating my own variable then concatenate it inside the function with result with the other preexisted variables but i didn't work.
Tomasz
@robssson
Nov 27 2016 01:38
its arr[2] and arr[5] @walidashri
Gilbert
@GilTorch
Nov 27 2016 01:38
*with the variable result @nredona
Tomasz
@robssson
Nov 27 2016 01:38
@walidashri i Have problem with index 2 and 5, idk why
Walid Ashri
@walidashri
Nov 27 2016 01:39
@robssson cause arr.length is reducing while i is increasing
Tomasz
@robssson
Nov 27 2016 01:40
oh i am stupid :/
nredona
@nredona
Nov 27 2016 01:43
@GilTorch yeah i don't understand when they say
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
cthuluspoke
@cthuluspoke
Nov 27 2016 01:43
fahrenhei=celcius*(9/5)+32
Gilbert
@GilTorch
Nov 27 2016 01:44
Hannah
@kikibell1004
Nov 27 2016 01:44
@cthuluspoke i typed it but it's not working
cthuluspoke
@cthuluspoke
Nov 27 2016 01:44
@kikibell1004 show your code
__mifflin__
@cdrainxv
Nov 27 2016 01:45
@kikibell1004 @cthuluspoke: celsius
cthuluspoke
@cthuluspoke
Nov 27 2016 01:45
rigth, make sure everything is spelled right.
Hannah
@kikibell1004
Nov 27 2016 01:45
@cthuluspoke i figured it out
@cthuluspoke thanks
CamperBot
@camperbot
Nov 27 2016 01:46
kikibell1004 sends brownie points to @cthuluspoke :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @cthuluspoke |http://www.freecodecamp.com/cthuluspoke
nredona
@nredona
Nov 27 2016 01:46
@GilTorch you have to put a space between result and +=
cthuluspoke
@cthuluspoke
Nov 27 2016 01:46
cool
Nikola
@NIDZAAAAA
Nov 27 2016 01:46
@nredonaif you find solution try to understand that code u copy/paste
if you don`t undesrtand ask here
:-)
nredona
@nredona
Nov 27 2016 01:49
@NIDZAAAAA lol i didnt get what they meant about making it like a mad lib now i get it after i saw it
Nikola
@NIDZAAAAA
Nov 27 2016 01:50
:+1:
just saying, no hard feelings
Gilbert
@GilTorch
Nov 27 2016 01:51
@nredona did what you say and it still not working
Nikola
@NIDZAAAAA
Nov 27 2016 01:51
@GilTorch show your code
Dusliat
@Alchemistioc
Nov 27 2016 01:51

What do I have wrong here? '
function sequentialSizes(val) {
var answer = "";
// Only change code below this line
switch(val){
case 1:
case 2:
case 3:
result="Low";
break;
case 4:
case 5:
case 6:
result="Mid";
break;
case 7:
case 8:
case 9:
result="High";
}

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

// Change this value to test
sequentialSizes(6);'

Nikola
@NIDZAAAAA
Nov 27 2016 01:51
break;
you forgot
after High
Gilbert
@GilTorch
Nov 27 2016 01:52
@NIDZAAAAA <code></code>
@NIDZAAAAA

@NIDZAAAAA function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
// Your code above this line
result +="My "+myAdjective+myNoun+"was "+myVerb+"very very "+myAdverb;
return result;
}

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

sorry
Phillip Kelley-Dotson
@pkdotson
Nov 27 2016 01:52
@Alchemistioc I believe your result is off
Gilbert
@GilTorch
Nov 27 2016 01:53
<code>alert("TEst");</code>
__mifflin__
@cdrainxv
Nov 27 2016 01:53
@Alchemistioc: Why are you using global variable result and then returning answer?
Instead: answer = "Low";… etc
Dusliat
@Alchemistioc
Nov 27 2016 01:55
Thanks @NIDZAAAAA
CamperBot
@camperbot
Nov 27 2016 01:55
alchemistioc sends brownie points to @nidzaaaaa :sparkles: :thumbsup: :sparkles:
:cookie: 5 | @nidzaaaaa |http://www.freecodecamp.com/nidzaaaaa
Nikola
@NIDZAAAAA
Nov 27 2016 01:56
@Alchemistioc :+1:
David Halls
@DavidHalls
Nov 27 2016 01:56
some feed back please.
Somia ♡
@somiajagadish
Nov 27 2016 01:56

function chainToSwitch(val) {
var answer = "";
// Only change code below this line

switch(val) {
case 1:
answer = "Marley";
break;

case 2:
  answer = "The Answer";
  break;

case 3:
  answer = "There is no #1";
  break;

case 4:
  answer = "Missed me ny this much!";
  break;

case 5:
  answer = "Ate Nine";
  break;

}

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

Whats wrong?
Dusliat
@Alchemistioc
Nov 27 2016 01:56
I added the break but it still didn't go over.
Prashis Raghuwanshi
@prashish14
Nov 27 2016 01:56

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

default d:
answer = "stuff";
break;

Somia ♡
@somiajagadish
Nov 27 2016 01:57

function chainToSwitch(val) {
var answer = "";
// Only change code below this line

switch(val) {
case 1:
answer = "Marley";
break;

case 2:
  answer = "The Answer";
  break;

case 3:
  answer = "There is no #1";
  break;

case 4:
  answer = "Missed me ny this much!";
  break;

case 5:
  answer = "Ate Nine";
  break;

}

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

Help?
David Halls
@DavidHalls
Nov 27 2016 01:57
is answer declared?
Somia ♡
@somiajagadish
Nov 27 2016 01:58
@Byzgig What?
Gilbert
@GilTorch
Nov 27 2016 01:58
@Byzgig tic tac toe awesome!
@NIDZAAAAA you forgot me man
Nikola
@NIDZAAAAA
Nov 27 2016 01:59
i`m trying to figure it out what is prob
David Halls
@DavidHalls
Nov 27 2016 01:59
@somiajagadish answer is white in your pasted code, makes me think you never defined it like ---- var answer = ""; or something
Nikola
@NIDZAAAAA
Nov 27 2016 01:59
@GilTorch try just this: result+= "My "+myAdjective+" "+myNoun+" "+myVerb+" very "+myAdverb+".";
Somia ♡
@somiajagadish
Nov 27 2016 01:59

@Byzgig function chainToSwitch(val) {
var answer = "";
// Only change code below this line

switch(val) {
case 1:
answer = "Marley";
break;

case 2:
  answer = "The Answer";
  break;

case 3:
  answer = "There is no #1";
  break;

case 4:
  answer = "Missed me ny this much!";
  break;

case 5:
  answer = "Ate Nine";
  break;

}

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

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

David Halls
@DavidHalls
Nov 27 2016 01:59
nvm, i see that you did
Somia ♡
@somiajagadish
Nov 27 2016 01:59
i did call it
David Halls
@DavidHalls
Nov 27 2016 02:00
you need to 'return' instead of 'break'
@somiajagadish
Somia ♡
@somiajagadish
Nov 27 2016 02:00
This is a switch statment
David Halls
@DavidHalls
Nov 27 2016 02:00
correct
Carlos
@clockwerkz
Nov 27 2016 02:00
@Byzgig I played as X and when I let the computer win, it would double or even quadruple it's score
Walid Ashri
@walidashri
Nov 27 2016 02:00
@GilTorch you need some spaces inbetween
Somia ♡
@somiajagadish
Nov 27 2016 02:00
@Byzgig so it needs the break;
Gilbert
@GilTorch
Nov 27 2016 02:01
@NIDZAAAAA Wohooo !!! it worked!!!
David Halls
@DavidHalls
Nov 27 2016 02:01
@clockwerkz thanks man, ive been seeing that too, trying to figure out why that is happening
CamperBot
@camperbot
Nov 27 2016 02:01
byzgig sends brownie points to @clockwerkz :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for clockwerkz
Nikola
@NIDZAAAAA
Nov 27 2016 02:01
@GilTorch :+1:
Gilbert
@GilTorch
Nov 27 2016 02:01
thanks @NIDZAAAAA
CamperBot
@camperbot
Nov 27 2016 02:01
:cookie: 6 | @nidzaaaaa |http://www.freecodecamp.com/nidzaaaaa
giltorch sends brownie points to @nidzaaaaa :sparkles: :thumbsup: :sparkles:
David Halls
@DavidHalls
Nov 27 2016 02:01
@somiajagadish no, you need a return
Somia ♡
@somiajagadish
Nov 27 2016 02:01
okay
Carlos
@clockwerkz
Nov 27 2016 02:01
@Byzgig Also, sometimes the game will put two spots for O as well. I'm trying to repro it and see when exactly it does that.
David Halls
@DavidHalls
Nov 27 2016 02:01
@somiajagadish for the result you are looking for in this scenario
Somia ♡
@somiajagadish
Nov 27 2016 02:02
@Byzgig it still says its wrong
David Halls
@DavidHalls
Nov 27 2016 02:02
@clockwerkz i know there is a bug when i run the ai, working on it :(
@somiajagadish post your new code
Somia ♡
@somiajagadish
Nov 27 2016 02:02

function chainToSwitch(val) {
var answer = "";
// Only change code below this line

switch(val) {
case 1:
answer = "Marley";
break;

case 2:
  answer = "The Answer";
  break;

case 3:
  answer = "There is no #1";
  break;

case 4:
  answer = "Missed me ny this much!";
  break;

case 5:
  answer = "Ate Nine";
  break;

}

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

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

function chainToSwitch(val) {
var answer = "";
// Only change code below this line

switch(val) {
case 1:
answer = "Marley";
return;

case 2:
  answer = "The Answer";
  return;

case 3:
  answer = "There is no #1";
  return;

case 4:
  answer = "Missed me ny this much!";
  return;

case 5:
  answer = "Ate Nine";
  return;

}

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

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

oops sorry
Gilbert
@GilTorch
Nov 27 2016 02:02

@nredona function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
// Your code above this line
result+= "My "+myAdjective+" "+myNoun+" "+myVerb+" very "+myAdverb+".";
return result;
}

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

@nredona this work
David Halls
@DavidHalls
Nov 27 2016 02:03
@somiajagadish you need to return something, probably answer
Somia ♡
@somiajagadish
Nov 27 2016 02:03
answer is already returned
David Halls
@DavidHalls
Nov 27 2016 02:03
@somiajagadish no, that is not how a switch works
Carlos
@clockwerkz
Nov 27 2016 02:03
@Byzgig Welp, other than that it's pretty cool!
David Halls
@DavidHalls
Nov 27 2016 02:04
@somiajagadish in each case, you need to return answer;
Somia ♡
@somiajagadish
Nov 27 2016 02:04
@Byzgig Thanks but i think i will figure this out tommrow
CamperBot
@camperbot
Nov 27 2016 02:04
somiajagadish sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 377 | @byzgig |http://www.freecodecamp.com/byzgig
Somia ♡
@somiajagadish
Nov 27 2016 02:04
Good night :)
Ryan Santos
@ryasan86
Nov 27 2016 02:04
console.log('hi');
David Halls
@DavidHalls
Nov 27 2016 02:05
@somiajagadish just change your return; to return answer;
Ryan Santos
@ryasan86
Nov 27 2016 02:05
console.log(im new here to gitteri');
Walid Ashri
@walidashri
Nov 27 2016 02:06
@emag50 missing a ' :)
console.log(im new here to gitteri');
Ryan Santos
@ryasan86
Nov 27 2016 02:06
and to coding apparently with that horible echo
lmaio i know...carpal tunnel :/
__mifflin__
@cdrainxv
Nov 27 2016 02:06

@somiajagadish: The cases aren’t numbers in chronological order… click Run tests and you will see the actual cases to use:

chainToSwitch("bob") should be "Marley"
chainToSwitch(42) should be "The Answer"
chainToSwitch(1) should be "There is no #1"
chainToSwitch(99) should be "Missed me by this much!"
chainToSwitch(7) should be "Ate Nine"
chainToSwitch("John") should be "" (empty string)
chainToSwitch(156) should be "" (empty string)

Ryan Santos
@ryasan86
Nov 27 2016 02:06
but just poppin in to say hi...never chatted here but had an account for like 5 months
Walid Ashri
@walidashri
Nov 27 2016 02:07
@emag50 yes I know :smile: welcome
Ryan Santos
@ryasan86
Nov 27 2016 02:08
hehe thanks...well im off...again, nice to meet u all..hope we have some good nerconvos in the future :) gotta project and this shakey arm isi holdin me back!
:D lol cya
__mifflin__
@cdrainxv
Nov 27 2016 02:11
@walidashri: Missing a lot actually:
console.log('I\'m new here in gitter.');
Victor McLean
@vmvictorvm
Nov 27 2016 02:13

Hi, I have some questions for the code below:

Question 1:
"var todos" is a local variable that only live within deleteTodo method below. By doing todos.splice, it will delete/change the local variable "var todos" but NOT the this.todos variable? Am I correct?

Question 2:
What is "data.n"? I know the data is what it return, but what is the data.n? n is a property?

Please advise

    deleteTodo(todo){
    var todos = this.todos;

    this._todoService.deleteTodo(todo._id)
      .subscribe(data => {
        if(data.n == 1){
          for(var i = 0; i < todos.length; i++){
            if(todos[i]._id == todo._id){
              todos.splice(i, 1);
            }
          }
        }
      })
  }
tom43511
@tom43511
Nov 27 2016 02:16
Please judge my code and tell me how flawed it is

function palindrome(str) {
  // Good luck!
  var strArr = str.toLowerCase().replace(/[~!@#$%^&*()_+,.? -\/\-+]/g, "").split("").toString();
  var reverseString = str.replace(/[~!@#$%^&*()_+,.? -\/\-+]/g, "").toLowerCase().split("").reverse().toString();

  if (strArr !== reverseString){          
    return false;
  }else {

  return true;
  }  
}



palindrome("nope");
David Halls
@DavidHalls
Nov 27 2016 02:16
this.todos is not a variable in what you are showing, i do not see datat.n
@vmvictorvm
David Cruz
@dcruz87
Nov 27 2016 02:21
At what point does javascript get LESS confusing?! lol
tom43511
@tom43511
Nov 27 2016 02:21
From what I can tell, never lol
Victor McLean
@vmvictorvm
Nov 27 2016 02:21
let me try again:
class name {
   todos = Todos[];

   deleteTodo(todo){
    var todos = this.todos;

    this._todoService.deleteTodo(todo._id)
      .subscribe(data => {
        if(data.n == 1){
          for(var i = 0; i < todos.length; i++){
            if(todos[i]._id == todo._id){
              todos.splice(i, 1);
            }
          }
        }
      })
  }
}
David Halls
@DavidHalls
Nov 27 2016 02:22
@vmvictorvm post more of your code
Victor McLean
@vmvictorvm
Nov 27 2016 02:24
ok here we go:
import { Component, OnInit } from '@angular/core';
import { TodoService } from '../services/todo.service';
import { Todo } from '../Todo';


@Component({
  moduleId: module.id,
  selector: 'my-todos',
  templateUrl: 'todos.component.html'
})
export class TodosComponent implements OnInit  { 

    todos:Todo[];

    constructor(private _todoService:TodoService) {

    }

    ngOnInit() {
        this._todoService.getTodos().subscribe(todos => {
        //   console.log(todos);
            this.todos = todos;
        });

    }




    deleteTodo(todo){
    var todos = this.todos;

    this._todoService.deleteTodo(todo._id)
      .subscribe(data => {
        if(data.n == 1){
          for(var i = 0; i < todos.length; i++){
            if(todos[i]._id == todo._id){
              todos.splice(i, 1);
            }
          }
        }
      })
  }

}
Moisés Man
@moigithub
Nov 27 2016 02:25
angular2 ?
Victor McLean
@vmvictorvm
Nov 27 2016 02:25
yeah, but I think my question is related to basic javascript
Moisés Man
@moigithub
Nov 27 2016 02:26
todos:Todo[]; that looks weird.. why [] ?
Victor McLean
@vmvictorvm
Nov 27 2016 02:26
It's an array of todo objects
I'm thinking why they put a for loop in the delete method that delete a local variable todos
it seems it makes more sense if they do this.todos.splice(i,1) rather than todos.splice(i,1)
Moisés Man
@moigithub
Nov 27 2016 02:30
about the array question... if i recall...
if u have this
a = [5,1,3,7];
b = a;
b.sort();
a content will be sorted too.. cuz b = a; will copy the same reference
CamperBot
@camperbot
Nov 27 2016 02:30
you need to ask about @someone!
Zaurbek Zhakupov
@zzhakupov
Nov 27 2016 02:31
Hello guys, can someone pls explain how to proper;y use ":" in retunr statements?
return"
Victor McLean
@vmvictorvm
Nov 27 2016 02:31
I see, wow thats new to me
thx
Stephen James
@sjames1958gm
Nov 27 2016 02:33
@vmvictorvm Since todos is an array todos and this.todos refer to the same array - probably just to not have to type this everywhere
Moisés Man
@moigithub
Nov 27 2016 02:33
if u wanna make a copy.. better use
b = a.slice();
b = Array.from(a);
b = [...a];
any of those will create a copy / not linked
tom43511
@tom43511
Nov 27 2016 02:33
@Zooll8 I'm not sure what you're asking
Zaurbek Zhakupov
@zzhakupov
Nov 27 2016 02:34
Like this: return value ? 1 : 0;
and how to use ? sign in javascript
Moisés Man
@moigithub
Nov 27 2016 02:34
ternary operator
Victor McLean
@vmvictorvm
Nov 27 2016 02:36

So, the normal assignment "=" with an array will be referenced?
b = a;
b will point to the same data as 'a'

So this rule only apply for arrays? Not for number, string or any other types?

Moisés Man
@moigithub
Nov 27 2016 02:36
(condition expression) ? (true block) : (false block)
@Zooll8
Zaurbek Zhakupov
@zzhakupov
Nov 27 2016 02:37
@moigithub WOW!, thanks man!! I haven't even know that this is possible to make if-else --> return statement just in 1 line of code in js
CamperBot
@camperbot
Nov 27 2016 02:37
zooll8 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2256 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Nov 27 2016 02:37
array n objects @vmvictorvm
:) @Zooll8
Victor McLean
@vmvictorvm
Nov 27 2016 02:40
nice thanks
Any good javascript video tutorial? I want to dive deeper into javascript
Zaurbek Zhakupov
@zzhakupov
Nov 27 2016 02:40
@vmvictorvm You can do codecademy js free course
It not that hard, but it will teach you basics even working with objects and classes
I did full codecademy free course before fcc
But don't buy anything there
It isn't worth it
Stephen James
@sjames1958gm
Nov 27 2016 02:43
@tom43511 you can use /[^a-z0-9]/g to select all non-alphanumeric. and if you do a different order.
var cleanStr = str.toLowerCase().replace( /[^a-z0-9]/g, "");
Now you have a cleanStr that you can reverse (rather than do the toLowerCase and replace twice.
var reverseStr = cleanStr.split("").reverse().join("");
Now these two strings can be compared.
return cleanStr === reverseStr;
So only three lines
Kirby James
@kirbygit
Nov 27 2016 02:43
can somebody explain to me how to use i++
in javascript when a variable is being declared
Stephen James
@sjames1958gm
Nov 27 2016 02:44
@kboygit You cannot do it when it is being declared.
because it is the same as i = i + 1 i has to have a value first.
Kirby James
@kirbygit
Nov 27 2016 02:44
so do I need to delete my variable?
Stephen James
@sjames1958gm
Nov 27 2016 02:45
@kboygit
You could have.
var i = 10;
i++
then i is 11
Victor McLean
@vmvictorvm
Nov 27 2016 02:45
@Zooll8 Thanks
CamperBot
@camperbot
Nov 27 2016 02:45
vmvictorvm sends brownie points to @zooll8 :sparkles: :thumbsup: :sparkles:
:cookie: 307 | @zooll8 |http://www.freecodecamp.com/zooll8
Aiden
@AidenMead
Nov 27 2016 02:46
Hey everyone!
Kirby James
@kirbygit
Nov 27 2016 02:46
@sjames1958gm gotchu
Aiden
@AidenMead
Nov 27 2016 02:48
I've got a best practice question. I'm on the Wikipedia challenge, and I stumbled across someone who used html to redirect to a searched wikipedia page, and the code is just so much cleaner than using the API, is there a benefit to using the API when just simply redirecting, as opposed to needing the API to search in a specific spot.
<form action=”http://www.wikipedia.org/search-redirect.phpmethod=”get”>
Search Wikipedia:
<input type=”hidden” name=”language” value=”en” />
<input type=”text” name=”search” size=”20″ />
<input type=”submit” name=”go” value= Go! ” />
</form>
Compared to several functions back and forth and an ajax and stuff I'm still working through.
Aiden
@AidenMead
Nov 27 2016 02:54
In fact, for that matter, why would I use an API to get any return, when all I want to do is redirect someone to a page with the content that they want? Am I missing something about the API?
flaviojc
@flaviojc
Nov 27 2016 02:56

Im kind of lost in this task, did try somethings but didn't work.

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

return item; // Change this line
}

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

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

and I have to do this

nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10

David Halls
@DavidHalls
Nov 27 2016 02:58
feedback?
Stephen James
@sjames1958gm
Nov 27 2016 02:58
@flaviojc The key is the function will receive an array and a value inside the function the array is in the arr variable and the value is in the item variable.
Now in the function add itemto the end of arrthen remove the first value from arr and return it.
There are two array functions that can accomplish this
Tyler Moeller
@TylerMoeller
Nov 27 2016 03:00
@Byzgig The computer cheats :) after two rounds, the computer starts going first. If I tie, it marks 2 wins for the computer
3rd tie game shows 2 ties and 2 wins for the computer
Stephen James
@sjames1958gm
Nov 27 2016 03:00
@Byzgig I played as X and at the end when I played my third move O played twice and won (then counted two wins for O).
David Halls
@DavidHalls
Nov 27 2016 03:00
@TylerMoeller by design, it switches over to starting first every other game
Tyler Moeller
@TylerMoeller
Nov 27 2016 03:01
I'd design it that way too if I were the computer lol :)
David Halls
@DavidHalls
Nov 27 2016 03:01
@sjames1958gm hmm
Stephen James
@sjames1958gm
Nov 27 2016 03:01
@Byzgig I started as X and played center, top center, top right, then center left
Aiden
@AidenMead
Nov 27 2016 03:01
@Byzgig I had the same issue where we got to the last move and the computer put took two spots during one turn, thus winning. It happened both as O and as X for me.
David Halls
@DavidHalls
Nov 27 2016 03:01
@AidenMead thanks, wtf why?
CamperBot
@camperbot
Nov 27 2016 03:01
byzgig sends brownie points to @aidenmead :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @aidenmead |http://www.freecodecamp.com/aidenmead
David Halls
@DavidHalls
Nov 27 2016 03:01
@TylerMoeller thanks
CamperBot
@camperbot
Nov 27 2016 03:01
byzgig sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1001 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
LandonBreeden
@LandonBreeden
Nov 27 2016 03:01
i had question about lesson i completed(code works)

var count = 0;

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

switch (count) {
case 0:
return count + " Hold";
}

switch (count) {
case 1:
return count + " Bet";
}

switch (count) {
case 2:
return count + " Bet";
}

switch (count) {
case 3:
return count + " Bet";
}

switch (count) {
case 4:
return count + " Bet";
}

switch (count) {
case 5:
return count + " Bet";
}
switch (count) {
case -1:
return count + " Hold";
}

switch (count) {
case -2:
return count + " Hold";
}

switch (count) {
case -3:
return count + " Hold";
}

switch (count) {
case -4:
return count + " Hold";
}

switch (count) {
case -5:
return count + " Hold";
}
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(7); cc(8); cc(9); cc(); cc();

David Halls
@DavidHalls
Nov 27 2016 03:02
@sjames1958gm thanks
CamperBot
@camperbot
Nov 27 2016 03:02
byzgig sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4550 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 27 2016 03:02
@Byzgig Looks nice though - just need to work out some kinks :)
LandonBreeden
@LandonBreeden
Nov 27 2016 03:02
coukd this be written in IF ELSE format?
would it be better/shorter
Moisés Man
@moigithub
Nov 27 2016 03:03
u can put all ur cases in only 1 switch @LandonBreeden
Stephen James
@sjames1958gm
Nov 27 2016 03:03
This message was deleted
Stephen Kilgore
@devninja89
Nov 27 2016 03:03
what concepts do I need to have a grasp of to jump into react?
David Halls
@DavidHalls
Nov 27 2016 03:03
@LandonBreeden switch is more efficient
Stephen James
@sjames1958gm
Nov 27 2016 03:03
@LandonBreeden The second part should only be an if and else
LandonBreeden
@LandonBreeden
Nov 27 2016 03:04
how to write on switch for">0"
?
one switch**
or can you
David Halls
@DavidHalls
Nov 27 2016 03:05
@LandonBreeden dont understand the question
LandonBreeden
@LandonBreeden
Nov 27 2016 03:05
guess thats where if else comes in
Moisés Man
@moigithub
Nov 27 2016 03:05
">0" part u can use an if/else like @sjames1958gm said
(or another separated switch)
David Halls
@DavidHalls
Nov 27 2016 03:06
@LandonBreeden i mean >0 is pretty much every result
Moisés Man
@moigithub
Nov 27 2016 03:06
if/else would be easier to read
Stephen James
@sjames1958gm
Nov 27 2016 03:06
@LandonBreeden The instructions said if count > 0 then return Bet else return hold
David Halls
@DavidHalls
Nov 27 2016 03:06
switch is better for the task he is on
LandonBreeden
@LandonBreeden
Nov 27 2016 03:07
a ha ok ty @moigithub , @Byzgig @sjames1958gm
CamperBot
@camperbot
Nov 27 2016 03:07
landonbreeden sends brownie points to @moigithub and @byzgig and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 378 | @byzgig |http://www.freecodecamp.com/byzgig
:star2: 2257 | @moigithub |http://www.freecodecamp.com/moigithub
:star2: 4551 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Mark Kahler
@6merk
Nov 27 2016 03:11
Can someone break this down for me: var ourArray = [1,2,3];
ourArray1 = 3; // ourArray now equals [1,3,3].
var ourArray = [1,2,3];
ourArray1 = 3; // ourArray now equals [1,3,3].
David Halls
@DavidHalls
Nov 27 2016 03:12
feedback?
Mark Kahler
@6merk
Nov 27 2016 03:12
why does it equal 1,3,3
sktipwr
@sktipwr
Nov 27 2016 03:13
i taught here all are the legend in code. i want to learn JS on-line , can anyone pls help me about it or can just tell me the right way to learn it? thanks in advance
Stephen James
@sjames1958gm
Nov 27 2016 03:14
The index or position in the array are numbered from 0
so [1, 2, 3] has 1 at position 0 and 2 at position 1 and 3 at position 2
so ourArray[1] = 3 replaces the value at position 1 replacing the 2 with a 3 giving [1,3,3]
sktipwr
@sktipwr
Nov 27 2016 03:18
??
i taught here all are the legend in code. i want to learn JS on-line , can anyone pls help me about it or can just tell me the right way to learn it? thanks in advance
??
Aiden
@AidenMead
Nov 27 2016 03:19
@Byzgig That audio made my fiance, who is sitting next to me jump, and I burst out laughing
WKhaw
@vickyhaw94
Nov 27 2016 03:20
function factorialize(num) {
  var total;
  while(num > 0){
    total = num * (num-1);
    num--;
  }
  return total;
}

factorialize(5);
Hi, currently doing the factorialize a number challenge.
I wondering what wrong with my code, really cant find any errors.
Any help will be appreciate!
Stephen James
@sjames1958gm
Nov 27 2016 03:20
@sktipwr You can start the javascript program here on FCC, there is codewars.com for practicing algorithms.
I would just jump right in and start coding - that is the best way
flaviojc
@flaviojc
Nov 27 2016 03:20
@sjames1958gm Im still loss in that task. Im very new on this and somethings are a bit hard to get.
function nextInLine(arr, item) {
// Your code here
return item; // Change this line
}
// Test Setup
var testArr = [1,2,3,4,5];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
and I have to do this
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
Brennan Glynn
@BrennanGlynn
Nov 27 2016 03:20
Stephen James
@sjames1958gm
Nov 27 2016 03:21
@flaviojc Do you recall which function adds to the end of an array?
@vickyhaw94 You are just setting total to the last two values (you need to have a running total).
I am guessing this results in zero each time (1 * 0)
sktipwr
@sktipwr
Nov 27 2016 03:22
@sjames1958gm thank you :))
CamperBot
@camperbot
Nov 27 2016 03:22
sktipwr sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4552 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Hanyang Liao
@LHyNick
Nov 27 2016 03:22
@sjames1958gm hello, I can't understand how to use RegExp to find "\" in this string "0_0 (: /-\ :) 0-0" . There is question that the backslash can not show, because there is only one.
sktipwr
@sktipwr
Nov 27 2016 03:22
can you guys help me more pls ?
flaviojc
@flaviojc
Nov 27 2016 03:23
@sjames1958gm this is an array right "[1,2,3]"?
Stephen James
@sjames1958gm
Nov 27 2016 03:23
@LHyNick /\\/g should find backslash - but maybe you want to remove all that are not 0-9 a-z?
@flaviojc Yes
@flaviojc In this challenge since you have a function the array is in the variable arr
sktipwr
@sktipwr
Nov 27 2016 03:24
what is Fcc @sjames1958gm ?
Stephen James
@sjames1958gm
Nov 27 2016 03:24
@sktipwr Free code camp - this is a forum for that -
WKhaw
@vickyhaw94
Nov 27 2016 03:25
@sjames1958gm Hi, yeah i am wondering why it return 0 in this situation? Since the input is 5, so in the while loop should be 5 4 then 3 then etc. How come it return 0?
Stephen James
@sjames1958gm
Nov 27 2016 03:25
@flaviojc Right before this challenge I thought there were for challenges for arrays.
sktipwr
@sktipwr
Nov 27 2016 03:25
@sjames1958gm thank you :)
CamperBot
@camperbot
Nov 27 2016 03:25
sktipwr sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: sktipwr already gave sjames1958gm points
Stephen James
@sjames1958gm
Nov 27 2016 03:26
@vickyhaw94 because when num is 1 (the last value before the loop finishes) you have total = num * (num - 1) which is 1 * 0
@vickyhaw94 total will be 20, then 12, then 6, then 2 then 0 and only the last value is returned
flaviojc
@flaviojc
Nov 27 2016 03:27
@sjames1958gm the challenge before is "Assignment with a Returned Value"
Stephen James
@sjames1958gm
Nov 27 2016 03:28
@flaviojc A few farther back - there was Manipulate Arrays With push as well as pop, unshift and shift -
these are relevant here.
Hanyang Liao
@LHyNick
Nov 27 2016 03:28
@sjames1958gm but there is only one backslash, and the string can not show one backslash. The question want me to find whether the string is Palindromes.
WKhaw
@vickyhaw94
Nov 27 2016 03:30
@sjames1958gm How come only last value is return? Since i using while loop, the total should be keep accumulate the number right?
Stephen James
@sjames1958gm
Nov 27 2016 03:30
@LHyNick In the actual testing code palindrome(\"0_0 (: /-\\ :) 0-0\") this is the call
@vickyhaw94 when you assign total = something new each time you are not accumulating anything.
If you did something like total = total * num then you would accumulate.
flaviojc
@flaviojc
Nov 27 2016 03:31

This is the instructions: "Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
So i have to write
function nextInLine(1, 1);
return arr

This is what I'm understanding.

Stephen James
@sjames1958gm
Nov 27 2016 03:32
@flaviojc That function body is provided - you need to put the code inside the function
Hanyang Liao
@LHyNick
Nov 27 2016 03:32
Stephen James
@sjames1958gm
Nov 27 2016 03:33
@flaviojc The function definition has function nextInLine(arr, item) so you need to write code that manipulates arr and item per the instructions above
David Halls
@DavidHalls
Nov 27 2016 03:34
@AidenMead lucky she didnt get fatalitied
Stephen James
@sjames1958gm
Nov 27 2016 03:35
@flaviojc do you recall how to add to the end of an array?
Aiden
@AidenMead
Nov 27 2016 03:35
lol
Stephen James
@sjames1958gm
Nov 27 2016 03:35
@BrennanGlynn I hit 9 + 9 + 9 + 9 I expected that to continually accumulate 9s but it didn'
Brennan Glynn
@BrennanGlynn
Nov 27 2016 03:36
@sjames1958gm Ahhh thanks I'll work on that next
CamperBot
@camperbot
Nov 27 2016 03:36
brennanglynn sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4553 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
agusprieto
@agusprieto
Nov 27 2016 03:39
hi guys
can someone help me with a challenge

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

  // Only change code below this line

  var lookup  = {   
    alpha:"Adams",
    bravo:"Boston",
    charlie:"Chicago",
    delta:"Denver",
    echo:"Easy",
    foxtrot:"Frank"
};

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

// Change this value to test
phoneticLookup("alpha") ;
flaviojc
@flaviojc
Nov 27 2016 03:39
@sjames1958gm with nest ?
Stephen James
@sjames1958gm
Nov 27 2016 03:40
@flaviojc You need to go back and review the challenges that start with manipulating arrays with ?
@agusprieto Now you need to set result to the value of the val property of lookup.
agusprieto
@agusprieto
Nov 27 2016 03:41
yes but how
flaviojc
@flaviojc
Nov 27 2016 03:41
I was doing this while speaking with you, but I think I need to review all of them more carefully
I'm completely lost in this challenge.
Brozathon
@Brozathon
Nov 27 2016 03:41
hello all
flaviojc
@flaviojc
Nov 27 2016 03:42
hello
Brozathon
@Brozathon
Nov 27 2016 03:42
I really do not get this switch thing
David Halls
@DavidHalls
Nov 27 2016 03:42
hit me up @Brozathon
agusprieto
@agusprieto
Nov 27 2016 03:42
how can i associate the lookup and the result variables
David Halls
@DavidHalls
Nov 27 2016 03:43
@agusprieto vague much?
Brozathon
@Brozathon
Nov 27 2016 03:43

function caseInSwitch(val) {
var answer = "";
// Only change code below this line

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

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

idk how to post the challenge but i was doing case 1:
David Halls
@DavidHalls
Nov 27 2016 03:44
your case is outside of the switch, so it will never work
help post code
CamperBot
@camperbot
Nov 27 2016 03:44
no wiki entry for: post code
Brozathon
@Brozathon
Nov 27 2016 03:48
my head is about to explode i think i need a break
flaviojc
@flaviojc
Nov 27 2016 03:49
im revising every challenge before the on I got stuck, this may help
one*
WKhaw
@vickyhaw94
Nov 27 2016 03:51
@sjames1958gm Thanks you so much! Finally understand what you trying to say! Thanks!!
CamperBot
@camperbot
Nov 27 2016 03:51
vickyhaw94 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4554 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Islam Ibakaev
@dagman
Nov 27 2016 04:03
i was trying ro reproduce .slice() method. What do you think about it guys?
const slice = (arr, begin = 0, end = 0) => {
    if(!Array.isArray(arr)) return alert("provide array");

    if(end === 0) return arr.filter((_, i) => i >= begin);

    const transform = (index) => {
        const transformed = (arr.length - 1) + index;
        return (transformed > 0) ? arr[transformed] : arr[0];
    };

    if(begin < 0) begin = transform(begin);
    if(end < 0) end = transform(end);

    return arr.filter((_, i) => i >= begin && i < end);
};

slice([1,2,3,4,5,6,7,8,9,10], -5, -3); // returns [ 6, 7 ]
Brian Giles
@briangiles
Nov 27 2016 04:03
Hi guys, I'm stuck on this one: Returning Boolean Values from Functions
I removed the if/else statements and replaced them with return a === b;
but it only returns False
and doesn't complete the challenge
Stephen James
@sjames1958gm
Nov 27 2016 04:08
@vickyhaw94 :+1:
@briangiles Instead of replacing with === you should should keep the comparison from before the change (the function is called isLess)
Brian Giles
@briangiles
Nov 27 2016 04:09
@sjames1958gm thanks!
CamperBot
@camperbot
Nov 27 2016 04:09
briangiles sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4555 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 27 2016 04:11
@dagman This like confuses me - return (transformed > 0) ? arr[transformed] : arr[0];
why would begin or end depend on the array contents?
@dagman slice([3,4,5,6,7,8,9,10,11,12], -5, -3) this returns [10, 11]
Matteo
@matteo-web
Nov 27 2016 04:19
Hi all, i have one problem whit this task Increment a Number with JavaScript
David Halls
@DavidHalls
Nov 27 2016 04:20
speak @matteo-web
feedback?
Matteo
@matteo-web
Nov 27 2016 04:21

var myVar = 87;

// Only change code below this line
myVar = myVar + 1;
myVar++;
myVar = 88;

iceveda06
@iceveda06
Nov 27 2016 04:21
allrite guys im back
David Halls
@DavidHalls
Nov 27 2016 04:22
@matteo-web your adding to myVar twice
iceveda06
@iceveda06
Nov 27 2016 04:22
need some help here...doing the 'wherefore-art-thou'
David Halls
@DavidHalls
Nov 27 2016 04:22
feedback on this one sorry
iceveda06
@iceveda06
Nov 27 2016 04:22
how do i return the property and value of the object?

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  var answer = [];
  var x = Object.keys(source);
  console.log(x + " value of x");
  // Only change code below this line
  for(var i = 0; i < collection.length; i++) {
     arr = Object.keys(collection[i]);
     console.log(collection[i][arr[0]] + " first name");
    console.log(collection[i][arr[1]] + " last name");
    console.log(collection[i][x] + " the one with x");
    if (collection[i][arr[1]] === source[x] && collection[i].hasOwnProperty(x)) {
      console.log(collection[i][x] + " inside if");
      answer.push(collection[i][arr[0]]);
      answer.push(collection[i][arr[1]]);
      return answer;

    }
  }

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

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
David Halls
@DavidHalls
Nov 27 2016 04:22
@matteo-web and then setting myVar to 88, why??
c0d0er
@c0d0er
Nov 27 2016 04:23
@walidashri thanks
CamperBot
@camperbot
Nov 27 2016 04:23
c0d0er sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 701 | @walidashri |http://www.freecodecamp.com/walidashri
iceveda06
@iceveda06
Nov 27 2016 04:23
i get ["Tybalt", "Capulet"] ...it should be [{first: "Tybalt", last: Capulet"}]
Matteo
@matteo-web
Nov 27 2016 04:23
I dont know this myVar = myVar should be changed
Is all ok,only that i dont understand
David Halls
@DavidHalls
Nov 27 2016 04:25
return answer probably returns [object][object]
Matteo
@matteo-web
Nov 27 2016 04:25

'var myVar = 87;

// Only change code below this line
myVar = myVar + 1;
myVar = myVar ++;
'

David Halls
@DavidHalls
Nov 27 2016 04:26
@matteo-web still adding to myVar twice
flaviojc
@flaviojc
Nov 27 2016 04:26

am I in the right way to solve this ?

function nextInLine(arr, item) {
var nextInLine = [[arr], 1];

nextInLine.push(item);
nextInLine.shift();
return item; // Change this line
}

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

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

iceveda06
@iceveda06
Nov 27 2016 04:27
@Byzgig in some cases i did get [object object]
David Halls
@DavidHalls
Nov 27 2016 04:27
@iceveda06 you need to be more specific ie. return answer[0]
iceveda06
@iceveda06
Nov 27 2016 04:29
that would make first: and last: show up?
Phillip Kelley-Dotson
@pkdotson
Nov 27 2016 04:30

function destroyer(arr) {
// Remove all the values
for (i = 1; i < arguments.length; i++){

var newArr = arguments[i];}

return arr.filter(function (e){
return arr !== newArr;
});

}

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

David Halls
@DavidHalls
Nov 27 2016 04:30
i think so
Phillip Kelley-Dotson
@pkdotson
Nov 27 2016 04:30
why isn't this crap working! :(
Matteo
@matteo-web
Nov 27 2016 04:30
@Byzgig sorry i dont understand!

var myVar = 87;

// Only change code below this line
myVar = myVar + 1;
var test = 88;
myVar = myVar ++;
test = test --;

iceveda06
@iceveda06
Nov 27 2016 04:31
what crap @pkdotson
Phillip Kelley-Dotson
@pkdotson
Nov 27 2016 04:31
My code
David Halls
@DavidHalls
Nov 27 2016 04:31
@matteo-web myVar = myVar + 1; and myVar = myVar++; are doing the same thing
iceveda06
@iceveda06
Nov 27 2016 04:31
which one are you working on?
David Halls
@DavidHalls
Nov 27 2016 04:32
@matteo-web so you are adding 2 to myVar
Phillip Kelley-Dotson
@pkdotson
Nov 27 2016 04:32
@iceveda06 seek and destory
Will
@Will-is-Coding
Nov 27 2016 04:33
myVar++ is equivalent to myVar = myVar + 1 you don't need to set it equal to it as well like you do with myVar = myVar++
Matteo
@matteo-web
Nov 27 2016 04:34

var myVar = 87;

// Only change code below this line
myVar = myVar++;

Is not equal 88
David Halls
@DavidHalls
Nov 27 2016 04:35
ya, it is
johcoh11
@johcoh11
Nov 27 2016 04:37

Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.

Help!

Joseph
@revisualize
Nov 27 2016 04:37
hey.
Remainder:
http://images.tutorvista.com/cms/images/38/remainder1.PNG
13 % 2 is 1 ... 26 % 5 is 1 ... 24 % 6 is 0
24 % 5 is 4 ... 219 % 20 is 19 ... Does that help?
David Halls
@DavidHalls
Nov 27 2016 04:38
@johcoh11 i can help
Joseph
@revisualize
Nov 27 2016 04:38

@matteo-web

var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8

See how the one for getting num from 7 to 8 doesn't use the assignment operator (=)?
The lesson is requesting that you recreate that process so that you know how to increment and decrement a number with short notation.

johcoh11
@johcoh11
Nov 27 2016 04:39
I get the math, but how do I write it?
Joseph
@revisualize
Nov 27 2016 04:39
@johcoh11 var num = 1 + 2; What is num?
Phillip Kelley-Dotson
@pkdotson
Nov 27 2016 04:39

function destroyer(arr) {
// Remove all the values
for (i = 1; i < arguments.length; i++){

var newArr = arguments[i];}

return arr.filter(function (e){
return arr !== newArr;
});

}

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

johcoh11
@johcoh11
Nov 27 2016 04:40
@revisualize ...what? lol
Joseph
@revisualize
Nov 27 2016 04:41
@johcoh11 That's what I'm asking you. What??
johcoh11
@johcoh11
Nov 27 2016 04:42
How do I write remainders? "Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator." @revisualize
David Halls
@DavidHalls
Nov 27 2016 04:43
var num = 11 % 3;
Matteo
@matteo-web
Nov 27 2016 04:44

var myVar = 87;

// Only change code below this line

var num = 87;
num = num + 1;

He Liu
@HeLiu
Nov 27 2016 04:44
function stringLength(string) {
    return string ? 1 + stringLength(string.slice(1)) : 0;
}

console.log(stringLength("game"));
hello this is the length property rewritten
David Halls
@DavidHalls
Nov 27 2016 04:45
no
He Liu
@HeLiu
Nov 27 2016 04:45
it isnt?
it tells the length of a string
David Halls
@DavidHalls
Nov 27 2016 04:45
string.length try
Matteo
@matteo-web
Nov 27 2016 04:45

var myVar = 87;

// Only change code below this line

var num = 87;
num = num + 1;
myVar++;

lol
David Halls
@DavidHalls
Nov 27 2016 04:46
@matteo-web dude, what are you working on?
Matteo
@matteo-web
Nov 27 2016 04:46
Now i have understand thank you
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 04:46
hi guys i have a problem on "Chunky Monkey" challenge, compiler says to me there is a infinite loop but i cant see ho my loop is infinite, any one can help? this is my code :
David Halls
@DavidHalls
Nov 27 2016 04:46
@Hossein-Ghanaati paste it
He Liu
@HeLiu
Nov 27 2016 04:46
you mean "string"? @Byzgig
it tells the length of a string
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 04:46
well i did
function chunkArrayInGroups(arr, size) {
// Break it up.
var newArr = [];
//
for ( i = 0; i < arr.length; i + size ) {
newArr.push(arr.slice(i, i + size));
}
return newArr;
}
David Halls
@DavidHalls
Nov 27 2016 04:47
@Hossein-Ghanaati nope
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 04:47
blob
Khensura25
@Khensura25
Nov 27 2016 04:47

function updateRecords(id, prop, value) {

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

else if (value === "") {
delete collection[id][prop];
}
return collection;
}

Joseph
@revisualize
Nov 27 2016 04:47
@johcoh11 You do it the same way you do any math operations with JavaScript.
Matteo
@matteo-web
Nov 27 2016 04:47
@Byzgig whats is tag for post code here ?
Khensura25
@Khensura25
Nov 27 2016 04:47
some help please
David Halls
@DavidHalls
Nov 27 2016 04:47
@HeLiu i mean string.length
crazycoder775
@crazycoder775
Nov 27 2016 04:47
// Setup
function phoneticLookup(val) {
var result = "";
var lookup={
// Only change code below this line
"alpha":"Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo":"Easy",
"foxtrot": "Frank"
};
result=lookup[""];
// Only change code above this line
return result;
}
// Change this value to test
phoneticLookup("charlie");
What am I doing wrong with this code?
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 04:48
i dont understand
Joseph
@revisualize
Nov 27 2016 04:48
@crazycoder775 lookup[""] isn't looking anything up.
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 04:48
i do it always
Moisés Man
@moigithub
Nov 27 2016 04:48
@Hossein-Ghanaati for ( i = 0; i < arr.length; i + size ) {
i is not changing.. should be i=i+size
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 04:48
it is in js library
Khensura25
@Khensura25
Nov 27 2016 04:48

heres the direction : Write a function which takes an album's id (like 2548), a property prop (like "artist" or "tracks"), and a value (like "Addicted to Love") to modify the data in this collection.

If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.

Your function must always return the entire collection object.

There are several rules for handling incomplete data:

If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.

If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array.

If value is empty (""), delete the given prop property from the album.

Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 04:48
oh ok
David Halls
@DavidHalls
Nov 27 2016 04:48
help
Joseph
@revisualize
Nov 27 2016 04:49
@johcoh11 var addition = 2 + 2;
@johcoh11 var subtraction = 1 - 1;
crazycoder775
@crazycoder775
Nov 27 2016 04:49
@revisualize I tried with lookup[alpha] and others but they are giving only a single object, I want to get the result for all the objects
Joseph
@revisualize
Nov 27 2016 04:49
@johcoh11 var multiplication = 5 * 5;
Khensura25
@Khensura25
Nov 27 2016 04:49

my code: if (prop !== "tracks"){
collection[id][prop] = value;
}
else if (prop === "tracks" && value !== ""){
collection[id][prop]=[];
collection[id][prop].unshift(value);
}

else if (value === "") {
delete collection[id][prop];
}
return collection;
}

Joseph
@revisualize
Nov 27 2016 04:49
@crazycoder775 Is alpha a variable?
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 04:49
@moigithub tnx man in worked :)
it worked*
JaySnel
@JaylanSnelson
Nov 27 2016 04:50
hey you guys! can anyone help with this? im very confused

function caseInSwitch(val) {
var answer = "";
// Only change code below this line

switch (answer) {

 case 1:
 console.log("alpha");
 break;

 case 2:
 console.log("beta");
 break;

 case 3:
 console.log("gamma");
 break;

 case 4:
 console.log("delta");
 break;

}

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

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

crazycoder775
@crazycoder775
Nov 27 2016 04:50
@revisualize Alpha is in the table, inside the variable :
var lookup={
// Only change code below this line
"alpha":"Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo":"Easy",
"foxtrot": "Frank"
};
Joseph
@revisualize
Nov 27 2016 04:51
@crazycoder775 What is the variable?
Chance Vodnoy
@esgameco
Nov 27 2016 04:51
@JaylanSnelson What exersize is it?
David Halls
@DavidHalls
Nov 27 2016 04:51
@JaylanSnelson break exits the loop
Joseph
@revisualize
Nov 27 2016 04:51

@crazycoder775 Parameters are variables that represent the values that get passed into your function from the function call.
https://cs.wellesley.edu/~cs110/lectures/L16/images/function-anatomy.png
Notice how the variables level and score in the function definition addScore are called parameters.
However, when we invoke the function like in:
addScore(3, 10) or addScore(6, 20)
the values are called arguments. Here is an important lesson:
You define a function with parameters, you call a function with arguments.

Another example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

Other important things to remember:
* A function can have zero parameters. You still have to use the parentheses to define it.
* A function might have no return statements. In this case we say that the function returns undefined.

David Halls
@DavidHalls
Nov 27 2016 04:51
and it returns nothing
Matteo
@matteo-web
Nov 27 2016 04:52
code
David Halls
@DavidHalls
Nov 27 2016 04:52
and your only printing to the console :(
JaySnel
@JaylanSnelson
Nov 27 2016 04:52
@esgameco its the Selecting from many options with Switch Statements
Matteo
@matteo-web
Nov 27 2016 04:53
var code = "sorry";
Mmmmm sorry! i have tested
JaySnel
@JaylanSnelson
Nov 27 2016 04:53
@Byzgig so i shouldnt use break at all?
David Halls
@DavidHalls
Nov 27 2016 04:53
@JaylanSnelson i dont think for the excersice you are on
Chance Vodnoy
@esgameco
Nov 27 2016 04:54
@JaylanSnelson Instead of console.logging you should set a variable to it
@JaylanSnelson Answer specificly
@JaylanSnelson Also switch Val not Answer
Paulo Tokimatu
@paulotokimatu
Nov 27 2016 04:55
@JaylanSnelson the thing is: you used "switch(answer)" in your code, but what value holds this variable? Nothing at all. So this code would not work
Joseph
@revisualize
Nov 27 2016 04:56
@JaylanSnelson read the text + graphic that I posted.
Chance Vodnoy
@esgameco
Nov 27 2016 04:56
David Halls
@DavidHalls
Nov 27 2016 04:57
@esgameco

You are given a JSON object representing a part of your musical album collection. Each album has several properties and a unique id number as its key. Not all albums have complete information.

Write a function which takes an album's id (like 2548), a property prop (like "artist" or "tracks"), and a value (like "Addicted to Love") to modify the data in this collection.

If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.

Your function must always return the entire collection object.

There are several rules for handling incomplete data:

If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.

If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array.

If value is empty (""), delete the given prop property from the album.

JaySnel
@JaylanSnelson
Nov 27 2016 04:57
@Byzgig @esgameco @paulotokimatu switching answer to val and not console.logging worked like a charm. Thanks you guys
CamperBot
@camperbot
Nov 27 2016 04:57
jaylansnelson sends brownie points to @byzgig and @esgameco and @paulotokimatu :sparkles: :thumbsup: :sparkles:
:cookie: 217 | @esgameco |http://www.freecodecamp.com/esgameco
:cookie: 296 | @paulotokimatu |http://www.freecodecamp.com/paulotokimatu
:cookie: 379 | @byzgig |http://www.freecodecamp.com/byzgig
Khensura25
@Khensura25
Nov 27 2016 04:57
some help anyone??
David Halls
@DavidHalls
Nov 27 2016 04:57
@Khensura25 you got it buddy
Cal-culator
@Cal-culator
Nov 27 2016 04:58
var api="https://en.wikipedia.org/w/api.php?action=query&titles="; var api2="&prop=images&imlimit=20&format=json";
var articles={};
function random(){

}
function search(title){
  var xml=new XMLHttpRequest();
  var url=api+title+api2;
  console.log(xml.status);
  console.log(xml.readyState);
  console.log(url);
  xml.onreadystatechange = function() {
  if (xml.readyState==4 && xml.status==200){
    var data=JSON.parse(xml.responseText);

    update(articles);
  }

  xml.open("GET", url, true);
  xml.send();
}
}
function update(articles){

}
document.getElementById('search').onkeypress = function(e){
    if (!e) e = window.event;
    var keyCode = e.keyCode || e.which;
    if (keyCode == '13'){
      var title=document.getElementById("search").value;
      search(title);
    }
  }
Why does the readyState and status output 0?
flaviojc
@flaviojc
Nov 27 2016 04:59
how do I copy the page like this??
Waqas Abbasi
@Waqas909
Nov 27 2016 04:59

@flaviojc

You put "~~~

your code

~~~"

without the quotation marks
Chance Vodnoy
@esgameco
Nov 27 2016 05:00
@flaviojc
Do that like `` or
```*
flaviojc
@flaviojc
Nov 27 2016 05:00
function nextInLine(arr, item) {
  var nextInLine = [["arr"], [1]];

  nextInLine.push();
  nextInLine.shift();
  return nextInLine;
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
David Halls
@DavidHalls
Nov 27 2016 05:01
@Cal-culator im guessing it has something to do with the &&
flaviojc
@flaviojc
Nov 27 2016 05:01
thanks
And by the way, what am I doing wrong here? Im stuck on this.
Joseph
@revisualize
Nov 27 2016 05:01
@flaviojc nextInLine is a function. Not a variable.
Cal-culator
@Cal-culator
Nov 27 2016 05:01
@Byzgig I know that the url isn't the issue here because I entered it into the url field and it outputs the JSON
crazycoder775
@crazycoder775
Nov 27 2016 05:02
@revisualize Thank you for the info. I know the parameters and arguments concept of a function. I am trying to access objects from a variable. Here I have 6 object names which I can access individually without any issue by calling the object name eg : lookup["alpha"]; but I want to make it generic so that instead of calling lookup["beta"]; myself to access the next object, it should run in a loop
CamperBot
@camperbot
Nov 27 2016 05:02
crazycoder775 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2419 | @revisualize |http://www.freecodecamp.com/revisualize
David Halls
@DavidHalls
Nov 27 2016 05:02
didnt say anything about the url
Cal-culator
@Cal-culator
Nov 27 2016 05:03
@Byzgig Oh. What did you mean by the &&
David Halls
@DavidHalls
Nov 27 2016 05:03
i think your function is broke
i think the and statement might be the problem
Cal-culator
@Cal-culator
Nov 27 2016 05:04
@Byzgig Can you help me figure out which part?
@Byzgig xml.readyState outputs 0 and xml.status also outputs 0
David Halls
@DavidHalls
Nov 27 2016 05:05
i dont know xml, but this is confusing
document.getElementById('search').onkeypress = function(e){
if (!e) e = window.event;
var keyCode = e.keyCode || e.which;
if (keyCode == '13'){
var title=document.getElementById("search").value;
search(title);
}
}
Cal-culator
@Cal-culator
Nov 27 2016 05:06
@Byzgig I am sure that's not the problem because all that function does is accept the value inside the <input> when I click enter
David Halls
@DavidHalls
Nov 27 2016 05:06
well your asking if xml.readystate == 4 not 0 so something wrong there
flaviojc
@flaviojc
Nov 27 2016 05:07

~~~
function nextInLine(arr, item) {

nextInLine.push(item);
nextInLine.shift(arr);
return arr ;
}
~~~ Do I have to substitute arr for [arr] and item for any number? Im new on this and its a bit dificult to understand what I have to do.

David Halls
@DavidHalls
Nov 27 2016 05:09
sorry, was just copying your code to a new page
so you have if (xml.readyState==4 && xml.status==200){
and your saying that xml.readySate = 0 and xml.status = 0 so your code will never enter this loop
Cal-culator
@Cal-culator
Nov 27 2016 05:10
@Byzgig yeah basically
Paulo Tokimatu
@paulotokimatu
Nov 27 2016 05:11
@flaviojc [arr] is a wrong syntax
shift() removes the first element from an array, and there is no need for arguments (the things in parentheses9
and nextInLine is a function, not an array, so the methods .push() and .shift() would not work
David Halls
@DavidHalls
Nov 27 2016 05:12
@Cal-culator so, your xml must be wrong or your calling it before the page is ready
Cal-culator
@Cal-culator
Nov 27 2016 05:12
@Byzgig That seems to be the issue. The question is how do i fix it
Khensura25
@Khensura25
Nov 27 2016 05:13

@Byzgig heres the direction: Write a function which takes an album's id (like 2548), a property prop (like "artist" or "tracks"), and a value (like "Addicted to Love") to modify the data in this collection.

If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.

Your function must always return the entire collection object.

There are several rules for handling incomplete data:

If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.

If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array.

If value is empty (""), delete the given prop property from the album.

flaviojc
@flaviojc
Nov 27 2016 05:13
@paulotokimatu so I have to write an array like
~var nextInLine = [[arr], item];
~
David Halls
@DavidHalls
Nov 27 2016 05:13
@Cal-culator you need to figure out where ready state = 4 is and work from there
@Khensura25 mmhmm, im familiar, show your code
flaviojc
@flaviojc
Nov 27 2016 05:14
"~var nextInLine = [[arr], item];"
Khensura25
@Khensura25
Nov 27 2016 05:15

@Byzgig function updateRecords(id, prop, value) {

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

else if (value === "") {
delete collection[id][prop];
}
return collection;
}

David Halls
@DavidHalls
Nov 27 2016 05:15
help
Khensura25
@Khensura25
Nov 27 2016 05:16
huh
flaviojc
@flaviojc
Nov 27 2016 05:16
@paulotokimatu Eu sou novo em programação e a forma como as tarefas são apresentadas são um pouco confusas pra mim, tenho apenas 1 semana e apenas podendo gastar 1h devido a faculdade.
David Halls
@DavidHalls
Nov 27 2016 05:16
go paste your code
Khensura25
@Khensura25
Nov 27 2016 05:17

function updateRecords(id, prop, value) {

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

else if (value === "") {
delete collection[id][prop];
}
return collection;
}

crazycoder775
@crazycoder775
Nov 27 2016 05:19
@revisualize got what I was doing wrong, hope I got your point now
David Halls
@DavidHalls
Nov 27 2016 05:19
is camper bot broken?
@Khensura25 try collection[id][prop] = value;
Nicolas Nielsen
@niconielsen
Nov 27 2016 05:31
hi
does someone sees the error
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;
}
Ogundele Olumide
@Lumexralph
Nov 27 2016 05:32
@niconielsen your loop seems to be wrong
Nicolas Nielsen
@niconielsen
Nov 27 2016 05:33
the error says cannot read property length of undefined
Sergio Salinas
@sergiosalfer
Nov 27 2016 05:34
becouse you don't define the array multiplyAll
change the name of multiplyAll to arr
Nicolas Nielsen
@niconielsen
Nov 27 2016 05:34
its defined under the comment
Ogundele Olumide
@Lumexralph
Nov 27 2016 05:34
@niconielsen multiplyAll is the name of your function probabaly you're thinking of using the length of arr which is your parameter from your function....because multiplyAll is the name of your function
Nicolas Nielsen
@niconielsen
Nov 27 2016 05:34
this is the entire

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]]);
Sergio Salinas
@sergiosalfer
Nov 27 2016 05:34
buy you're passing one array arr in the function, use it
Ogundele Olumide
@Lumexralph
Nov 27 2016 05:35
@niconielsen your for loops
Nicolas Nielsen
@niconielsen
Nov 27 2016 05:35
@Lumexralph you are seeing it
Ogundele Olumide
@Lumexralph
Nov 27 2016 05:35
yes
Sergio Salinas
@sergiosalfer
Nov 27 2016 05:35
you can't use the same name for the variables and for the function
Nicolas Nielsen
@niconielsen
Nov 27 2016 05:35
thats the template
and i think you can
Ogundele Olumide
@Lumexralph
Nov 27 2016 05:35
@niconielsen your multiplyAll is not defined
that's why it's saying undefined
Sergio Salinas
@sergiosalfer
Nov 27 2016 05:36
´´´
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0;i < arr.length;i++){
for(var j=0;j < arr[i].length;j++){
product *= arr[i][j];
}
}
// Only change code above this line
return product;
}
´´´
Nicolas Nielsen
@niconielsen
Nov 27 2016 05:37
thanks
a lor
lot
Ogundele Olumide
@Lumexralph
Nov 27 2016 05:37
but use your arr from your function in place of the nultiplyAll in your function, you should be checking against the length of the array
Nicolas Nielsen
@niconielsen
Nov 27 2016 05:37
having the Help button so User friendly is dangerous
Ogundele Olumide
@Lumexralph
Nov 27 2016 05:37
not length of your function
Nicolas Nielsen
@niconielsen
Nov 27 2016 05:37
yes
David Halls
@DavidHalls
Nov 27 2016 05:37
@sergiosalfer whatcha doing man?
Nicolas Nielsen
@niconielsen
Nov 27 2016 05:37
using the global name not the local
Ogundele Olumide
@Lumexralph
Nov 27 2016 05:38
@niconielsen understand now?
Nicolas Nielsen
@niconielsen
Nov 27 2016 05:38
gotit
Ogundele Olumide
@Lumexralph
Nov 27 2016 05:39
@niconielsen cool
Nicolas Nielsen
@niconielsen
Nov 27 2016 05:39
THKS
Kirby James
@kirbygit
Nov 27 2016 05:46
anybody in south bay area
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 05:51
hi guys i am working on "Mutations" challenge and i dont know why my code doesnt work, any one can help? here is my code :

function mutation(arr) {
arr[0] = arr[0].toLowerCase();
arr[0] = arr[0].split('');
arr1 = arr1.toLowerCase();
var foundCharCount = 0;

for ( i = 0; i < arr[0].length; i++ ) {
if (arr[0][i].indexOf(arr1) !== -1) {
foundCharCount++;
}

}
return foundCharCount == arr[0].length;
}

blob
is there any body out there? :)
Ogundele Olumide
@Lumexralph
Nov 27 2016 06:00
@Hossein-Ghanaati doing this arr[0] = arr[0].split(''); turns it to sub-array, just simply store it in a variable say var newArray = arr[0].toLowercase() and split it
use that also for arr1, then you can use them in your loop
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:01
ok tnx i try it now
still doesnt work

function mutation(arr) {
var first = arr[0].toLowerCase().split('');

var second = arr1.toLowerCase();
var foundCharCount = 0;

for ( i = 0; i < first.length; i++ ) {
if (first[i].indexOf(second) == -1) {
foundCharCount++;
}

}
return foundCharCount == arr[0].length;
}

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

Paulo Tokimatu
@paulotokimatu
Nov 27 2016 06:08

@Hossein-Ghanaati is this right?
first[i].indexOf(second) == -1

I think it is the other way

Ogundele Olumide
@Lumexralph
Nov 27 2016 06:08
@Hossein-Ghanaati it should be return foundCharCount === second.length
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:09
@paulotokimatu i checked either way
@Lumexralph i did that too still doesnt work
Ogundele Olumide
@Lumexralph
Nov 27 2016 06:10
@Hossein-Ghanaati your comparison should be index of element in second from first
@Hossein-Ghanaati you have to split second to an array then pick each element from second and check for its index in first
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:11
@Lumexralph no man i think it should be first any way i did that too still doesnt work
Ogundele Olumide
@Lumexralph
Nov 27 2016 06:11
you're trying to check if the characters in second are present in first
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:12
ok then i have to change who le code let me try it :D
Paulo Tokimatu
@paulotokimatu
Nov 27 2016 06:12
@Hossein-Ghanaati according to your code, mutation(["hehehe", "hey"]); would return true, right?
if I undestood correctly
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:13
it should
Ogundele Olumide
@Lumexralph
Nov 27 2016 06:14
@paulotokimatu it won't return true because of "y"
Paulo Tokimatu
@paulotokimatu
Nov 27 2016 06:14
but because the string "hehehe" does not contain a "y", it should actually be false
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:15
yeah i wright it vise-versa you are right
i should change first and second in all code and
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:21
@Lumexralph @paulotokimatu fuk me it still doesnt work, here is the code :

function mutation(arr) {
var first = arr[0].toLowerCase().split('');

var second = arr1.toLowerCase().split('');
var foundCharCount = 0;

for ( i = 0; i < second.length; i++ ) {
if (second[i].indexOf(first) == -1) {
foundCharCount++;
}

}
return foundCharCount == second.length;
}

Ogundele Olumide
@Lumexralph
Nov 27 2016 06:21
@Hossein-Ghanaati don't split first
just change first to lowercase
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:23
@Lumexralph still dont work
Ogundele Olumide
@Lumexralph
Nov 27 2016 06:23
@Hossein-Ghanaati
function mutation(arr) {
var first = arr[0].toLowerCase();
var second = arr[1].toLowerCase().split('');
var foundCharCount = 0;
for ( i = 0; i < second.length; i++ ) {
if (second[i].indexOf(first) == -1) {
foundCharCount++;
}
}
return foundCharCount == second.length;
}

mutation(["hello", "Hell"]);
that should work
Paulo Tokimatu
@paulotokimatu
Nov 27 2016 06:24
@Hossein-Ghanaati try (first.indexOf(second[i]) == -1
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:24
@Lumexralph nope
Ogundele Olumide
@Lumexralph
Nov 27 2016 06:25
@Hossein-Ghanaati it returned true, i meant the above code
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:26
@paulotokimatu nope
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:26
@paulotokimatu @Hossein-Ghanaati first.indexOf(second[i]) > -1
Ogundele Olumide
@Lumexralph
Nov 27 2016 06:26
@Hossein-Ghanaati what are we getting wrong then
@ghulamshabir hey bro, how's your throat?
feeling great now, right?
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:27
@ghulamshabir tnx it worked but i dont understand why ? :D
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:27
@Lumexralph hey dear, I am recovering now, thanks
CamperBot
@camperbot
Nov 27 2016 06:27
ghulamshabir sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 492 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Nov 27 2016 06:27
glad to hear that
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:28
@Hossein-Ghanaati you were supposed to count number of letters which existed in first string
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:28
@ghulamshabir yeah but why it doesnt work with == -1?
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:28
@Hossein-Ghanaati indexOf returns 0 or positive value if it finds letter
Paulo Tokimatu
@paulotokimatu
Nov 27 2016 06:28
@ghulamshabir oops, that is right. I am kinda useless in reading code from others :(
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:29
@ghulamshabir and if it doesnt -1
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:29
@Hossein-Ghanaati ye
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:29
base on mozila documentation
but == -1 doesnt work
!= -1 *
we checked it, it is wierd
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:30
@paulotokimatu sometimes it happens :smile:
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:31
:)
tnx man :)
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:31
@Hossein-Ghanaati :smile: you are irani ?
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:31
yes
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:32
I am from pakistan
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:32
nice :) are programmer there good programmer?
here are too uninformed
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:33
@Hossein-Ghanaati ye here people are good programmer
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:34
it can be a very good income for countries like us specially through sites like freelancer we can have a very good income compared to others in our country
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:35
@Hossein-Ghanaati freelancing is not for beginners/inexperienced I think
@Hossein-Ghanaati you will need experience of building a project from start to finnish in as less time as possible
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:36
why not? did you look at jobs offer there? many of them are very simple
many of them are not projects
they just want a simple functionality or something
besides that you get paid in dollor
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:37
where ? freelance.com ?
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:38
js is not my first though, i am not a experienced programmer but i know a few in basi lvl
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:39
how is iran ?
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:40
we have very similar country man, you know it :) but if you have more specific question i can answer
specially baloochestan(southeast of iran) is very similr to pakistan
michael
@buffmike
Nov 27 2016 06:41
@Hossein-Ghanaati how long have you been programming
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:42
@Hossein-Ghanaati you are baloch ?
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:42
well i never did it as a job but i know C up to pointers and Java for andoid and some basic functionality of php
no i am not but i was lived there for a few month
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:43
@Hossein-Ghanaati oh I am baloch
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:43
nice :)
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:43
@Hossein-Ghanaati :smile: chey halen ?
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:44
i am mix of russian's turks and arabs :D all are my ancestors
i was there but i dont understand the language :D
we spook farsi there
i was at military service in near the border
Ghulam Shabir
@ghulamshabir
Nov 27 2016 06:45
ye farsi is similar to balochi i have heard
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:45
yeah they ar similar
drummer2595
@drummer2595
Nov 27 2016 06:51

Hello Can anyone please help? Im doing the standing in line section and need some help. Here is my code:


function nextInLine(arr, item) {
  // Your code here
  testArr.push(item);
  return testArr.shift();  // Change this line
}

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

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

Thanks in advance!

Screen Shot 2016-11-27 at 1.49.36 AM.png
Screen Shot 2016-11-27 at 1.49.36 AM.png
Thats the problem^
Merlyn007
@Merlyn007
Nov 27 2016 06:53
Hello people
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:53
you souldnt do anything on testArr @drummer2595
@drummer2595 you should do it on arr which is the value that you function get from app
drummer2595
@drummer2595
Nov 27 2016 06:55
Thanks!
Merlyn007
@Merlyn007
Nov 27 2016 06:55

People I have a problem and I dont get it.
this is mi index.html
<!doctype html>

<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<script src="../scripts/libs/jquery.min.js"></script>
<script src="../scripts/libs/bootstrap/js/bootstrap.min.js"></script>
<link href="../scripts/libs/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script src="../scripts/libs/angular.js"></script>
<script src="index.js"></script>
</head>

<body ng-app="app">
<h2>Cucumber software</h2>
<ui-view></ui-view>
</body>

</html>

Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:55
np
Merlyn007
@Merlyn007
Nov 27 2016 06:55
mmmm
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:55
@drummer2595 did you understand it why?
Merlyn007
@Merlyn007
Nov 27 2016 06:55
sorry
im trying to write in a good way
drummer2595
@drummer2595
Nov 27 2016 06:57
Yes, i tried using just arr.push(item) earlier and FCC kept giving me an error stating it wasn't a function. So thats kind of how I got stuck.
Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:57
so ir works now?
it*
drummer2595
@drummer2595
Nov 27 2016 06:58
Yes I guess I refreshing it worked! Thanks
Merlyn007
@Merlyn007
Nov 27 2016 06:58

This is my index.html

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
    <script src="../scripts/libs/jquery.min.js"></script>
    <script src="../scripts/libs/bootstrap/js/bootstrap.min.js"></script>
    <link href="../scripts/libs/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script src="../scripts/libs/angular.js"></script>
    <script src="index.js"></script>
  </head>

  <body ng-app="app">
    <h2>Cucumber software</h2>
    <ui-view></ui-view>
  </body>

</html>

This is the index.js

import angular from '../scripts/libs/angular.js';
import '../scripts/libs/angular-ui-router.min.js';

import contactsModule from 'app/contacts';

import routesConfig from './routes';

import {main} from './app/main';
import './index.css';

angular
  .module('app', [contactsModule,'ui.router'])
  .config(routesConfig)
  .component('app', main);

I have a problem with Syntax Error, i dont know why.
SyntaxError: import declarations may only appear at top level of a module

Why i had this error ?

Hossein Ghanaati
@Hossein-Ghanaati
Nov 27 2016 06:58
np
Parag Shah
@paragshah36
Nov 27 2016 07:00
I am having trouble with Escaping Literal Quotes in Strings.

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

this is what i wrote.

what am i doing wrong?
anybody here?
Ian
@toianw
Nov 27 2016 07:03
@paragshah36 the period on the end is outside you closing quote
@paragshah36 also no opening quote
escape a quote like this: \". You'll need to escape each quotation mark inside the string
Parag Shah
@paragshah36
Nov 27 2016 07:05
I thought there should be no quotes behind I?
Ian
@toianw
Nov 27 2016 07:06
Your whole string needs to be wrapped in quotes. Then escape any quotes inside with the backslash
Parag Shah
@paragshah36
Nov 27 2016 07:10
got it Ian
Ian
@toianw
Nov 27 2016 07:11
@paragshah36 good job
Parag Shah
@paragshah36
Nov 27 2016 07:11
how do i send you brownies or something like that?
Ian
@toianw
Nov 27 2016 07:12
@paragshah36 you just need to mention @name and the word thanks
CamperBot
@camperbot
Nov 27 2016 07:12
toianw sends brownie points to @paragshah36 and @name :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for name
:cookie: 120 | @paragshah36 |http://www.freecodecamp.com/paragshah36
Ian
@toianw
Nov 27 2016 07:13
@paragshah36 look, I just gave you a cookie!
Parag Shah
@paragshah36
Nov 27 2016 07:13
Thanks Camper bot
@toianw how did you do that?
Ian
@toianw
Nov 27 2016 07:14
Like this: @paragshah36 thanks
CamperBot
@camperbot
Nov 27 2016 07:14
toianw sends brownie points to @paragshah36 :sparkles: :thumbsup: :sparkles:
:warning: toianw already gave paragshah36 points
Em Hallam
@emhallam
Nov 27 2016 07:15
Hi there, just wondering if you guys can help me out. With the returning boolean values from functions question
This is my code
Parag Shah
@paragshah36
Nov 27 2016 07:15
@toianw thanks
CamperBot
@camperbot
Nov 27 2016 07:15
paragshah36 sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
:cookie: 434 | @toianw |http://www.freecodecamp.com/toianw
Em Hallam
@emhallam
Nov 27 2016 07:15

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

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

Joseph
@revisualize
Nov 27 2016 07:15
@emhallam less than.
You're doing an equality comparison.
Em Hallam
@emhallam
Nov 27 2016 07:15
@revisualize thank-you. Knew it was something tiny catching me up.
CamperBot
@camperbot
Nov 27 2016 07:15
emhallam sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2421 | @revisualize |http://www.freecodecamp.com/revisualize
Yerrapotu Manojkiran
@nani554
Nov 27 2016 07:21
i have a c-language problem ,i hope somone will solve it

include<stdio.h>

int main(){
char dog[20];
char gorilla;
printf("enter dogs name: ");
scanf("%s",dog);
printf("enter gorilla gender: ");
scanf("%c",&gorilla);
printf("%s",dog);
printf("%c"gorilla);
return 0;
}
i can see only one result only (t.i i can see only dogs result and machine is asking and not showing gorillas result)
machine is not asking and not showing gorillas result
Ayush Bahuguna
@relentless-coder
Nov 27 2016 07:45
@yangguangyang what is it?
Macb2002
@Macb2002
Nov 27 2016 07:46
blob
blob
Can anybody help me at the Counting Card challenge. This is my code trial and I dont know why its not working.
Yerrapotu Manojkiran
@nani554
Nov 27 2016 07:48
@Macb2002 u r using assigning symbol(=) instead of ==
if (card==2)
Macb2002
@Macb2002
Nov 27 2016 07:49
Thank you @nani554 . Ill try that out!
CamperBot
@camperbot
Nov 27 2016 07:49
macb2002 sends brownie points to @nani554 :sparkles: :thumbsup: :sparkles:
:cookie: 48 | @nani554 |http://www.freecodecamp.com/nani554
Yerrapotu Manojkiran
@nani554
Nov 27 2016 07:50
@Macb2002 can u help me out ,see my question by scrolling up
Macb2002
@Macb2002
Nov 27 2016 07:52
Sorry, but I just started learning and still be at the very beginning. Its still not working...
yangguangyang
@yangguangyang
Nov 27 2016 07:56
@relentless-coder no thanks
CamperBot
@camperbot
Nov 27 2016 07:56
yangguangyang sends brownie points to @relentless-coder :sparkles: :thumbsup: :sparkles:
:cookie: 271 | @relentless-coder |http://www.freecodecamp.com/relentless-coder
Ian
@toianw
Nov 27 2016 08:01
@Macb2002 you need a space between count and Bet / Hold
Yerrapotu Manojkiran
@nani554
Nov 27 2016 08:09
@toianw can u help me in c-language
please
Ian
@toianw
Nov 27 2016 08:11
@nani554 sorry, I'm not familiar with C. Just looking at your code, the ampersand looks out of place on this line: scanf("%c",&gorilla);. Should that be there? And maybe a comma missing on this line: printf("%c"gorilla);
Yerrapotu Manojkiran
@nani554
Nov 27 2016 08:19
yeah i modified it ,but still no result
yangguangyang
@yangguangyang
Nov 27 2016 08:29

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

result=myNoun+myAdjective+myVerb+myAdverb;
// Your code above this line
return result;
}

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

i really don't know what is meaning of this
Ghulam Shabir
@ghulamshabir
Nov 27 2016 08:31
@yangguangyang you need to space between words, when your solution runs the result outputs dogbigranquickly, it should big dog ran quickly
yangguangyang
@yangguangyang
Nov 27 2016 08:32
@ghulamshabir ok ,i will try it,thanks
ABitOfKylie
@ABitOfKylie
Nov 27 2016 08:34

ok -- stuck in the same place as @yangguangyang function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

result = "One day I met a " + "wordBlanks[wordBlanks[0]]" + "who was very " + "wordBlanks[wordBlanks1]" + "We " + "wordBlanks[wordBlanks[2]]" + "very " "wordBlanks[wordBlanks[3]]" +".";
// Your code above this line
return result;
}
any hints? @ghulamshabir ?
or should I just use {myNoun} in brackets?

Ghulam Shabir
@ghulamshabir
Nov 27 2016 08:36
@ABitOfKylie use parameters myAjective myNoun instead of wordBlanks[wordBlank[0]] this is not correct
bahaa aldin
@bahaa-al-deen
Nov 27 2016 08:40
@revisualize @Lumexralph hey
do u have time to help me with my simon game project ?
yangguangyang
@yangguangyang
Nov 27 2016 08:44
error,why?
Ghulam Shabir
@ghulamshabir
Nov 27 2016 08:45
@yangguangyang your code ?
yangguangyang
@yangguangyang
Nov 27 2016 08:45
yes
Ghulam Shabir
@ghulamshabir
Nov 27 2016 08:47
@yangguangyang post your code here
ABitOfKylie
@ABitOfKylie
Nov 27 2016 08:52

re: Word Blanks -- "you will need to use string op to build a new string 'result' -- " really not sure what they want. it says .push is not a function....
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

result.push("One day I met a " + myNoun + "who was very " + myAdjective + "We " + myVerb + "very "+ myAdverb +".");
// Your code above this line
return result;
}

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

mamukundan
@mamukundan
Nov 27 2016 08:52
am stuck with the smallest common multiple.
yangguangyang
@yangguangyang
Nov 27 2016 08:52
@ghulamshabir thank you very much ,
CamperBot
@camperbot
Nov 27 2016 08:52
yangguangyang sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1160 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
mamukundan
@mamukundan
Nov 27 2016 08:52
any ideas?
Ghulam Shabir
@ghulamshabir
Nov 27 2016 08:53
@mamukundan your code ?
mamukundan
@mamukundan
Nov 27 2016 08:53
should I paste it here?
yangguangyang
@yangguangyang
Nov 27 2016 08:53
@ghulamshabir your code
mamukundan
@mamukundan
Nov 27 2016 08:54
sorry, am new to the forum.. that's why am asking the question
yangguangyang
@yangguangyang
Nov 27 2016 08:54
@ABitOfKylie thank you ,too
CamperBot
@camperbot
Nov 27 2016 08:54
yangguangyang sends brownie points to @abitofkylie :sparkles: :thumbsup: :sparkles:
:cookie: 103 | @abitofkylie |http://www.freecodecamp.com/abitofkylie
Ghulam Shabir
@ghulamshabir
Nov 27 2016 08:54
@ABitOfKylie do not push, push applies only to arrays and result is not an array its a string just assign to it, result = "One day .....
@mamukundan yes paste here, it would better if know how to format code see more info link '''
CamperBot
@camperbot
Nov 27 2016 08:55
:bulb: to format code use backticks! ``` more info
mamukundan
@mamukundan
Nov 27 2016 08:55
function smallestCommons(arr) {
arr = arr.sort();
var elemArr = [];
var product = 1;
for (var i=arr[0]; i<=arr1; i++){
product = i;
elemArr.push(i);
}
//console.log(product);
var temp = 1;
for (var j=0; j<elemArr.length; j++){
temp = elemArr[j]
elemArr[j];
console.log("temp:"+ temp + "||product:"+ product + "||elemArr[j]:"+ elemArr[j]);
if (product % temp === 0){
product /= elemArr[j];
}
}
return product;
}
my idea was to get the product and start removing the number from the product if it is already there
looks like there is a flaw with this approach
can someone tell me how you approached this problem?
Ghulam Shabir
@ghulamshabir
Nov 27 2016 08:57
@mamukundan first of all arr.sort will not sort numbers in the array, to sort numbers you will need to give callback funtion to sort and return a-b as you might have learned in previous lessons
mamukundan
@mamukundan
Nov 27 2016 08:58
right.. now i remember.. it only sorts strings
i did a quick test which worked.. but that's because my example was incorrect
thanks Ghulam
let me make that change first
Ghulam Shabir
@ghulamshabir
Nov 27 2016 08:59
@mamukundan use @name for thanking
mamukundan
@mamukundan
Nov 27 2016 08:59
@ghulamshabir thanks a lot
CamperBot
@camperbot
Nov 27 2016 08:59
mamukundan sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1161 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Nov 27 2016 08:59
also you need to review is your sum all primes challenge you will need that in this challenge
ABitOfKylie
@ABitOfKylie
Nov 27 2016 08:59
@ghulamshabir - I was missing spaces! how do I send those brownie points?
Ghulam Shabir
@ghulamshabir
Nov 27 2016 09:00
@ABitOfKylie just click on @name and say thanks
CamperBot
@camperbot
Nov 27 2016 09:00
ghulamshabir sends brownie points to @abitofkylie and @name :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for name
:cookie: 105 | @abitofkylie |http://www.freecodecamp.com/abitofkylie
mamukundan
@mamukundan
Nov 27 2016 09:00
@ghulamshabir Ok.. I felt it was a bit challenging and that's why skipped it
let me go back and try
@ghulamshabir thanks again
CamperBot
@camperbot
Nov 27 2016 09:00
mamukundan sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:warning: mamukundan already gave ghulamshabir points
Ghulam Shabir
@ghulamshabir
Nov 27 2016 09:01
@mamukundan :+1: as you go forward in exercises their complexity will increase except few challenges
mamukundan
@mamukundan
Nov 27 2016 09:02
@ghulamshabir got it.. let me try prime numbers and come back.. you guys have been very helpful.. love this forum
ABitOfKylie
@ABitOfKylie
Nov 27 2016 09:02
@ghulamshabir thanks!
CamperBot
@camperbot
Nov 27 2016 09:02
abitofkylie sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1162 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Nov 27 2016 09:02
@mamukundan get in touch here you will learn more than you can on your own
mamukundan
@mamukundan
Nov 27 2016 09:03
@ghulamshabir agree.. didn't know till now.. but realised it
Jean Baptiste Kwizera
@jbkwizera
Nov 27 2016 09:39
hello world!
CamperBot
@camperbot
Nov 27 2016 09:39

welcome to FreeCodeCamp @jbkwizera!

Johnny
@JohnnyBizzel
Nov 27 2016 09:41
@jbkwizera Good day!
@jbkwizera What do you know?
Ghulam Shabir
@ghulamshabir
Nov 27 2016 09:41
@JohnnyBizzel Good afternoon
Jean Baptiste Kwizera
@jbkwizera
Nov 27 2016 09:42
I actually wanted to bring people back here....
Johnny
@JohnnyBizzel
Nov 27 2016 09:42
@ghulamshabir Morning!
Jean Baptiste Kwizera
@jbkwizera
Nov 27 2016 09:43
I got stuck on this bonfire: I am trying to get an array whose arrays are of size of size.
function chunkArrayInGroups(arr, size) {

  var newArr= [];
  for(var i = 0; i<=arr.length; i += size){
    var arrToPush = arr.splice(i-size, i+size);
    newArr.push(arrToPush);
  }
  return newArr;
}
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3);
Arman Galstyan
@AGalstyanK622
Nov 27 2016 09:43
hi all
Jean Baptiste Kwizera
@jbkwizera
Nov 27 2016 09:43
I end up missing one array though
Arman Galstyan
@AGalstyanK622
Nov 27 2016 09:43
blob
how can I FIX it ??
Johnny
@JohnnyBizzel
Nov 27 2016 09:48
@jbkwizera You seem to be doing it backwards
Jean Baptiste Kwizera
@jbkwizera
Nov 27 2016 09:50
is it because of how I am splicing? or the for loop?
Johnny
@JohnnyBizzel
Nov 27 2016 09:52
@jbkwizera I would splice the 1st section of the array first.
@AGalstyanK622 It would be easier if you copy-paste your code instead of a screenshot
@jbkwizera This might work var arrToPush = arr.splice(0, i+size);
Ghulam Shabir
@ghulamshabir
Nov 27 2016 09:54
@AGalstyanK622 give arguments to Book constructor instead of pages and book
Arman Galstyan
@AGalstyanK622
Nov 27 2016 09:55
@JohnnyBizzel @ghulamshabir
// 3 lines required to make harry_potter
var harry_potter = new Object();
harry_potter.pages = 350;
harry_potter.author = "J.K. Rowling";

// A custom constructor for book
function Book (320,"J.R.R. Tolkien") {
    this.pages = pages;
    this.author = author;
}

// Use our new constructor to make the_hobbit in one line
var the_hobbit=new Book(pages,author) ;
//Book(320,"J.R.R. Tolkien");
like this ?
Johnny
@JohnnyBizzel
Nov 27 2016 09:56
@ghulamshabir Someone was asking about this in another room. I think it's pretty cool: https://www.flag-sprites.com/
Ghulam Shabir
@ghulamshabir
Nov 27 2016 09:56
@JohnnyBizzel I will look at it
@AGalstyanK622 you are mixing things up
pages and author should go in Book construction definition
and the values 320 and J.R.R... should good into new Book()
Arman Galstyan
@AGalstyanK622
Nov 27 2016 10:00
@ghulamshabir thanks Ghulam
CamperBot
@camperbot
Nov 27 2016 10:00
agalstyank622 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1163 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Nov 27 2016 10:00
@JohnnyBizzel :smile: awsome
@AGalstyanK622 :smile:
@AGalstyanK622 i solved your problem of printing X diagonally
@AGalstyanK622
function diagonal() {
    for(var i=0; i<5; i++) {
        for(var j=0; j<5; j++) {
            if(j==i)
            process.stdout.write('X')
           else process.stdout.write(' ');
        }
        console.log('');
    }
}
diagonal();
Arman Galstyan
@AGalstyanK622
Nov 27 2016 10:02
thanks
@ghulamshabir Ghulam how can I change this code for Google Developer Toosl
Tools
Ghulam Shabir
@ghulamshabir
Nov 27 2016 10:05
@AGalstyanK622 use document.write and &nbsp; <br>
Arman Galstyan
@AGalstyanK622
Nov 27 2016 10:06
@ghulamshabir its not work
Ghulam Shabir
@ghulamshabir
Nov 27 2016 10:06
show me the code
Arman Galstyan
@AGalstyanK622
Nov 27 2016 10:09


function diagonal() {
    for(var i=0; i<5; i++) {
        for(var j=0; j<5; j++) {
            if(j==i)
            document.write('X')
           else document.write(' ');
        }
        document.write('<br> ');
    }
}
diagonal();
Ghulam Shabir
@ghulamshabir
Nov 27 2016 10:15
@AGalstyanK622 use &nbsp; instead of ' '
Arman Galstyan
@AGalstyanK622
Nov 27 2016 10:17


function diagonal() {
    for(var i=0; i<5; i++) {
        for(var j=0; j<5; j++) {
            if(j==i)
            document.write('X')
           else document.write("%nbsp");
        }
        document.write('<br> ');
    }
}
diagonal()
yeah worked
Ghulam Shabir
@ghulamshabir
Nov 27 2016 10:18
its & not %
@AGalstyanK622 :smile:
Laetitia Myriam
@LaetitiaMyriam
Nov 27 2016 10:31
@Macb2002 you should write return instead of console.log
@Macb2002 for the counting card
Alexandro Pequeno
@Argestis
Nov 27 2016 10:44

do you guys know how can I compare the last part of two arrays?

arrayX[2,3,4,2]
arrayY[3,6,7,2]

How can I do to compare if the last part of two arrays are the same if I'm going to keep on adding values?

Ardis Petermans
@Ardis101
Nov 27 2016 10:44
can somebody help me with Make Object Properties Private? I have no idea what to do there
Mateusz Kadlubowski
@xeho91
Nov 27 2016 10:47
@Argestis that depends what result your function is supposed to return, a single condition could do the job
Stuart Taylor
@Bouncey
Nov 27 2016 10:49
@Argestis have a look at all the different array methods to see what you could use.
@Ardis101 What are you not sure on?
Hi @Iszeak
Adegunle Isaac Seun
@Iszeak
Nov 27 2016 10:53

Please I'm having some issues with passing the Stand in line Challenge. This is my code: function nextInLine(arr, item) {
// Your code here
arr.push(item);
item = arr.pop();
return item;
}

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

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

andry91959
@andry91959
Nov 27 2016 10:54
guys I'm trying to reverse "hello" to "olleh" is this how do you do it?
str.split('').reverse().join('');
Mateusz Kadlubowski
@xeho91
Nov 27 2016 10:54
@Iszeak item = arr.pop(); this is a hint, what's wrong with your code
andry91959
@andry91959
Nov 27 2016 10:55

function reverseString(str) {
str.split('').reverse().join('');
return str;
}

reverseString('hello');

Mateusz Kadlubowski
@xeho91
Nov 27 2016 10:55
@andry91959 you forgot assigment, you need to assign these methods to str