These are chat archives for FreeCodeCamp/HelpJavaScript

12th
Nov 2016
RaphaelNorth
@RaphaelNorth
Nov 12 2016 00:01
@biruhalex welcome!
Diego Mayer
@Chrono79
Nov 12 2016 00:04
@dhruvilshah01 create several if/else using the table
ehutchllew
@ehutchllew
Nov 12 2016 00:11
Hey guys, could someone help me out with a question on Twitch API?
https://codepen.io/ehutchllew/pen/jVWdjR?editors=1111 Line 24, my if statement, for some reason, is applying both conditions to my 3rd row only. The 3rd row should only be met by the 'else', whereas the 1st and 2nd should be the IF.
Joseph
@revisualize
Nov 12 2016 00:14
@Chrono79 Grats on 2500.
Benjamin Kaul
@fullace
Nov 12 2016 00:15
Hey guys I cant get "Falsy Bouncer" to work :/ I have to implement a filter function for an array containing [1, null, NaN, 2, undefined] and I dont know how to filter out NaN
Joseph
@revisualize
Nov 12 2016 00:15
@fullace !isNaN
@fullace Or you could just use Boolean() like the lesson suggests.
Benjamin Kaul
@fullace
Nov 12 2016 00:17
@revisualize Thank you so much! :smile:
CamperBot
@camperbot
Nov 12 2016 00:17
fullace sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2291 | @revisualize |http://www.freecodecamp.com/revisualize
Treylerp
@Treylerp
Nov 12 2016 00:40
so im on the word blanks challange
and need help im confused
Stephen James
@sjames1958gm
Nov 12 2016 00:54
@Treylerp There are 4 parameters whose values will be words (strings) when the function is called, you need to concatenate these
into a single string, separating them with other strings containing words and spaces.
Vu Phung
@VDPhung
Nov 12 2016 01:03
I am trying to do a random quote machine, but I don't know how to keep calling the API, http://codepen.io/Gummy-Bear/pen/mOembw?editors=0010
after I click quote button, it just generate one quote and that's it
I check the console, it is not click function. It json object is not updating
Moisés Man
@moigithub
Nov 12 2016 01:17
@tofu123 $.getJSON("https://crossorigin.me/http://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&lang=en&jsonp=?", function(json) { <-- that works
view-source:http://api.forismatic.com/api/jsonp/
or like this
$.getJSON("http://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&lang=en&jsonp=?&callback=?", function(json) { without crossorigin website.. but jsonP jquery request 'callback=?' <-- on the documentation
Jonathan Mancia
@jonmancia
Nov 12 2016 01:22
On the record collection challenge why is this not accepted?
function updateRecords(id, prop, value) {
  if (prop !== collection.id.props && value !== "") {
   collection = collection[id][prop][value]; 
  }

  return collection;
}
what's wrong with it?
Moisés Man
@moigithub
Nov 12 2016 01:29
@jonmancia is prop and value are variables... no dot notation (on ur IF line )
also u replacing collection (the big object) value with something else
Vu Phung
@VDPhung
Nov 12 2016 01:31
@moigithub thanks, it works !!!!, I am using the first method you gave me. My question is what is the "&jsonp=?" for ?
Eclipseparadox
@Eclipseparadox
Nov 12 2016 01:31
@EfrainAR I'm on the sameone
CamperBot
@camperbot
Nov 12 2016 01:31
:star2: 2187 | @moigithub |http://www.freecodecamp.com/moigithub
tofu123 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
Moisés Man
@moigithub
Nov 12 2016 01:33
@tofu123 thats part of the api documentation.. it return data in jsonp format ...
http://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&jsonp=parseQuote <-- on the example... its named parseQuote
but using jquery... the ? is gonna be replaced by jquery with a function name
Joseph
@revisualize
Nov 12 2016 01:34
cbot
CamperBot
@camperbot
Nov 12 2016 01:34
you called?
Joseph
@revisualize
Nov 12 2016 01:34
@jonmancia if prop is "tracks".
Jonathan Mancia
@jonmancia
Nov 12 2016 01:34
@moigithub what's the difference in using dot notation and bracket?
Joseph
@revisualize
Nov 12 2016 01:34
@EfrainAR You're doing things out of order.
Dot Notation is a String Literal. Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation.
@jonmancia
Jonathan Mancia
@jonmancia
Nov 12 2016 01:35
gotcha
function updateRecords(id, prop, value) {
  if (prop !== collection.id.prop && value !== "") {
   collection = collection.id.prop[value]; 
  }

  return collection;
}
Joseph
@revisualize
Nov 12 2016 01:37
@jonmancia Can I ask you a side question?
Jonathan Mancia
@jonmancia
Nov 12 2016 01:37
yes sir?
Joseph
@revisualize
Nov 12 2016 01:38
@jonmancia Can you write a bit of code for me?
if a variable fName is equal to "Joseph" return "Awesome".
Jonathan Mancia
@jonmancia
Nov 12 2016 01:40
ok
var fName= "Joseph";
if (fName === "Joseph"){
return "Awesome";
}
Joseph
@revisualize
Nov 12 2016 01:41
@jonmancia Can you write another one for me?
If a variable prop is not equal to "tracks" and a variable value is not an empty string "" update a variable myAlbum to the value of the variable value.
Jonathan Mancia
@jonmancia
Nov 12 2016 01:43
if (prop !== "tracks" && value !== ""){
var myAlbum  = value;
}
is that right?
Joseph
@revisualize
Nov 12 2016 01:43
@jonmancia it is.
@jonmancia How does that relate to your challenge? Compared to what you are doing.
Jonathan Mancia
@jonmancia
Nov 12 2016 01:45
Hmmm...
Moisés Man
@moigithub
Nov 12 2016 01:45
i thin k his problem is with object notation
Joseph
@revisualize
Nov 12 2016 01:46
@moigithub That too.. But, he was overcomplicating the if statement in the first place.
@jonmancia Dot Notation is a String Literal. Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation.
@moigithub I try to break things down bit by bit. It helps.. Sometimes.
Jonathan Mancia
@jonmancia
Nov 12 2016 01:47
function updateRecords(id, prop, value) {
  if (prop !== "tracks" && value !== "") {
   collection = collection[id][prop][value]; 
  }

  return collection;
}
Joseph
@revisualize
Nov 12 2016 01:48
@jonmancia Kind of .. but, you're overwriting the WHOLE collection.
You're supposed to assign just the value to the property.
Jonathan Mancia
@jonmancia
Nov 12 2016 01:49
well don't i have to access the object ?
Joseph
@revisualize
Nov 12 2016 01:49
You do.
Jonathan Mancia
@jonmancia
Nov 12 2016 01:49
oh i see what you mean
Joseph
@revisualize
Nov 12 2016 01:49
myAlbum = value;
You wrote that.
Just replace myAlbum with the object.
Okay time for me to jet.
Jonathan Mancia
@jonmancia
Nov 12 2016 01:55
Hmmm what tis the record album's property?
function updateRecords(id, prop, value) {
  if (prop !== "tracks" && value !== "") {
   collection[id][prop][value] = [value]; 
  }

  return collection;
}
thanks for your help @revisualize
CamperBot
@camperbot
Nov 12 2016 02:00
jonmancia sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2292 | @revisualize |http://www.freecodecamp.com/revisualize
Eclipseparadox
@Eclipseparadox
Nov 12 2016 02:05
Stand in Line anyone have thoughts on this excersize
Ian Lee
@asparism
Nov 12 2016 02:08
@asparism
does anyone know how ajax promises work? i can't seem to get my twitch.tv page working properly. http://codepen.io/Asparism/pen/oYbOOv
it works fine with async: false, but with the async i wonder if it's the syntax or logic that i'm not right on
js956717
@js956717
Nov 12 2016 02:14
function updateRecords(id, prop, value) {

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

  return collection;
}
Why doesn't this work?
Diego Mayer
@Chrono79
Nov 12 2016 02:15
@Eclipseparadox review array manipulation methods: pop, push, shift and unshift, use 2 of them
@js956717 collection[id][prop] !== "tracks" ? You have to test if the property exists, with hasOwnProperty
jaredpinargote
@jaredpinargote
Nov 12 2016 02:16
Hello can anyone help me out with the seek and destroy challenge?
I have coded a solution which returns the right answer, but it is still being registered as incorrect

Here is my code
'''
function compare(val){
return val !== this;
}

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

destroyer(["tree", "hamburger", 53], "tree", 53);
'''

CamperBot
@camperbot
Nov 12 2016 02:17
:bulb: to format code use backticks! ``` more info
jaredpinargote
@jaredpinargote
Nov 12 2016 02:18
function compare(val){
  return val !== this;
}

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

destroyer(["tree", "hamburger", 53], "tree", 53);
Diego Mayer
@Chrono79
Nov 12 2016 02:25
@jaredpinargote refresh the browser and try again
Aiden
@AidenMead
Nov 12 2016 02:26
So i'm working along in my weather machine, and I can get the temp units to toggle from the default of F to C, but I can't get it to toggle back. Anyone willing to have a look for me?
Jeremy P-K
@Jerediablo
Nov 12 2016 02:26
Everytime I open "Sum All Odd Fibonacci Numbers" or "
Sum All Primes" my browser freezes.. I think I might have made some sort of endless loop in them, but I can't reset the code because it's frozen
any ideas?
@AidenMead How are you trying to get it to switch back and force?
forth*
Aiden
@AidenMead
Nov 12 2016 02:27
@Jerediablo try hopping to the challenge before it and see if it will allow you to start fresh on it
Jeremy P-K
@Jerediablo
Nov 12 2016 02:27
Thanks!
will try those
Diego Mayer
@Chrono79
Nov 12 2016 02:27
@AidenMead paste your codepen link
jaredpinargote
@jaredpinargote
Nov 12 2016 02:28
blob
So I am still getting the same results, even after restarting my browser:
Aiden
@AidenMead
Nov 12 2016 02:28
$(".toggle").click(function (){
    if (tempF){
      $(".temp").replaceWith(tempC);
    } else {
      $(".temp").replaceWith(tempF);
    }
  })
with tempF and tempC stored from my data pull
Moisés Man
@moigithub
Nov 12 2016 02:28
@jaredpinargote did u check whats this value have ?? (console.log helps )
Diego Mayer
@Chrono79
Nov 12 2016 02:28
@AidenMead if tempF is a number, it'll never be false, unless it's 0
Aiden
@AidenMead
Nov 12 2016 02:29
Hhahah, that makes sense
is there a way to code "if this second matches tempF, then switch it tempC, otherwise, switch to tempF"?
if this section*
I would have to define the section as a var, right?
jaredpinargote
@jaredpinargote
Nov 12 2016 02:30
@moigithub Yes, its the item set to be removed. The code produces the right results, the challenge doesnt register it as correct however
Diego Mayer
@Chrono79
Nov 12 2016 02:31
@AidenMead compare $(".temp") content with tempC or tempF
Aiden
@AidenMead
Nov 12 2016 02:33
@Chrono79 I'm not sure how that would look in an if else statement. If I'm not mistaken, I can't just throw the jQuery in there.
Jeremy P-K
@Jerediablo
Nov 12 2016 02:36
@Chrono79 thank you, working now
CamperBot
@camperbot
Nov 12 2016 02:36
jerediablo sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 2502 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Nov 12 2016 02:40

@AidenMead you have some problem on how you encode degree symbols

        tempF = (data.current.temp_f + "ºC");
        tempC = (data.current.temp_c + "ºF");
...
    if ($(".temp").html() == tempF){
      $(".temp").html(tempC);
    } else {
      $(".temp").html(tempF);
    }

Try doing those changes

Justin Vernon
@Jvernz
Nov 12 2016 02:43
So when in the course do we start applying javascript to web pages?
Diego Mayer
@Chrono79
Nov 12 2016 02:43
@Jvernz when you do the projects
Justin Vernon
@Jvernz
Nov 12 2016 02:44
Sounds difficult lol. Is there practice before the projects?
Eclipseparadox
@Eclipseparadox
Nov 12 2016 02:45
@Chrono79 Im looking at the pop and push etc manipulations.
Diego Mayer
@Chrono79
Nov 12 2016 02:46
See what you have to do and chose two of them
Aiden
@AidenMead
Nov 12 2016 02:50
@Chrono79 Hmm, I made the changes but it seems not to be toggling at all?
@Chrono79 just kidding! I was missing the () after the html in the comparison
Diego Mayer
@Chrono79
Nov 12 2016 02:53
@AidenMead if ($(".temp").html() == tempF){ <- parentheses after html
Aiden
@AidenMead
Nov 12 2016 02:53
I stared at it for like ten minutes then saw it, lol
(obvious inflation of time)
Word.
@Chrono79 thank you!
CamperBot
@camperbot
Nov 12 2016 02:53
aidenmead sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 2503 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Nov 12 2016 02:54
no problem
Brian Danowski
@mailtruck
Nov 12 2016 02:59
I <3 character encoding
Moisés Man
@moigithub
Nov 12 2016 03:00
@jaredpinargote i copy/pasted ur code on repl.it .. and its not returning the correct result.. https://repl.it/EVv0
Alexander Zachreson
@alectz
Nov 12 2016 03:05
I'm working on this Caesars Cipher challenge and I'm not sure why my String.fromCharCode won't read the string i'm feeding it. any hints?

function rot13(str) { // LBH QVQ VG!
var x = [];

for( var i = 0 ; i<str.length; i++){
x.push(str.charCodeAt(i)-13);
}
return String.fromCharCode(x.toString());
}

Eclipseparadox
@Eclipseparadox
Nov 12 2016 03:05
@Chrono79 i reviewed, and its .push and .shift
havent figured out how to format the code to do it as yet
Diego Mayer
@Chrono79
Nov 12 2016 03:06
@Eclipseparadox

See how they work and what they return
Eclipseparadox
@Eclipseparadox
Nov 12 2016 03:08
@Chrono79 the .push is to add to the array, and the .shift is to remove from it. But I'm not following what they are asking for here "write a function nextInLine" as they have already written it.
Diego Mayer
@Chrono79
Nov 12 2016 03:08
@Eclipseparadox write your code inside it, below the comment your code here
Juwdohr
@Juwdohr
Nov 12 2016 03:09
Does anyone know why this: if(board[i] !== "E" && board[i] === board[i + 1] && board[i + 1] === board[i + 2]) executes vs if(board[i] !== "E" && board[i] === board[i + 1] === board[i + 2]). I thought these were equivalent statments?
Cole Maly
@malycole
Nov 12 2016 03:09
With Ceasar's cipher, is there a way to utilize unicode so that it will limit itself to latin alphabetical characters or is it just an if/then sort of problem?
Diego Mayer
@Chrono79
Nov 12 2016 03:10
@Juwdohr no more than one === for condition, it's exactly like you can't do if (1 < a < 5)
Alexander Zachreson
@alectz
Nov 12 2016 03:10
@malycole I'm working on that same one right now
Cole Maly
@malycole
Nov 12 2016 03:12
@alectz I could pretty easily make an if then statement that works based on adding or subtracting, but I have to imagine there's a more efficient way
Eclipseparadox
@Eclipseparadox
Nov 12 2016 03:12
@Chrono79 i have the location correct. however I'm looking to arr.push(); and arr.shift(); I'm just not understanding the rest of the code use, nor what to write.
Juwdohr
@Juwdohr
Nov 12 2016 03:12
@Chrono79 OK that is weird thought you could.
Alexander Zachreson
@alectz
Nov 12 2016 03:17
@malycole my problem is i cant get it to read my string of unicode numbers maybe you can see what i did wrong

@malycole function rot13(str) { // LBH QVQ VG!
var x = [];

for( var i = 0 ; i<str.length; i++){
x.push(str.charCodeAt(i)-13);
}
return String.fromCharCode(x.toString());
}

Cole Maly
@malycole
Nov 12 2016 03:20
II think you might need another loop to decode each individual index @alectz
Diego Mayer
@Chrono79
Nov 12 2016 03:21
@alectz an array to string would return a string, not comma separated number values
Either do what @malycole suggested (or build the string in the same loop) or google spread operator
Note that your code is incomplete, think about your chars range and falling out of bounds
Emily
@Emilyrb
Nov 12 2016 03:23
I'm doing Factorialize a Number and my code is extremely different from the solution given but my code still returns the right answer. I don't know why it won't let me continue to the next challenge. Should i just replace my code with the solution and move on?
my code :
function factorialize(num) {
for(var x = 1; x < (num+1); x++){
number = number*x;
}
return number;
}
Moisés Man
@moigithub
Nov 12 2016 03:24
whats the initial value of number ? @Emilyrb
Diego Mayer
@Chrono79
Nov 12 2016 03:24
@Emilyrb number is undefined?
Alexander Zachreson
@alectz
Nov 12 2016 03:24
@Chrono79 yeah i know i'm going to have to deal with that part too, i just needed a way to see what my output would be so i can check it
Emily
@Emilyrb
Nov 12 2016 03:25
oh yea i put
var number = 1;
before the function @moigithub
chunnali
@chunnali
Nov 12 2016 03:25
http://codepen.io/chunnali/pen/yVYOWY why is only one of my text floating to the left?
Diego Mayer
@Chrono79
Nov 12 2016 03:25
@Emilyrb that's a global var and keeps its value between tests, move it inside your function
Joseph
@revisualize
Nov 12 2016 03:25
Hello.
Emily
@Emilyrb
Nov 12 2016 03:26
Oh okay, thanks @Chrono79
CamperBot
@camperbot
Nov 12 2016 03:26
emilyrb sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 2504 | @chrono79 |http://www.freecodecamp.com/chrono79
jaredpinargote
@jaredpinargote
Nov 12 2016 03:26
@moigithub thanks, Ill try to fix it here
CamperBot
@camperbot
Nov 12 2016 03:26
jaredpinargote sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2188 | @moigithub |http://www.freecodecamp.com/moigithub
Cole Maly
@malycole
Nov 12 2016 03:27
@alectz The other problem is that just putting str.charCodeAt(i)-13 doesn't provide the answer that you want. Because it's looking at all unicode codes, not just latin alphabetical codes (it also doesn't account for the spaces)
Dany
@Danylrs
Nov 12 2016 03:30
Hey does anyone understand the lesson " testing Objects for Properties"
Christian
@xChristianZx
Nov 12 2016 03:33
If someone would be as so kind to take a quick look at my code for the "Golf Code" challenge for me and tell me what am i over looking in my conditionals...
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes = 1) {
    return "Hole-in-one!";
  } else if (strokes <= par - 2) {
    return "Eagle";
  } else if (strokes = par - 1) {
    return "Birdie";
  } else if (strokes = par)

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

// Change these values to test
golfScore(5, 4);
Thomas Gerot
@tjgerot
Nov 12 2016 03:33
@cazenaty 1 equal sign
(strokes = 1) should become (strokes == 1)
same with the birdie and changeme conditionals
Christian
@xChristianZx
Nov 12 2016 03:34
excellent, thank you @tjgerot
CamperBot
@camperbot
Nov 12 2016 03:34
cazenaty sends brownie points to @tjgerot :sparkles: :thumbsup: :sparkles:
:cookie: 115 | @tjgerot |http://www.freecodecamp.com/tjgerot
Thomas Gerot
@tjgerot
Nov 12 2016 03:34
Of course!
Christian
@xChristianZx
Nov 12 2016 03:35
i knew it was something simple
just needed a fresh pair of eyes
Cole Maly
@malycole
Nov 12 2016 03:35
Could anyone explain where I can find the unicode numbers that my console.log keeps spitting out? I was under the impression that there were letters in unicode as well but I dont seem to ever get any.
As in where I can find a list of what represents what
Diego Mayer
@Chrono79
Nov 12 2016 03:36
@malycole it doesn't matter, A to Z is 65 to 90, that should be enough
http://www.asciitable.com/
Cole Maly
@malycole
Nov 12 2016 03:37
@Chrono79 ah ok, the 65-90 is what I was looking for
Walid Ashri
@walidashri
Nov 12 2016 03:38
@moigithub this code returns the right result in pythontutor and fcc console?here
Daniel
@DanielMW34
Nov 12 2016 03:44

I'm having some trouble with my Simon game, namely at this point, I cannot get the button sequence to fire in any sensible manner. I have tried several different formats however, I seemingly do not understand the nature of how timing events work and, no matter how many articles I read on stack overflow, have not grasped the concept of how the various undesirable results are coming to be as they are. Here is my code:

EXAMPLE 1:

function playSequence() {
    for (var i=0; i < (cpuSequence.length); i++) {
      $("#test1test").html(cpuSequence.length);
      var test2text = $("#test2test").text();
      $("#test2test").html(test2text + i);
      var y = cpuSequence[i];
      setTimeout(function() {
        if (y == 1) {
          $("#1").css("background-color", "#00fe00");
          document.getElementById("audio1").play();
          setTimeout(function() {
            $("#1").css("background-color", "#004d00"); }, 333);
        };
        if (y == 2) {
          $("#2").css("background-color", "#f60000");
          document.getElementById("audio2").play();
          setTimeout(function() {
            $("#2").css("background-color", "#860000"); }, 333);
        };
        if (y == 3) {
          $("#3").css("background-color", "#eeee00");
          document.getElementById("audio3").play();
          setTimeout(function() {
            $("#3").css("background-color", "#b3b300"); }, 333);
        };
        if (y == 4) {
          $("#4").css("background-color", "#0000ff");
          document.getElementById("audio4").play();
          setTimeout(function() {
            $("#4").css("background-color", "#000066"); }, 333);
        };
      }, 500);
    }
  }

Within the pen I have set cpuSequence to {1,2,3,4,1,2,3,4] and, am calling a previous series of functions to add one more value to this array (1,2,3 or 4) and then this function playSequence is called.

The result of the code above is that the for loop iterates through all the values of the array. I know this because use of ...

(code excerpt from Example 1)

var test2text = $("#test2test").text();
      $("#test2test").html(test2text + i);

the end result is that ("#test2test) displays "012345678", thus the for loop is running over the array like it should however, the Simon game ONLY lights up and makes the sound associated with the final value in the array.

Adjusting the code to the example below gets all the buttons to fire however, they do so in such rapid succession that it occurs as one solid burst of all button/lights and sounds firing at once..

EXAMPLE 2:

function playSequence() {
    for (var i=0; i < (cpuSequence.length); i++) {
      $("#test1test").html(cpuSequence.length);
      var test2text = $("#test2test").text();
      $("#test2test").html(test2text + i);
      var y = cpuSequence[i];
      setTimeout(playStuff(y), 500);
    }
  }

  function playStuff(y) {
        if (y == 1) {
          $("#1").css("background-color", "#00fe00");
          document.getElementById("audio1").play();
          setTimeout(function() {
            $("#1").css("background-color", "#004d00"); }, 333);
        };
        if (y == 2) {
          $("#2").css("background-color", "#f60000");
          document.getElementById("audio2").play();
          setTimeout(function() {
            $("#2").css("background-color", "#860000"); }, 333);
        };
        if (y == 3) {
          $("#3").css("background-color", "#eeee00");
          document.getElementById("audio3").play();
          setTimeout(function() {
            $("#3").css("background-color", "#b3b300"); }, 333);
        };
        if (y == 4) {
          $("#4").css("background-color", "#0000ff");
          document.getElementById("audio4").play();
          setTimeout(function() {
            $("#4").css("background-color", "#000066"); }, 333);
        };
  }

It's clear to me the problem exists is not understanding the setTimeout function. For EXAMPLE 1, the FOR loop should iterate, find the value of the corresponding value of index (i), and play the appropriate light/sound...

any thoughts
?
Walid Ashri
@walidashri
Nov 12 2016 03:45
@DanielMW34 oh it's easier to share the pen link :)
sorry about that
Cole Maly
@malycole
Nov 12 2016 03:49
@alectz did you get yours to work? I solved it using the if elses
Daniel
@DanielMW34
Nov 12 2016 03:49
and @walidashri thank you for taking a look at this
CamperBot
@camperbot
Nov 12 2016 03:49
danielmw34 sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 619 | @walidashri |http://www.freecodecamp.com/walidashri
Daniel
@DanielMW34
Nov 12 2016 04:03
@walidashri just checking in, are you by any chance taking a look at that?
@walidashri I might have to log off soon as the coffee shop i am at is closing within the hour
Walid Ashri
@walidashri
Nov 12 2016 04:05
@DanielMW34 yes I'm trying u need to clear the settimeout
Daniel
@DanielMW34
Nov 12 2016 04:05
@walidashri how would I do that, and why may I ask is that the "problem"?
Joe Mercurio
@RandBetween
Nov 12 2016 04:06
Can anyone help with an API request for Open Weather? Should I be using XMLHttprequest to request JSON data?
Daniel
@DanielMW34
Nov 12 2016 04:07
@RandBetween no, you don't need to do that, you probably need to wrap your JSON inside a function (we call this using JSONP)...
@RandBetween send me a link to your pen
Joe Mercurio
@RandBetween
Nov 12 2016 04:09
Hi @DanielMW34, I didn't start a pen yet, just trying to wrap my head around putting the results of the API request into a variable
var weatherData = loadJSON(baseUrl + mode + apiKey);
Daniel
@DanielMW34
Nov 12 2016 04:13

@RandBetween gotcha, the key to that exercise is you need to name the JSONP function you are calling in the API request. It's a bit finnicky in that some JSON requests you need to name the function you want returned while others do not, as I recall, this is one which needs you to name the function. Here is a link to my pen for that, make not of how I name the function I want returned in my API call and how I get data out of that returned function. I played with this a lot in terms of not naming it and trying to get the data and this was the only viable option. I will paste the link as code so that it does not fill up the entire screen...

http://codepen.io/Daniel_Widrich/pen/VjgRqQ

Best of luck, DM me if you need any further help. I'm calling it a night soon but may be on a little later after a break and certainly tomorrow.

Joe Mercurio
@RandBetween
Nov 12 2016 04:14
Awesome, thanks for the pointer @DanielMW34
CamperBot
@camperbot
Nov 12 2016 04:14
randbetween sends brownie points to @danielmw34 :sparkles: :thumbsup: :sparkles:
:cookie: 355 | @danielmw34 |http://www.freecodecamp.com/danielmw34
Daniel
@DanielMW34
Nov 12 2016 04:15
@RandBetween you're welcome, I have got TONS of help on here, glad I could play it forward to you
Joseph Chu
@ChewyCodes
Nov 12 2016 04:15
ok i'm stuck on Modify Array Data with Indexes
myArray should now be [3,2,3].
You should be using correct index to modify the value in myArray.

// Example
var ourArray = [1,2,3];
ourArray[1] = 3; // ourArray now equals [1,3,3].

// Setup
var myArray = [1,2,3];

// Only change code below this line.
Daniel
@DanielMW34
Nov 12 2016 04:16
@JCDevelop3d Arrays are ZERO based, the first item in an array is array[0]
@JCDevelop3d you are, by using array1, effectively manipulating the SECOND value in the array.
Try playing with array[0] = "Z' vs array1= "Z" vs array2 ="Z"
Joseph Chu
@ChewyCodes
Nov 12 2016 04:17
?
wont work on this challenge.
Daniel
@DanielMW34
Nov 12 2016 04:18
array1 -- array[0] ---array2
Joseph Chu
@ChewyCodes
Nov 12 2016 04:18
so it should be myArray[0]=3
Daniel
@DanielMW34
Nov 12 2016 04:18
yes, for some reason my text is getting changed
Joseph Chu
@ChewyCodes
Nov 12 2016 04:18
lol.
Daniel
@DanielMW34
Nov 12 2016 04:19
myArray[0] --- myArray1---myArray2
hmmm... did it again
myArray1
and again
"myArray[0]"
damn, finally
Joseph Chu
@ChewyCodes
Nov 12 2016 04:19
so it should be myArray[0]=3
Daniel
@DanielMW34
Nov 12 2016 04:19
yes
but play with it and see how indexing works
Joseph Chu
@ChewyCodes
Nov 12 2016 04:20
THanks @DanielMW34
CamperBot
@camperbot
Nov 12 2016 04:20
jcdevelop3d sends brownie points to @danielmw34 :sparkles: :thumbsup: :sparkles:
:cookie: 356 | @danielmw34 |http://www.freecodecamp.com/danielmw34
Daniel
@DanielMW34
Nov 12 2016 04:20
@JCDevelop3d you're welcome
Joseph Chu
@ChewyCodes
Nov 12 2016 04:20
dropped you a line.
Daniel
@DanielMW34
Nov 12 2016 04:21
@walidashri I guess I'm confused as to why the setTimeout needs to be cleared? I know a setInterval() needs to be cleared because it repeats as a loop until cleared, but not a setTimeout...
Bùi Cường
@bphvcg
Nov 12 2016 04:26
hi guys i have a problem with counting cards challenge

here my code :smile: var count = 0;

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

}

if(count <= 0)
{
return "\""+count+" Hold\"";
}
else
return "\""+count+" Bet\"";
// Only change code above this line
}

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

Emilie
@Snipercatz
Nov 12 2016 04:27
@StasVitvitskiy did you ever get help with your question? I'm stuck on the same one. :(
Daniel
@DanielMW34
Nov 12 2016 04:27
@bphvcg please edit your question using the proper markup
use "```" at the beginning and end of your code so it will look like this...
var yourCodeHere = "your code here";
joshandevera
@joshandevera
Nov 12 2016 04:35
i'm stuck at word blanks can some explain what i have to do here
jenniferubah
@jenniferubah
Nov 12 2016 04:36
Hello, I am having a difficulty in the "Concatenating String with plus operator "challenge.
here is my code: var myStr = "This is the start." + "This is the end.";
joshandevera
@joshandevera
Nov 12 2016 04:38
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");
i don't even know what i'm trying to do.
jenniferubah
@jenniferubah
Nov 12 2016 04:39
but it is flagging an error: myStr should have a value of This is the start. This is the end.
any help will be appreciated. thank you
joshandevera
@joshandevera
Nov 12 2016 04:41
@jenniferubah add a space after the period
huangruilong
@badbyeseason
Nov 12 2016 04:56
var count = 0;

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

  // Only change code above this line
}

// Add/remove calls to test your function.
// 提示: Only the last will display
cc('A');
Ken Haduch
@khaduch
Nov 12 2016 05:09
@jenniferubah - make sure you put a space in there between those two things that you are concatenating - that might be the problem.
jenniferubah
@jenniferubah
Nov 12 2016 05:10
@joshandevera it is still not working
chunnali
@chunnali
Nov 12 2016 05:13
http://codepen.io/chunnali/pen/yVYOWY so my wind and humidity text randomly disppeared and I cant figure out why…=_=
jenniferubah
@jenniferubah
Nov 12 2016 05:13
@khaduch just tried that, still not working
Ken Haduch
@khaduch
Nov 12 2016 05:14
@jenniferubah - make sure you have a space at the end of "This is the start. " a space after the period. That should do it if you have all of the other things correct in the spelling of the strings.
@jenniferubah - can you post your code using the markdown format?
'''
CamperBot
@camperbot
Nov 12 2016 05:15
:bulb: to format code use backticks! ``` more info
Joe Mercurio
@RandBetween
Nov 12 2016 05:15
Did anyone else have trouble connecting to the open weather API and receiving a connection refused error, perhaps related to the use of http vs https?
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:16
Hello guys, I'm doing my Weather respond service on codepen.io and when i request json from api it gives me this:
http://s.codepen.io/boomerang/39051d421f15875fd4e7df374bcb0f021478931027119/api.openweathermap.org/data/2.5/weather?lat=35&lon=139&APPID=5e03b2d2bf0692b26779dd53f3251cdd Failed to load resource: the server responded with a status of 404 (Not Found)
But main problem is that it remake why raw api request to their own:
http://s.codepen.io/boomerang/39051d421f15875fd4e7df374bcb0f021478931027119/api.openweathermap.org/data/2.5/weather?lat=35&lon=139&APPID=5e03b2d2bf0692b26779dd53f3251cdd
Why codepen remake my API request to their own?
@RandBetween Hi
Joe Mercurio
@RandBetween
Nov 12 2016 05:18
I think I'm having the same problem as you @Zooll8. Perhaps this is relevant? FreeCodeCamp/FreeCodeCamp#7853
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:18
@RandBetween May be
Ken Haduch
@khaduch
Nov 12 2016 05:18
@Zooll8 - this kind of looks like you don't have an "http://" in front of your URL for the openweathermap site? It is trying to load it as a CodePen resource and that won't work. Make sure to have http://api.openweathermap.org/... etc.
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:18
@RandBetween can you show your console error problem?
@khaduch ok, thanks I'll try it
CamperBot
@camperbot
Nov 12 2016 05:19
zooll8 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1918 | @khaduch |http://www.freecodecamp.com/khaduch
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:20
@khaduch That solved my problem, thank you sir
CamperBot
@camperbot
Nov 12 2016 05:20
zooll8 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: zooll8 already gave khaduch points
Ken Haduch
@khaduch
Nov 12 2016 05:20
@RandBetween - you cannot connect to openweathermap on the free account using https:// - only `http://
why all the conditions not working here?
Joe Mercurio
@RandBetween
Nov 12 2016 05:22
@khaduck, when I use http: I receive this error message: jquery.min.js:4 Mixed Content: The page at 'https://codepen.io/sixfinger/full/kkdoZx/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.openweathermap.org/data/2.5/weather?q=Montreal&mode=html&appid=6590e1c04ed58f7a8ad71fd1153806b4'. This request has been blocked; the content must be served over HTTPS.
Ken Haduch
@khaduch
Nov 12 2016 05:22
@AKASH888 - this if(2,3,4,5,6){ return "5 Bet"; } is not valid - you cannot write an if statement if (2, 3, 4, 5, 6)
Joe Mercurio
@RandBetween
Nov 12 2016 05:22
Should my codepen site not be using https?
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:23
@AKASH888 In this question, aren't supposed to make "total" variable add switch to all cards and then make some ifs at the end?
Ken Haduch
@khaduch
Nov 12 2016 05:23

@AKASH888 - you could write:

if( card === 2 || card == 3 || card === 4 || card === 5 || card === 6){
    return "5 Bet";
  }

etc.

Although the " 5 Bet" would not necessarily be correct. Each of those tests of the cards is supposed to add or subtract one from the count and then the code later will determine the action of "Bet" or "hold" along with the count.

@RandBetween - you run into a problem with Chrome needing https:// to get geolocation, and openweather not using https:// - so that's a problem. If you a mix of the two, then you also run into a problem with loading part of the page on a secure connection and part of it on an insecure connection. You can use an IP -based service like http://ip-api.org, although it's not necessarily as accurate, but it kind of gets the job done. Or u se some of the information in that past that you linked to to move away from openweather and use another site?
khaduch @khaduch - checking out for the night... happy coding everyone
Joe Mercurio
@RandBetween
Nov 12 2016 05:28
Good to know, thanks @khaduch
CamperBot
@camperbot
Nov 12 2016 05:28
randbetween sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1919 | @khaduch |http://www.freecodecamp.com/khaduch
Ed
@edyiot
Nov 12 2016 05:30
how do I convert from celsius to fahrenheit ? How can I add more lines to one test if already defined fahrenheit ?
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:30
@edyiot depending on api it gives you f,c or k
You determine this BEFORE all of your code
and then just add formula to where you include your json part
Ed
@edyiot
Nov 12 2016 05:31

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

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

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

Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:31
ohhh
sry
I thought that you was building Local WEather Machine
Ill hlep you in few seconds
Ed
@edyiot
Nov 12 2016 05:32
@Zooll8 I wish, thanks
CamperBot
@camperbot
Nov 12 2016 05:32
edyiot sends brownie points to @zooll8 :sparkles: :thumbsup: :sparkles:
:cookie: 291 | @zooll8 |http://www.freecodecamp.com/zooll8
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:32
@edyiot
nothing is working guys if statements with or conditions too did'nt work
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:33
@edyiot
fahrenheit=(celsius*9/5)+32;
this will help i think
AKASH GUNJAL
@AKASH888
Nov 12 2016 05:33
and now cases too giving errors
Ed
@edyiot
Nov 12 2016 05:34
@Zooll8 ooooooooh, I thought I had to give them specific temperatures. Thank you!
CamperBot
@camperbot
Nov 12 2016 05:34
edyiot sends brownie points to @zooll8 :sparkles: :thumbsup: :sparkles:
:warning: edyiot already gave zooll8 points
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:35
@edyiot you are welcome!

@AKASH888
Hi this is what you think :
switch (varName)
{
case "afshin", "saeed", "larry":
alert('Hey');
break;

default:
alert('Default case');
break;
}

But actually this is how multiple cases are made in js:
switch (varName)
{
case "afshin":
case "saeed":
case "larry":
alert('Hey');
break;

default:
alert('Default case');
}

AKASH GUNJAL
@AKASH888
Nov 12 2016 05:39
ok let me give it a try
It doesn't work and still break statement gives errors :worried:
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:44
@AKASH888 you actually don't need to "return" anything in your switch, you need to manipulate with "count" variable in every case, and you need to make if statement at end to check 'count' value
Aldair
@ald1413
Nov 12 2016 05:46

Hello everyone, I am doing the Caesar Cipher exercise and i have trouble getting a result


function rot13(str) { // LBH QVQ VG!
  var result = [];
  for (var i = 0; i < str.length; i++) {
if (str[i].charCodeAt() >= 65 || str[i].charCodeAt() <= 90) {
  return result.push(String.fromCharCode(str[i].charCodeAt - 13));
}
  }
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

I think i got most of it right but i dont know why the result is still not a function

Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:46
@Zooll8 and only at the end return a string something like this: return count+"A new string which is equal to 'Hold' or 'Bet' depending on 'count ' value"
Walid Ashri
@walidashri
Nov 12 2016 05:52
@ald1413 MOVE THE RETURN OUTSIDE THE FOR LOOP
@ald1413 Sorry for caps
still not working @Zooll8
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:56
@AKASH888 hi, give me few seconds Ill help you
Aldair
@ald1413
Nov 12 2016 05:56

function rot13(str) { // LBH QVQ VG!
  var result = [];
  for (var i = 0; i < str.length; i++) {
if (str[i].charCodeAt() >= 65 || str[i].charCodeAt() <= 90) {
} 
} return result.push(String.fromCharCode(str.charCodeAt() - 13));
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Still nothing I have a number at least
yourpalsneakers
@yourpalsneakers
Nov 12 2016 05:56
I'm struggling with Factorialize a Number... I have a for loop to iterate backwards from num to 1. can't figure out how to multiply each number by the next.. anyone have a hint???
joshandevera
@joshandevera
Nov 12 2016 05:57
i'm stuck at the World Blanks challenge challenge can someone help me?
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 05:58

@AKASH888 var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count=count+1;
break;

case 7:
case 8:
case 9:
  count=count+0;
   break;

case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
  count=count-1;
  break;
  }

if(count>1){
return count+" Bet";
}

else {
return count +" Hold";
}
// Only change code above this line
}

CamperBot
@camperbot
Nov 12 2016 05:58
:bulb: to format code use backticks! ``` more info
Ken Nawrocki
@nawrockp
Nov 12 2016 05:58
@AKASH888 should you have quotes around the A?
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 06:00
@AKASH888
so with all cases you dont set count equal to something, you set count=previouscount+1 or +0 or -1 depending on case
Walid Ashri
@walidashri
Nov 12 2016 06:01
@yourpalsneakers use temp var =1 then temp* num-1
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 06:01
@AKASH888 but basically it looks lie this:
```
count=count+1 or +0 or -1
yourpalsneakers
@yourpalsneakers
Nov 12 2016 06:02
@walidashri what is temp?
Walid Ashri
@walidashri
Nov 12 2016 06:03
@yourpalsneakers temporary variable :)
lixchen
@lixchen
Nov 12 2016 06:04
if(3 < x  <  9){
.....
}
if(3 < x && x < 9){
.....
}
// the first is wrong?
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 06:04
@lxccl yes first is wrong
you can only do this: by &&
lixchen
@lixchen
Nov 12 2016 06:05
JavaScript is not supposed?
@Zooll8 thanks
CamperBot
@camperbot
Nov 12 2016 06:05
lxccl sends brownie points to @zooll8 :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @zooll8 |http://www.freecodecamp.com/zooll8
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 06:06
@AKASH888 Have you solved your problem?
AKASH GUNJAL
@AKASH888
Nov 12 2016 06:06
still not working sadly
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 06:07
@AKASH888 can you link your current code, I'll try to ascertain how to help you

function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count=count+1;
break;

case 7:
case 8:
case 9:
  count=count+0;
   break;

case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
  count=count-1;
  break;
  }

if(count>1){
return count+"Bet";
}

else if(count===0){
return count+ "Hold";
}
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(10); cc('J'); cc('Q'); cc('K'); cc('A');

Aldair
@ald1413
Nov 12 2016 06:11

Okay I managed to get the first word but now i cant get the whole sentence


function rot13(str) { // LBH QVQ VG!
  var result = [];
  for (var i = 0; i < str.length; i++) {
if (str[i].charCodeAt() >= 65 || str[i].charCodeAt() <= 90) {
var word = str[i].charCodeAt() - 13;
  return String.fromCharCode(word);
} 
} 
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

Is there something wrong with my return statement?

Walid Ashri
@walidashri
Nov 12 2016 06:11
@AKASH888
if(count>0){
        return count+" Bet";
  }

   else if(count<=0){
     return count+ " Hold";
   }
maximilianomonzon
@maximilianomonzon
Nov 12 2016 06:11

@maximilianomonzon
Hi, sorry i need help urgently
The problem I have is that I can not access the "onclick" property of the buttons and it does not redirect me to the function that I specify
input(type="submit", name="accion", onclick='jugadas()', value='Quiero')
script.
function jugadas (){
alert('Hi world');
}
But, never execute the alert
I removed the sentences that are obvious

I am doing something wrong in the javascript syntax?

Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 06:13
@AKASH888 You're on the way to finish! Only thing you need to fix is to change
else if(count===0){
return count+ "Hold";
}
to
else {
return count+" Hold";
}
because you have only 2 possible answers and you don't need to make second "if" statement you make it like: "if" and "everything else if "if" hadn't worked"
Walid Ashri
@walidashri
Nov 12 2016 06:13
@ald1413 return inside the loop will break the loop
maximilianomonzon
@maximilianomonzon
Nov 12 2016 06:13
Anyone?
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 06:14
@maximilianomonzon sry, I already need to go to sleep, 1am, I need to help that guy with @AKASH888 and then I go sleep
maximilianomonzon
@maximilianomonzon
Nov 12 2016 06:15
Oh
Conor Murphy
@cmurphy580
Nov 12 2016 06:15
can anyone help with this button? I want to position next to the search bar, but its not happening. I tried display: inline-block, and when i tried just using margins to position next to bar, something prevents it from the touching the side. let me know if you have any ideas.
https://codepen.io/cmurphy580/pen/gLaamJ
maximilianomonzon
@maximilianomonzon
Nov 12 2016 06:15
Ok, thanks
Aldair
@ald1413
Nov 12 2016 06:15
@walidashri but if i return it outside the loop it gives me a number
Ken Nawrocki
@nawrockp
Nov 12 2016 06:16
@maximilianomonzon do you have a link?
And is this plain js?
Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 06:16
@maximilianomonzon @cmurphy580 Guys you can go and ask help in FreeCodeCamp Main chat, they are quite good in helping everybody! ^_^

@AKASH888
This one if final i tested this:
if(count>=1){
return count+" Bet";
}

else {
return count+ " Hold";
}

maximilianomonzon
@maximilianomonzon
Nov 12 2016 06:19
@nawrockp
The problem seems to be relatively easy, I have to do is to link the button with a function so that something is executed and I do not execute it. Everything is inside a view
Walid Ashri
@walidashri
Nov 12 2016 06:19

@ald1413

var word = str[i].charCodeAt() - 13;
  result.push(String.fromCharCode(word));
} 
}
return result

like this but ur logic nedd adjustment

Zaurbek Zhakupov
@zzhakupov
Nov 12 2016 06:20
@AKASH888 have you solved it now?
Ken Nawrocki
@nawrockp
Nov 12 2016 06:20
@maximilianomonzon ok but you are generating an input tag with js?
Conor Murphy
@cmurphy580
Nov 12 2016 06:20
@Zooll8 sorry
Ken Nawrocki
@nawrockp
Nov 12 2016 06:21
If it generates ok then you might need to use prevent default
maximilianomonzon
@maximilianomonzon
Nov 12 2016 06:23
@nawrockp Yes.
The button is inside a form that is then executed in the POST. When the button is clicked I should not only have to address it but also execute a function (it is to be able to use socket.io, but that is part of another problem)
Justin Vernon
@Jvernz
Nov 12 2016 06:24
Good evening friends
maximilianomonzon
@maximilianomonzon
Nov 12 2016 06:25
How is it that generates an ok?
Ken Nawrocki
@nawrockp
Nov 12 2016 06:26
Try changing it to a normal button
maximilianomonzon
@maximilianomonzon
Nov 12 2016 06:26
I've already tried! But it does not work
Canan Gursoy
@CananGursoy
Nov 12 2016 06:27
Why this palindrome("1 eye for of 1 eye.") should return false? It seems like this is a bug. Has anyone else run into this issue?
Ken Nawrocki
@nawrockp
Nov 12 2016 06:27
I cant see how it gets generated so i cant tell. But perhaps
maximilianomonzon
@maximilianomonzon
Nov 12 2016 06:29
@nawrockp
Could you connect by the team viewer with me so you see?
Walid Ashri
@walidashri
Nov 12 2016 06:29

@cmurphy580 hard coding btn style

position:relative;
  left:-5px;

u can search for more elegant ways

Ken Nawrocki
@nawrockp
Nov 12 2016 06:30
Onclick="alert('blah')"
maximilianomonzon
@maximilianomonzon
Nov 12 2016 06:30
Yes
Ken Nawrocki
@nawrockp
Nov 12 2016 06:31
That works?
Markus Kiili
@Masd925
Nov 12 2016 06:31
@CananGursoy Because you should not remove numbers.
maximilianomonzon
@maximilianomonzon
Nov 12 2016 06:31
There i prove it
Justin Vernon
@Jvernz
Nov 12 2016 06:32
Man, when I knock out algorithm challenges in 5-10 minutes I feel like a genius
Treylerp
@Treylerp
Nov 12 2016 06:33
I need help wtih the worldblank challenge
maximilianomonzon
@maximilianomonzon
Nov 12 2016 06:33
Yes, if the alert works
Canan Gursoy
@CananGursoy
Nov 12 2016 06:33
Thanks Markus!
maximilianomonzon
@maximilianomonzon
Nov 12 2016 06:34
@nawrockp Yes, if the alert works
So if it works
@nawrockp
That makes me think that I never run or attempt to execute my function
Emmanuel
@chriemma
Nov 12 2016 06:35

please need help can someone put me through here 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");
var myNoun = "dog";
var myAdjective = "big";
var resulOne = "myAdjective + myNoun";

var resultTwo = myAdjective + ' ' + myNoun;

Philipp Scholz
@philipp32
Nov 12 2016 06:37
Hey, I am checking for palindromes but my code doesn't really work. What do I need to change?
function palindrome(str) {  
  str.prototype.toLowerCase();
  str.split(" ").reverse().join(" ");
  str.text.replace(/\W+/g, " ");
  var reversed = str;
  if (str === reversed) {
    return true;
  } else {
    return false;
  }
}

palindrome("eye");
Markus Kiili
@Masd925
Nov 12 2016 06:39
@philipp32 It should be like str = str.toLowerCase();
All strings inherit string methods from String.prototype but you use them on the string.
Remember that strings are immutable. You always make a new string and store it somewhere.
Ryan McMahon
@Radio-Mac
Nov 12 2016 06:41
Greetings there. I'm just wondering if there is a better method of doing the reverse-a-string.
function reverseString(str) {
  return str.split('').reverse().join('');
}

reverseString("hello");
Philipp Scholz
@philipp32
Nov 12 2016 06:42
@Radio-Mac you need to insert a space between the two thingies in the brackets there. And no, there isn't. :/
Markus Kiili
@Masd925
Nov 12 2016 06:42
@Radio-Mac That is a good and elegant way. You could also use a loop, recursion, or some iterator like .reduce().
Joseph
@revisualize
Nov 12 2016 06:43
@Radio-Mac That's pretty good.
@philipp32 If you do a split(' ') you're no longer reversing a string. You're reversing a sentence.
Philipp Scholz
@philipp32
Nov 12 2016 06:45
function palindrome(str) {  
  str=str.toLowerCase();
  str = str.split('').reverse().join('');
  var reversed = str.replace(/\W+/g, " ");
  if (str === reversed) {
    return true;
  } else {
    return false;
  }
}

palindrome("eye");
It still doesn't work. It shows this "_eye" as a palindrom but doesn't show flase for "nope".
Markus Kiili
@Masd925
Nov 12 2016 06:45
@philipp32 You are not removing underscore _
Justin Vernon
@Jvernz
Nov 12 2016 06:45
Arrays kill me
Philipp Scholz
@philipp32
Nov 12 2016 06:46
@Masd925 how would you write that?
Joseph
@revisualize
Nov 12 2016 06:46

@philipp32 Example:

var str = "Happy Feet really loves to shake his tail feather and dance!";
console.log(str.split(' ').reverse().join(' '));
console.log("vs");
console.log(str.split('').reverse().join(''));

dance! and feather tail his shake to loves really Feet Happy
vs
!ecnad dna rehtaef liat sih ekahs ot sevol yllaer teeF yppaH

Markus Kiili
@Masd925
Nov 12 2016 06:46
@philipp32 Replace and lowercase first. Then compare original with the reversed. You can use [ ] and _ with the \W
Philipp Scholz
@philipp32
Nov 12 2016 06:48
this works now.

function palindrome(str) {  
  str=str.toLowerCase();
  str = str.replace(/[^0-9a-z]/gi, '');
  var reversed = str.split('').reverse().join('');
  if (str === reversed) {
    return true;
  } else if (str != reversed) {
    return false;
  }
}


palindrome("eye");
Why do I need to do the toLowerCase and the replace before the reversing of the string?
Markus Kiili
@Masd925
Nov 12 2016 06:49
@philipp32 The if is redundant. Just return str===reversed;.
Philipp Scholz
@philipp32
Nov 12 2016 06:49
@Masd925 everything works now :)
Why do I need to do the toLowerCase and the replace before the reversing of the string?
Markus Kiili
@Masd925
Nov 12 2016 06:50
@philipp32 Because that was the description of the problem.
@philipp32 The last if's are redundant. Learn to spot those. Just return str===reversed; instead of testing.
Philipp Scholz
@philipp32
Nov 12 2016 06:55
@Masd925 thank you. That worked even better. :)
CamperBot
@camperbot
Nov 12 2016 06:55
philipp32 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2885 | @masd925 |http://www.freecodecamp.com/masd925
Justin Vernon
@Jvernz
Nov 12 2016 06:59
For the Chunky Monkey challenge, do you guys use a loop?
Markus Kiili
@Masd925
Nov 12 2016 07:00
@Jvernz Most people do. You can also use an iterator method or recursion.
Loop is the most elegant way though.
Terryd12345
@Terryd12345
Nov 12 2016 07:00
hey guys how can i define a variable as the first index of an array and also remove that first index using javascript? I've tried to use .shift() and also just defining the first index returning that and then using shift().
Justin Vernon
@Jvernz
Nov 12 2016 07:00
@Masd925 Thanks, time to figure out what my loop should be!
CamperBot
@camperbot
Nov 12 2016 07:00
jvernz sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2886 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Nov 12 2016 07:01
@Terryd12345 Check out what is the return value of method .shift()
Ken Nawrocki
@nawrockp
Nov 12 2016 07:02
@maximilianomonzon still there?
@maximilianomonzon it seems the ode to generate the html is different than the code that is inserted. I imagine that if you look at the js console you will see an error
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:06
@nawrockp This is a BIG PROBLEM haha. Does not show me error
Ken Nawrocki
@nawrockp
Nov 12 2016 07:06
Try a semicolon before script
What build tool is this?
Or framework/ library?
You tried changing it to button,right?
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:10
@nawrockp
Yes, I did it type button and I did not work either
Ken Nawrocki
@nawrockp
Nov 12 2016 07:10
Can u paste code again?
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:10
Yeah
Ken Nawrocki
@nawrockp
Nov 12 2016 07:10
On phone,hard to scroll
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:11
hahaha, wait 1 second
one*
Terryd12345
@Terryd12345
Nov 12 2016 07:12
@Masd925 It returns the first index, yes? I am trying to assign that to a new variable but am not sure why it is not working. Also is it not possible to return the function using another inbuilt function?
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:13
input(type="button", name="accion", value='Submit', onclick="jugada()")
script.
function jugadas (){
alert('BAHH');
}
Markus Kiili
@Masd925
Nov 12 2016 07:13
@Terryd12345 You can remove and return the first array element by return arr.shift();
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:13
input(type="submit", name="accion", value='Envido', onclick="jugada()")*
Ken Nawrocki
@nawrockp
Nov 12 2016 07:13
Try a semicolon after the input line
And in rhe console did u try jugada()?
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:14
@nawrockp
Works without errors
Ken Nawrocki
@nawrockp
Nov 12 2016 07:14
Y hablo español si es mas facil
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:15
Sii ?
jajajajajaj
Gracias a diooos !
Ken Nawrocki
@nawrockp
Nov 12 2016 07:15
Monzon como el boxeador?
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:15
jajaja
Si el mismo jajaja
Annu Nirmal
@annunirmal
Nov 12 2016 07:15
can anyone help me align left sidebar-nav and its icons
http://codepen.io/nirmalannu/pen/oYbpmv?editors=1100
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:15
Renegando con el google traductor una hora y media estuve jajaja
Intenté poner un punto y coma y funciona de todas maneras
Diane
@106Ch213
Nov 12 2016 07:16
Hi guys, I've been stuck on the Testing Objects for Properties exercise for a little while. I tried 2 different methods: one with if condition as follow. The function does return the correct value if the object property exists but I don't understand why it doesn't return "Not Found" in other cases.
  if (myObj.hasOwnProperty("gift") || myObj.hasOwnProperty("pet") || myObj.hasOwnProperty("bed")){
    return myObj[checkProp];
  } else {
    return "Not Found";
  }
Ken Nawrocki
@nawrockp
Nov 12 2016 07:16
Prueba onClick()
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:16
Dentro del codigo de js?
Ken Nawrocki
@nawrockp
Nov 12 2016 07:17
Ni idea. No se como se genera el codigo
Markus Kiili
@Masd925
Nov 12 2016 07:17
@106Ch213 Don't hardcode the property keys. Test the object for the key stored in the function parameter checkProp.
Ken Nawrocki
@nawrockp
Nov 12 2016 07:17
Puedes copiar y pegar el html generado?
Para mi esta mal
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:18
Sisi aver ahi te lo paso entero pero es mucho igual
joshandevera
@joshandevera
Nov 12 2016 07:18
what is wrong with my code ```
Ken Nawrocki
@nawrockp
Nov 12 2016 07:18
Solo el input tag
joshandevera
@joshandevera
Nov 12 2016 07:18
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  result = "the " + "big " + "dog" + " and "+ "little" + " cat"+ " ran" + " quickly" + " slowly";
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
wordBlanks("cat", "little", "hit", "slowly");
Diane
@106Ch213
Nov 12 2016 07:18
@Masd925 Ohh ok I think I see, gonna try right away thanks!
CamperBot
@camperbot
Nov 12 2016 07:18
106ch213 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2887 | @masd925 |http://www.freecodecamp.com/masd925
irojabkhan
@irojabkhan
Nov 12 2016 07:18
How to right var a and var b is equal?
joshandevera
@joshandevera
Nov 12 2016 07:19
been stuck in the challenge for hours now
Terryd12345
@Terryd12345
Nov 12 2016 07:19
@Masd925 Finally got it, was trying to use .push in a variable lol. Thanks mate.
CamperBot
@camperbot
Nov 12 2016 07:19
terryd12345 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2888 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Nov 12 2016 07:19
@joshandevera Those function parameters myNoun etc hold the passed words. Use the parameters to make the long sentence.
Ken Nawrocki
@nawrockp
Nov 12 2016 07:20
@joshandevera seems it will always return the same
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:20

extends layout

block content
form(role='form', action="/play",method="post")
.form-group
input(type="button", name="accion", value='Submit', onclick="jugada('some')")
 
script.
function jugadas (){
alert('Hola estoy aca');
}

Esta todo bien intendado
Respetando los espacios y demas
Ken Nawrocki
@nawrockp
Nov 12 2016 07:20
Ok pero el html
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:20
Ahh es que eso usamos como html
Es una herramienta
Jade
Ken Nawrocki
@nawrockp
Nov 12 2016 07:21
Ok no hay html al final?
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:22
No, no lo hay
Ken Nawrocki
@nawrockp
Nov 12 2016 07:22
Como <input type='submit'....
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:23
Claro eso es lo mismo en jade: input(type="submit"...
Ken Nawrocki
@nawrockp
Nov 12 2016 07:23
Y como lo pruebes?
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:23
Con npm
Ken Nawrocki
@nawrockp
Nov 12 2016 07:23
En un browser?
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:23
Sisi
En el browser
Ken Nawrocki
@nawrockp
Nov 12 2016 07:24
Asi hay html
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:24
Que perdido estoy dios
jajajja
Ken Nawrocki
@nawrockp
Nov 12 2016 07:24
Right click,inspect element
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:24
Entonces si existe
Ok
Tenes razon
Jade es una herramienta que traduce a HTML
joshandevera
@joshandevera
Nov 12 2016 07:24
@Masd925 and @nawrockp thanks didn't know it was that simple.
CamperBot
@camperbot
Nov 12 2016 07:24
joshandevera sends brownie points to @masd925 and @nawrockp :sparkles: :thumbsup: :sparkles:
:cookie: 359 | @nawrockp |http://www.freecodecamp.com/nawrockp
:star2: 2889 | @masd925 |http://www.freecodecamp.com/masd925
Ken Nawrocki
@nawrockp
Nov 12 2016 07:25
Con chrome facil - copy outer html
Pegar aqui
Nikhil Singh
@nikhilmufc7
Nov 12 2016 07:26
can someone help me with the challenge Stand in Line
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:27
<input name="accion" value="Truco" type="submit">
Markus Kiili
@Masd925
Nov 12 2016 07:27
@nikhilmufc7 Sure.
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:27
<input name="accion" value="Submit" onclick="alert('blah')" type="button">
Sorry
Ese es el final:
<input name="accion" value="Submit" onclick="jugada('some')" type="button">
Me equiovque en las anteriores, no refresque la pagina
Nikhil Singh
@nikhilmufc7
Nov 12 2016 07:28
function nextInLine(arr, item) {
  // Your code here
 array = [];
  array.shift(arr);
  array.push(item);
  return arr;  // 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));
here is my source code
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:31
@nawrockp Ese ultimo que te pase es el codigo que me dio en el boton
Markus Kiili
@Masd925
Nov 12 2016 07:31
@nikhilmufc7 Use arr and item that hold the passed array and number.
maximilianomonzon
@maximilianomonzon
Nov 12 2016 07:44
@nawrockp Estas?
Joseph
@revisualize
Nov 12 2016 07:46
@nikhilmufc7 You're doing thins out of order. You're removing the first element from the array before adding the item to the array. But, you're not using the parameters correctly ... So.. yeah.

Parameters are 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.

Markus Kiili
@Masd925
Nov 12 2016 07:51
@revisualize Very nice explanation. This is wrong though Parameters are values that get passed into your function from the function call.
Joseph
@revisualize
Nov 12 2016 07:56
@Masd925 What should it be?
Jeff Shapiro
@Jeff-Shapiro
Nov 12 2016 07:57
@Masd925 Parameters are values that get passed into your function from the function call. is a pure fact!
Micah Lewis
@EastML
Nov 12 2016 08:00
I'm doing the intermediate js algorithms, and I was just wondering, is using the spread operator a best practice?
Markus Kiili
@Masd925
Nov 12 2016 08:00
@Jeff-Shapiro Arguments are values. Parameters are part of function declaration and become variables on the execution context where they hold the arguments.
So parameters are not values.
Tony Miri
@TonyMiri
Nov 12 2016 08:05
Any insight as to why this isn't working?
function removeDupes(x) { //x is an array

  return x.filter(function(v, index, array) { 

    return array.indexOf(v) == index;

  });
}


function sym(args) {

  var newArray = Array.from(arguments);

  console.log(newArray);

  newArray = newArray.forEach(removeDupes); //newArray is an array of arrays. I'm trying to loop over it, and for each array I'd like to use the removeDupes function.

  console.log(newArray);

}



sym([1, 2, 3], [5, 2, 1, 4]);
Markus Kiili
@Masd925
Nov 12 2016 08:06
@FatTone225 ForEach always returns undefined.
Tony Miri
@TonyMiri
Nov 12 2016 08:06
Always?
Markus Kiili
@Masd925
Nov 12 2016 08:06
It is only meant to make side effects.
Tony Miri
@TonyMiri
Nov 12 2016 08:07
Hmm
Can you think of an example?
Conor Murphy
@cmurphy580
Nov 12 2016 08:08
@walidashri Thank you, Walid!!
CamperBot
@camperbot
Nov 12 2016 08:08
cmurphy580 sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 620 | @walidashri |http://www.freecodecamp.com/walidashri
Markus Kiili
@Masd925
Nov 12 2016 08:08
var arr = ["cat","pants"];

var result = "";

arr.forEach(function(elem){
    result += elem;    
});

console.log(result);  // "catpants"
Reduce method could do the same without the result variable.
Usually there is some better method for any job than forEach.
@FatTone225
Same with reduce:
var arr = ["cat","pants"];

arr.reduce(function(acc,curr){
    return acc+curr;    
});                  // returns "catpants"
Tony Miri
@TonyMiri
Nov 12 2016 08:13
@Masd925 I think I see what you mean. In this instance I am merely trying to loop over that multidimensional array and run the removeDupes function on each array contained within it. Do you think a simple for loop would be best? I don't want to combine the arrays just yet. I will end up using reduce later, but not yet.
Markus Kiili
@Masd925
Nov 12 2016 08:13
@FatTone225 If you need to change each element of an array, use .map(). It returns a new array.
Tony Miri
@TonyMiri
Nov 12 2016 08:14
I don't need to change all of them. My removeDupes function returns an array.
Markus Kiili
@Masd925
Nov 12 2016 08:15
@FatTone225 Are you removing duplicate elements from each array element (which are arrays)?
Tony Miri
@TonyMiri
Nov 12 2016 08:16
Yes. I need to access each inner array individually and remove the duplicate values from each of the inner arrays.
Markus Kiili
@Masd925
Nov 12 2016 08:16
@FatTone225 Then just use map instead of forEach.
Tony Miri
@TonyMiri
Nov 12 2016 08:17
@Masd925 Ok! I will check it out. Thank you.
CamperBot
@camperbot
Nov 12 2016 08:17
fattone225 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2890 | @masd925 |http://www.freecodecamp.com/masd925
Ryan McMahon
@Radio-Mac
Nov 12 2016 08:17
Hey, I'm working on the factorize challenge. I have a feeling if I look up some help I'm just going to get an answer so I was wondering if someone could point me in the right direction.
Markus Kiili
@Masd925
Nov 12 2016 08:17
@Radio-Mac You can just post the question and the relevant code here.
Ryan McMahon
@Radio-Mac
Nov 12 2016 08:17
I know about using and if for num but I'm not sure if I should do a for loop for the actual factorizing.

function factorialize(num) {
  var temp = 0;
  if (num === 0)
    {
      return 1;
    }
  else
  for (var i = 0; i < num; i++)
    {

    }
  return num;
}

factorialize(5);
Markus Kiili
@Masd925
Nov 12 2016 08:18
@Radio-Mac For loop is fine.
Initialize the result variable to 1 and loop from 2 to num.
Tony Miri
@TonyMiri
Nov 12 2016 08:19
@Masd925 It worked. :smile: Thanks again.
CamperBot
@camperbot
Nov 12 2016 08:19
fattone225 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: fattone225 already gave masd925 points
bahaa aldin
@bahaa-al-deen
Nov 12 2016 08:32

function translatePigLatin(str) {
  var one = str.split("");
  var vowels = ["a","u","o","i","y","e"];
  var two;
  var three;
  /*
  for (i=0; i<vowels.length; i++) {
    if (one[0].indexOf(vowels[i]) != -1) {
      one.push("way");
      two = one.join("");
      return two;
    }
  }
  */
  for (i=0; i<one.length; i++) {
    for (j=0; j<vowels.length; j++) {
      if (one[i].indexOf(vowels[j]) != -1) {
        two = i;
        break;


      }
    }
  }



  return two;
}

translatePigLatin("paragraphs");
this loop is not functioning properly
when i return i; it says i=1
but when i say two = i and then return i; outside the loop it says two = 6
how is this even possible ?
the purpose of the code is to make pig latin function
Jeff Shapiro
@Jeff-Shapiro
Nov 12 2016 08:38
@BahaaZidan you should have var i = ........ and same for j
bahaa aldin
@bahaa-al-deen
Nov 12 2016 08:42
nth happened
the same problem
any one any ideas ??
Ogundele Olumide
@Lumexralph
Nov 12 2016 08:44
@BahaaZidan you're returning two which is the index from your loop
bahaa aldin
@bahaa-al-deen
Nov 12 2016 08:44
i know
Ogundele Olumide
@Lumexralph
Nov 12 2016 08:45
@BahaaZidan what are you trying to get?
Jeff Shapiro
@Jeff-Shapiro
Nov 12 2016 08:45
@BahaaZidan I get 6 from that
bahaa aldin
@bahaa-al-deen
Nov 12 2016 08:46
im trying to use i as startIndex for a substr i will use
my problem now is the the loop doesn't stop when it's intended
Ogundele Olumide
@Lumexralph
Nov 12 2016 08:49
@BahaaZidan break leaves the inner loop but not the outer loop
bahaa aldin
@bahaa-al-deen
Nov 12 2016 08:49
that's right m8
@Lumexralph but the problem with that
is if the first letter in one
is not a vowel
the function will stop their
and it will not chek further
and that is not intended
Ogundele Olumide
@Lumexralph
Nov 12 2016 08:52
@BahaaZidan that's if it's done with the loop? rigth?
bahaa aldin
@bahaa-al-deen
Nov 12 2016 08:52
right
Ogundele Olumide
@Lumexralph
Nov 12 2016 08:52
what do you want your loop to do that it's not doing?
bahaa aldin
@bahaa-al-deen
Nov 12 2016 08:53

function translatePigLatin(str) {
  var one = str.split("");
  var vowels = ["a","u","o","i","y","e"];
  var two;
  var three;
  /*
  for (i=0; i<vowels.length; i++) {
    if (one[0].indexOf(vowels[i]) != -1) {
      one.push("way");
      two = one.join("");
      return two;
    }
  }
  */

  for (i=0; i<one.length; i++) {
    for (j=0; j<vowels.length; j++) {
      if (one[i].indexOf(vowels[j]) != -1) {
        two = i;
        break;


      }
    }
    break;
  }



  return two;
}

translatePigLatin("paragraphs");
try it now
and it will return nothing
i want my final outer loop to return the index of one at which the first vowel letter exists
jsleek21
@jsleek21
Nov 12 2016 08:55
havent talked in this thing yet so dont make fun of me. Im having trouble with the word blanks test
Ogundele Olumide
@Lumexralph
Nov 12 2016 08:55
@BahaaZidan you can't put the second break in the outer loop cos it's still part of the outer loop, it won't pick other element s from index 1,
jsleek21
@jsleek21
Nov 12 2016 08:56
not entirely sure what to do
LupusDiamond
@LupusDiamond
Nov 12 2016 08:56
hey guys, I need some help
bahaa aldin
@bahaa-al-deen
Nov 12 2016 08:56
@Lumexralph that's the point
LupusDiamond
@LupusDiamond
Nov 12 2016 08:56
I am at the "Make Object Properties Private" section
here is my code

var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

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

var Bike = function() {
  var speed = 0;
  // Only change code below this line.

  this.setGear = function (spd) {
    speed += spd;

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

var myCar = new Car();

var myBike = new Bike();
it always gives back 0
bahaa aldin
@bahaa-al-deen
Nov 12 2016 08:57
@Lumexralph how can i make it stop at the right momen
moment
Ogundele Olumide
@Lumexralph
Nov 12 2016 08:58
@BahaaZidan one[i].indexOf(vowels[j]) != -1 one[i] is picking each element in the array, it should be one.indexOf(vowels[j])
Markus Kiili
@Masd925
Nov 12 2016 08:58
@LupusDiamond The variable name should be gear, not speed.
Mukul
@mukulramchandani
Nov 12 2016 08:58
hey everyone i'm just stuck here in Seek and Destroy .... help would be appreciated..
function destroyer(arr) {

  // Remove all the values

  var value = [];
  var counter = 0;

  var arr1 = arr;

    for(var i=1; i<arguments.length; i++){
      for(var j =0;j<arr.length; j++){
        if(arr[j]===arguments[i]){
          counter++;
          value = arr1.splice(j,1);
        }
      }
    }

  return arr1;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Evan
@ehutterback
Nov 12 2016 08:59

Assign the value 7 to variable a.

Assign the contents of a to variable b.

bahaa aldin
@bahaa-al-deen
Nov 12 2016 08:59
@Lumexralph NOT SURE what u mean !
LupusDiamond
@LupusDiamond
Nov 12 2016 08:59
@Masd925 the name of the variable doesnt really matter
I've tried changing it
Evan
@ehutterback
Nov 12 2016 08:59
How do I create a js code for that?
Ogundele Olumide
@Lumexralph
Nov 12 2016 08:59
@BahaaZidan when you split the str...it returns an array you stored in one, right?
Markus Kiili
@Masd925
Nov 12 2016 09:00
@LupusDiamond SetGear should assign, not increment.
Ademola Adegbuyi
@ooade
Nov 12 2016 09:00
@ehutterback create a variable labeled a
bahaa aldin
@bahaa-al-deen
Nov 12 2016 09:00
@Lumexralph right
LupusDiamond
@LupusDiamond
Nov 12 2016 09:00
Oh, yeah that was my error
Markus Kiili
@Masd925
Nov 12 2016 09:00
@mukulcode Mutating the array you iterate over with for usually causes problems.
Evan
@ehutterback
Nov 12 2016 09:00
var a = 7;
var b = ?
LupusDiamond
@LupusDiamond
Nov 12 2016 09:00
thanks @Masd925
CamperBot
@camperbot
Nov 12 2016 09:00
lupusdiamond sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2891 | @masd925 |http://www.freecodecamp.com/masd925
Micah Lewis
@EastML
Nov 12 2016 09:00

Trying to sum all the numbers between two given numbers. For some reason I'm not getting any output at all. Any ideas why?
```
function sumAll(arr) {
var max = Math.max(arr[0],arr1);
var min = Math.min(arr[0],arr1);
var total = [];

for (var i = min; i <= max; i++) {
total.push(i);
}

total.reduce(function(total, num) {
return total + num;
});
}

sumAll([1, 4]);
```

abkmrad
@abkmrad
Nov 12 2016 09:01
@ehutterback var b = a ;
Ogundele Olumide
@Lumexralph
Nov 12 2016 09:01
@BahaaZidan in your inner loop branch, you want to get the index of an element in the array but you ended up indexing that array one[i]....that picks each element of the one array and compares with each of the element in vowel
Ashraful Islam
@iashraful
Nov 12 2016 09:01
hello!
Evan
@ehutterback
Nov 12 2016 09:01

Assign the value 7 to variable a.

Assign the contents of a to variable b.

var a = 7;
var b = ?;

bahaa aldin
@bahaa-al-deen
Nov 12 2016 09:02
i intended to do this @Lumexralph
Ademola Adegbuyi
@ooade
Nov 12 2016 09:02
@ehutterback you're almost done.. var b should be equal to a
Ashraful Islam
@iashraful
Nov 12 2016 09:02
const a = 7;
const b = a;
Mukul
@mukulramchandani
Nov 12 2016 09:02
@Masd925 my code is executing for some arguments and for some not
Ashraful Islam
@iashraful
Nov 12 2016 09:02
@ehutterback
bahaa aldin
@bahaa-al-deen
Nov 12 2016 09:03
i want each index of one to be compared with all indexes of vowels
Ashraful Islam
@iashraful
Nov 12 2016 09:03
^ show your code please
bahaa aldin
@bahaa-al-deen
Nov 12 2016 09:03
and when the first vowel gets detected
i want the two loops to stop
@Lumexralph
Evan
@ehutterback
Nov 12 2016 09:04
right @marhyorh but its giving me an error:
b should have a value of 7
Ashraful Islam
@iashraful
Nov 12 2016 09:04
@BahaaZidan what does one contain
Ademola Adegbuyi
@ooade
Nov 12 2016 09:04
@ehutterback yeah. You should have var b = a; that way the value of a will be assigned to b, which is 7
Mukul
@mukulramchandani
Nov 12 2016 09:04
function destroyer(arr) {

  // Remove all the values

  var value = [];
  var counter = 0;

  var arr1 = arr;

    for(var i=1; i<arguments.length; i++){
      for(var j =0;j<arr.length; j++){
        if(arr[j]===arguments[i]){
          counter++;
          value = arr1.splice(j,1);
        }
      }
    }

  return arr1;
}
destroyer([3, 5, 1, 2, 2], 2, 3, 5);
here's my code..
Ogundele Olumide
@Lumexralph
Nov 12 2016 09:05
@BahaaZidan that means you want to pick each element in vowels and check for the occurence in the str you split? right?
bahaa aldin
@bahaa-al-deen
Nov 12 2016 09:05

function translatePigLatin(str) {
  var one = str.split("");
  var vowels = ["a","u","o","i","y","e"];
  var two;
  var three;
  /*
  for (i=0; i<vowels.length; i++) {
    if (one[0].indexOf(vowels[i]) != -1) {
      one.push("way");
      two = one.join("");
      return two;
    }
  }
  */

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

    for (j=0; j<vowels.length; j++) {
      if (one[i].indexOf(vowels[j]) != -1) {
        two = i;
        break;


      }
    }

  }



  return two;
}

translatePigLatin("paragraphs");
@Lumexralph right
@Lumexralph and at the first occurance .. i want the checking to stop and the return the index of the occurance
Evan
@ehutterback
Nov 12 2016 09:06
thanks @marhyorh and @iashraful
CamperBot
@camperbot
Nov 12 2016 09:06
ehutterback sends brownie points to @marhyorh and @iashraful :sparkles: :thumbsup: :sparkles:
:cookie: 770 | @marhyorh |http://www.freecodecamp.com/marhyorh
:cookie: 552 | @iashraful |http://www.freecodecamp.com/iashraful
Ademola Adegbuyi
@ooade
Nov 12 2016 09:06
@ehutterback :+1:
Ogundele Olumide
@Lumexralph
Nov 12 2016 09:07
@BahaaZidan
function translatePigLatin(str) {
  //var one = str.split("");
  var vowels = ["a","u","o","i","y","e"];
  var two;
  var three;
  /*
  for (i=0; i<vowels.length; i++) {
    if (one[0].indexOf(vowels[i]) != -1) {
      one.push("way");
      two = one.join("");
      return two;
    }
  }
  */

  for (i=0; i<vowels.length; i++) {
      if (str.indexOf(vowels[i]) != -1) {
        two = str.indexOf(vowels[i]);
        break;

    }

  }



  return two;
}

translatePigLatin("paragraphs");
bahaa aldin
@bahaa-al-deen
Nov 12 2016 09:08
i can't read it this way
Micah Lewis
@EastML
Nov 12 2016 09:09
For some reason this code gives no output. Any reason why?
function sumAll(arr) {
  var max = Math.max(arr[0],arr[1]);
  var min = Math.min(arr[0],arr[1]);
  var total = [];

  for (var i = min; i <= max; i++) {
    total.push(i);
  }

  total.reduce(function(total, num) {
    return total + num;
  });
}

sumAll([1, 4]);
Ademola Adegbuyi
@ooade
Nov 12 2016 09:09
When did 'y' become vowel :wink:
Markus Kiili
@Masd925
Nov 12 2016 09:09
@EastML Your function has no return.
Ashraful Islam
@iashraful
Nov 12 2016 09:10
@marhyorh that is troll vowel y u no understand vowel?
CamperBot
@camperbot
Nov 12 2016 09:10
:trollface: troll problems? notify admins here
Ashraful Islam
@iashraful
Nov 12 2016 09:10
ops!
Ademola Adegbuyi
@ooade
Nov 12 2016 09:10
@EastML return total.reduce
@iashraful LOL ^_^
Ogundele Olumide
@Lumexralph
Nov 12 2016 09:10
@BahaaZidan that should return the index of the first vowel in your str parameter
Ashraful Islam
@iashraful
Nov 12 2016 09:10
@marhyorh I think you should start with a zero in there, because sometimes undefined gets added for me
Ademola Adegbuyi
@ooade
Nov 12 2016 09:11
@iashraful huh??
Micah Lewis
@EastML
Nov 12 2016 09:11
thanks @Masd925 and @marhyorh
CamperBot
@camperbot
Nov 12 2016 09:11
eastml sends brownie points to @masd925 and @marhyorh :sparkles: :thumbsup: :sparkles:
:cookie: 771 | @marhyorh |http://www.freecodecamp.com/marhyorh
:star2: 2892 | @masd925 |http://www.freecodecamp.com/masd925
Micah Lewis
@EastML
Nov 12 2016 09:11
I completely overlooked that.
Ashraful Islam
@iashraful
Nov 12 2016 09:11
reduce
Ademola Adegbuyi
@ooade
Nov 12 2016 09:11
@EastML :+1:
bahaa aldin
@bahaa-al-deen
Nov 12 2016 09:12
@Lumexralph it works !!!! .... thanks m8 ... you've been a great help
CamperBot
@camperbot
Nov 12 2016 09:12
bahaazidan sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 434 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Nov 12 2016 09:13
@BahaaZidan your pick each element of vowel by looping through, you don't need to loop through the str, in your branch if, if the occurrence of the vowel exist, your store the index of that vowel in the string str using indexOf and that's all
@BahaaZidan glad i could help :+1:
Guy Romelle Magayano
@guyromellemagayano
Nov 12 2016 09:15
Change the 0.0 so that quotient will equal to 2.2. Can someone help me with the possible value for this problem?
Ashraful Islam
@iashraful
Nov 12 2016 09:15
^ where is the code?
Guy Romelle Magayano
@guyromellemagayano
Nov 12 2016 09:16
var quotient = 0.0 / 2.0;
its just a simple question but i have no idea what number i should replace 0.0 with so that the quotient will be 2.2
Ashraful Islam
@iashraful
Nov 12 2016 09:17
4.4?
let quotient = 4.4/2.2;
ah sorry
that 2
Guy Romelle Magayano
@guyromellemagayano
Nov 12 2016 09:18
got it. thanks man.
Ashraful Islam
@iashraful
Nov 12 2016 09:18
4.8
Guy Romelle Magayano
@guyromellemagayano
Nov 12 2016 09:18
you're correct with 4.4 :+1:
Ashraful Islam
@iashraful
Nov 12 2016 09:18
no, 4.4/2.2 = 2
4.84 should be it
Guy Romelle Magayano
@guyromellemagayano
Nov 12 2016 09:19
the problem asks for var quotient = __ / 2.0;
Ashraful Islam
@iashraful
Nov 12 2016 09:19
ah
yes, then 4.4
Guy Romelle Magayano
@guyromellemagayano
Nov 12 2016 09:20
yeah. exactly :D
Ashraful Islam
@iashraful
Nov 12 2016 09:20
but need to deal with weird floats :)
floats always mess up my head
Guy Romelle Magayano
@guyromellemagayano
Nov 12 2016 09:20
hehe. at least you got it right though.
Ashraful Islam
@iashraful
Nov 12 2016 09:20
:D
Vantrav
@vantrav
Nov 12 2016 09:25
Hello amazing people
Ashraful Islam
@iashraful
Nov 12 2016 09:26
Hello amazing Vantrav :D
Ogundele Olumide
@Lumexralph
Nov 12 2016 09:30
@vantrav hey awesome Vantrav
@vantrav howdy?
Prateek Gogia
@reeversedev
Nov 12 2016 09:30
Anyone done with Record Collection challenge?
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Nov 12 2016 09:31
@reeversedev Yes!
Prateek Gogia
@reeversedev
Nov 12 2016 09:32
@thomlom can you help me man?
I don't know how to delete a record.
Ogundele Olumide
@Lumexralph
Nov 12 2016 09:32
@reeversedev use the delete operator
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Nov 12 2016 09:33
Sure! you have to use delete as @Lumexralph said
Ashraful Islam
@iashraful
Nov 12 2016 09:33
record.someStuffIwantToDelete = 'abcd';
delete record.someStuffIwantToDelete;
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Nov 12 2016 09:33
You can also use the splice method @reeversedev
Prateek Gogia
@reeversedev
Nov 12 2016 09:35
Delete operator? I don't know that.
Damn! Have i skipped any challenge?
Ogundele Olumide
@Lumexralph
Nov 12 2016 09:36
@thomlom is that possible with an Object's property?
@reeversedev lol
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Nov 12 2016 09:37
@Lumexralph I don't think it is possible with the splice method
I was talking about arrays for the splice method
Ogundele Olumide
@Lumexralph
Nov 12 2016 09:37
@thomlom okay, :smile:
Prateek Gogia
@reeversedev
Nov 12 2016 09:37
Okay guys! Can you please help me step by step. I am starting now.
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Nov 12 2016 09:38
@reeversedev Ok, what have you done so far?
Prateek Gogia
@reeversedev
Nov 12 2016 09:38
@thomlom nothing.
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Nov 12 2016 09:39
Do you know how to access object properties ? @reeversedev
Prateek Gogia
@reeversedev
Nov 12 2016 09:41
Yeah.
@thomlom
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Nov 12 2016 09:46

Well, if you know how to access an object property, than delete an object property is easy.
Here is an example :

var obj = {
    'test': 1,
    'test2': 2
}

To delete for example 'test1', just do this:

delete obj.test

or

delete obj['test']
Simply put, you write how to access your property and you add delete in front of it
Prateek Gogia
@reeversedev
Nov 12 2016 09:46
Okay. Let me try @thomlom .
Ashraful Islam
@iashraful
Nov 12 2016 09:46
var myObj = {};
myObj.name = 'Prateek Gogia';
console.log(myObj.name); // => Prateek Gogia
// now want to delete the name prooperty
delete myObj.name;
console.log(myObj.name); // => undefined
Prateek Gogia
@reeversedev
Nov 12 2016 09:47
@iashraful Thanks. Let me try,
CamperBot
@camperbot
Nov 12 2016 09:47
reeversedev sends brownie points to @iashraful :sparkles: :thumbsup: :sparkles:
:cookie: 553 | @iashraful |http://www.freecodecamp.com/iashraful
Annu Nirmal
@annunirmal
Nov 12 2016 09:51
Juan Suarez
@reoxb
Nov 12 2016 09:54
span vs div ...
Ashraful Islam
@iashraful
Nov 12 2016 09:55
the icons look fine to me
what is the problem?
Donatas
@Donaatas
Nov 12 2016 10:00
TypeError: str.fromCharCode is not a function
str.fromCharCode(str.charCodeAt(strArr[i]) - 13);
how it should be written to work?
Ashraful Islam
@iashraful
Nov 12 2016 10:02
your str is probably a full string
sorry
String.fromCharCode(str.charCodeAt(strArr[i]) - 13);
the first str should be String
Bogdan Gatej
@Bogdan2992
Nov 12 2016 10:04
hello all Manipulating Complex Objects, can any1 help me with this 1 ? here is my code
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
},
[
{
"artist": "Daft punk",
"title": "Homework",
"releaase_year":1997,
"formats": [
"CD",
"Cassette",
"LP",
"video"
],
"gold": true}]
// Add record here
];
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Nov 12 2016 10:05
@Bogdan2992 What are you struggling with?
Ashraful Islam
@iashraful
Nov 12 2016 10:05
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
},
[
{
"artist": "Daft punk",
"title": "Homework",
"releaase_year":1997,
"formats": [
"CD",
"Cassette",
"LP",
"video"
],
"gold": true}]
// Add record here
];
I think I see the issue
unclosed brackets
or unmatched brackets
Bogdan Gatej
@Bogdan2992
Nov 12 2016 10:05
where ?
Ashraful Islam
@iashraful
Nov 12 2016 10:06
line#12
Bogdan Gatej
@Bogdan2992
Nov 12 2016 10:07
I think that is ok,because in line2 i start the array then { witch is closing in line 12 and the [ from line 2 is closing in 25
Ashraful Islam
@iashraful
Nov 12 2016 10:08
wait
FranCoulibaly
@FranCoulibaly
Nov 12 2016 10:09

Can anybody help me with the task Profile Lookup? I keep getting the error unexpected token for my last else statement.
``` function lookUpProfile(firstName, prop){
// Only change code below this line

for (var i = 0; i < contacts.length; i++)
{
for (var j = 0; j < contacts[i].length; j++)
{
contact = (contacts[i][j]);
}

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

      if (contacts[i][prop].hasOwnProperty(prop))
          {
             return contacts[i][j][prop];  
          }
       else
         {
         return "No such property";
         }
       } // end inside if
     } // end outside if

   else
       {
          return "No such contact";
       }


 } // end for loop 

// Only change code above this line
} // end function

// Change these values to test your function
lookUpProfile("Akira", "likes");

```

Ashraful Islam
@iashraful
Nov 12 2016 10:09
var myMusic = [
{
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [
                            "CS",
                            "8T",
                            "LP" 
                      ],
    "gold": true
},
[
    {
    "artist": "Daft punk",
    "title": "Homework",
    "releaase_year":1997,
    "formats": [
                            "CD",
                            "Cassette",
                            "LP",
                            "video"
                        ],
    "gold": true}]
    // Add record here
];
now makes sense
FranCoulibaly
@FranCoulibaly
Nov 12 2016 10:10
Oh sorry, that went weird
function lookUpProfile(firstName, prop){
// Only change code below this line


  for (var i = 0; i < contacts.length; i++)
    {
      for (var j = 0; j < contacts[i].length; j++)
          {
         contact = (contacts[i][j]);
          }

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

          if (contacts[i][prop].hasOwnProperty(prop))
              {
                 return contacts[i][j][prop];  
              }
           else
             {
             return "No such property";
             }
           } // end inside if
         } // end outside if

       else
           {
              return "No such contact";
           }


     } // end for loop 




// Only change code above this line
} // end function

// Change these values to test your function
lookUpProfile("Akira", "likes");
Bogdan Gatej
@Bogdan2992
Nov 12 2016 10:12
still no't working
so my layout of the code is ok yeah ?
Ashraful Islam
@iashraful
Nov 12 2016 10:12
which?
Bogdan Gatej
@Bogdan2992
Nov 12 2016 10:13

@iashraful myMusic1 should have at least 4 properties
myMusic1 should contain an artist property which is a string
myMusic1 should contain a title property which is a string
myMusic1 should contain a release_year property which is a number
myMusic1 should contain a formats property which is an array
formats should be an array of strings with at least two elements

i'm no't getting this things

Ashraful Islam
@iashraful
Nov 12 2016 10:13
I think you need to do this instead
var myMusic = [
{
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [
                            "CS",
                            "8T",
                            "LP" 
                      ],
    "gold": true
},
{
    "artist": "Daft punk",
    "title": "Homework",
    "releaase_year":1997,
    "formats": [
                            "CD",
                            "Cassette",
                            "LP",
                            "video"
                        ],
    "gold": true}
    // Add record here
];
^ check the bracket pair
myMusic is an array
but you made it an array and then you again made another array inside myMusic
Bogdan Gatej
@Bogdan2992
Nov 12 2016 10:14
@iashraful done thank you,got to many brackets open
CamperBot
@camperbot
Nov 12 2016 10:15
bogdan2992 sends brownie points to @iashraful :sparkles: :thumbsup: :sparkles:
:cookie: 554 | @iashraful |http://www.freecodecamp.com/iashraful
Ashraful Islam
@iashraful
Nov 12 2016 10:15
:+1:
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:16
@FranCoulibaly you have single array so no need of nested loop, only one loop will suffice
FranCoulibaly
@FranCoulibaly
Nov 12 2016 10:17
@ghulamshabir but if I don't have that won't the loop just stop when it gets to return?
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:18
@FranCoulibaly return stops function no matter how many loops are in funtion
FranCoulibaly
@FranCoulibaly
Nov 12 2016 10:19
@ghulamshabir so how would I get it to run through the whole array instead of stopping after the first true statement?
Donatas
@Donaatas
Nov 12 2016 10:19
if(strArr[i].charCodeAt(strArr[i]) >= 65 && strArr[i].charCodeAt(strArr[i]) <= 90) 
      {
        strArr[i] = String.fromCharCode(strArr[i].charCodeAt(strArr[i]) - 13);

this works great and all my char's goes down by 13. but then, who get < 65 i want to add 26 to, and it doesn't work.

if (strArr[i].charCodeAt(strArr[i]) < 65)
            {
              strArr[i] = String.fromCharCode(strArr[i].charCodeAt(strArr[i]) + 26);
            }

why?

Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:21
@FranCoulibaly if you find property return command will return that, it means your remaining code will not be executed, you can leverage that logic
Diego Mayer
@Chrono79
Nov 12 2016 10:21
@Donaatas use charCodeAt() or charCodeAt(0) if you test individual letters
JackVizl
@JackVizl
Nov 12 2016 10:21
yo anyone here that can help with a basic algorithm challenge?
Donatas
@Donaatas
Nov 12 2016 10:22
if statements are nested.
if () 
{
strArr[i] = ...
if ()
{
strArr[i] = ....
}
}
@JackVizl write the problem :)
JackVizl
@JackVizl
Nov 12 2016 10:23
its the falsy bouncer one
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:23
@JackVizl you have code ?
copy paste here
Donatas
@Donaatas
Nov 12 2016 10:24
use ``` for the code
Ashraful Islam
@iashraful
Nov 12 2016 10:24
@JackVizl you are almost there
JackVizl
@JackVizl
Nov 12 2016 10:24

function bouncer(arr) {

var newArr;

for(i=0;i<arr.length;i++){
newArr= arr.filter(function(i){
return newArr;

});

return newArr;
}
}

bouncer([7, "ate", "", false, 9]);

looking for a clever way to get returns for all the characters
thought i could do a switch
or chained ifs
but thats trash so i know theres a propper way
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:25
@JackVizl return i inside filter callback
Diego Mayer
@Chrono79
Nov 12 2016 10:25
@Donaatas what is strArr[i]?
Donatas
@Donaatas
Nov 12 2016 10:25
@Chrono79
var strArr = str.split("");
JackVizl
@JackVizl
Nov 12 2016 10:25
Thanks @ghulamshabir
CamperBot
@camperbot
Nov 12 2016 10:25
jackvizl sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:cookie: 975 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Diego Mayer
@Chrono79
Nov 12 2016 10:26
@Donaatas then use charCodeAt(0) or charCodeAt()
it's a string of length one, the argument of charCodeAt is the position you want to test
JackVizl
@JackVizl
Nov 12 2016 10:26
so filter just automatically gets rid of all the falsy values?
i thought i would have to specify all of them
Donatas
@Donaatas
Nov 12 2016 10:27
ok i'll read more about it and try. thanks @Chrono79
CamperBot
@camperbot
Nov 12 2016 10:27
donaatas sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 2505 | @chrono79 |http://www.freecodecamp.com/chrono79
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:27
@JackVizl ye
JackVizl
@JackVizl
Nov 12 2016 10:27
Thanks man
was very confused on that one
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:28
@JackVizl you are learning
JackVizl
@JackVizl
Nov 12 2016 10:28
yeah
Micah Lewis
@EastML
Nov 12 2016 10:29
So I'm finding differences between two arrays and this is the code I came up with:
function diffArray(arr1, arr2) {
  var newArr = [];

 for (var i = 0; i < arr1.length; i++) {
    if (arr2.indexOf(arr1[i]) === -1) {
      newArr.push(arr1[i]);
    }
  }

  for (var i = 0; i < arr2.length; i++) {
    if (arr1.indexOf(arr2[i]) === -1) {
      newArr.push(arr2[i]);
    }
  }

  return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Evan
@ehutterback
Nov 12 2016 10:29
hello anyone knows ho to code this in js?
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
Micah Lewis
@EastML
Nov 12 2016 10:29
Should I redo this? I feel like it undermines the spirit of coding
Alexandro Pequeno
@Argestis
Nov 12 2016 10:29
Guys, I'm having problems triggering and if when arrays are equal.

var game = {
count : [1,2,3,4],
guessWhat : [],
red : $("#red"),
blue : $("#blue"),
green : $("#green"),
yellow : $("#yellow")
};

game.red.on('click', function(){

game.guessWhat.push(1);
console.log(game.guessWhat)
});

game.blue.click(function(){

game.guessWhat.push(2);
console.log(game.guessWhat)
});

game.green.click(function(){

game.guessWhat.push(3);
console.log(game.guessWhat)
});

game.yellow.click(function(){

game.guessWhat.push(4);
console.log(game.guessWhat)
console.log(game.guessWhat.length + " " + game.count.length)
});

if(game.count.length === game.guessWhat.length){

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

if(game.count[i] === game.guessWhat[i]){

 console.log("bien " + game.count[i]);

}
else{ console.log("mal " + game.count[i]); }
}}

I'm pushing values to guessWhat array but when they reach the same length as game.count array is not triggering
any ideas?
Micah Lewis
@EastML
Nov 12 2016 10:32
@Argestis please check the markdown help to put your code in a readable format
Bogdan Gatej
@Bogdan2992
Nov 12 2016 10:34
hello all
Alexandro Pequeno
@Argestis
Nov 12 2016 10:34
 ``` 

var game = {
count : [1,2,3,4],
guessWhat : [],
red : $("#red"),
blue : $("#blue"),
green : $("#green"),
yellow : $("#yellow")
};

game.red.on('click', function(){

game.guessWhat.push(1);
console.log(game.guessWhat)
});

game.blue.click(function(){

game.guessWhat.push(2);
console.log(game.guessWhat)
});

game.green.click(function(){

game.guessWhat.push(3);
console.log(game.guessWhat)
});

game.yellow.click(function(){

game.guessWhat.push(4);
console.log(game.guessWhat)
console.log(game.guessWhat.length + " " + game.count.length)
});

if(game.count.length === game.guessWhat.length){

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

if(game.count[i] === game.guessWhat[i]){

console.log("bien " + game.count[i]);

}
else{ console.log("mal " + game.count[i]); }
}}
```

Godammit xD, one sec
Bogdan Gatej
@Bogdan2992
Nov 12 2016 10:34
how is the standar procedure to acces a nested object
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:34
@ehutterback % divides its left side of number with right one, retrns the remainder, you should assign the result to remainder variable
@Bogdan2992 if you know the keys use nested dot notation, if keys are in a variable use bracket notation for each object
badrkhanjaff
@badrkhanjaff
Nov 12 2016 10:36
how do you do this celisus to fahrenheit thing its getting on my nerve
Alexandro Pequeno
@Argestis
Nov 12 2016 10:36

`

var game = {
count : [1,2,3,4],
guessWhat : [],
red : $("#red"),
blue : $("#blue"),
green : $("#green"),
yellow : $("#yellow")
};

game.red.on('click', function(){

game.guessWhat.push(1);
console.log(game.guessWhat)
});

game.blue.click(function(){

game.guessWhat.push(2);
console.log(game.guessWhat)
});

game.green.click(function(){

game.guessWhat.push(3);
console.log(game.guessWhat)
});

game.yellow.click(function(){

game.guessWhat.push(4);
console.log(game.guessWhat)
console.log(game.guessWhat.length + " " + game.count.length)
});

if(game.count.length === game.guessWhat.length){

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

if(game.count[i] === game.guessWhat[i]){

console.log("bien " + game.count[i]);

}
else{ console.log("mal " + game.count[i]); }
}}
`

omg is not working D:
Evan
@ehutterback
Nov 12 2016 10:36
@ghulamshabir
var remainder = 11% 3;
var remainder = 2;
right?
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:36
@badrkhanjaff use celsius to farenheit farmula
Bogdan Gatej
@Bogdan2992
Nov 12 2016 10:36

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

// Only change code below this line

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

Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:37
@ehutterback you don't need second line, first line is the solution
Bogdan Gatej
@Bogdan2992
Nov 12 2016 10:37
@ghulamshabir but i think that there is a problem between my var gloveBoxContents and the thing that i input after the =
badrkhanjaff
@badrkhanjaff
Nov 12 2016 10:37
its asking me to convert 5 numbers i do all and it only checks for last number i used and says i didnt do it for the ones before it
Evan
@ehutterback
Nov 12 2016 10:37
@ghulamshabir ...thank u
badrkhanjaff
@badrkhanjaff
Nov 12 2016 10:38

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = 30 9/5 + 32;
fahrenheit = -30
9/5 + 32;
fahrenheit = -10 9/5 + 32;
fahrenheit = 0
9/5 + 32;
fahrenheit = 20 * 9/5 + 32;

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

Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:38
@ehutterback thank without dots i because i did not get a brownie
CamperBot
@camperbot
Nov 12 2016 10:38
ghulamshabir sends brownie points to @ehutterback :sparkles: :thumbsup: :sparkles:
:cookie: 137 | @ehutterback |http://www.freecodecamp.com/ehutterback
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:38
@Bogdan2992 nest another key after inside
Evan
@ehutterback
Nov 12 2016 10:39
@ghulamshabir thank you
CamperBot
@camperbot
Nov 12 2016 10:39
ehutterback sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:cookie: 976 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:39
@ehutterback :smile:
Bogdan Gatej
@Bogdan2992
Nov 12 2016 10:40
done
@ghulamshabir done thnak you
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:40
@Bogdan2992 please send me a brownie with correct thanks spelling
CamperBot
@camperbot
Nov 12 2016 10:40
ghulamshabir sends brownie points to @bogdan2992 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for bogdan2992
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:41
@badrkhanjaff do not hard code celsius values you need to make use of function parameter you already have
@badrkhanjaff solution is one liner
Alexandro Pequeno
@Argestis
Nov 12 2016 10:44
var game = {
count : [1,2,3,4],
guessWhat : [],
red : $("#red"),
blue : $("#blue"),
green : $("#green"),
yellow : $("#yellow")
};





game.red.on('click', function(){

game.guessWhat.push(1);
   console.log(game.guessWhat)
}); 

game.blue.click(function(){

  game.guessWhat.push(2);
   console.log(game.guessWhat)
}); 

game.green.click(function(){

  game.guessWhat.push(3);
    console.log(game.guessWhat)
}); 

game.yellow.click(function(){

  game.guessWhat.push(4);
    console.log(game.guessWhat)

}); 




if(game.count.length === game.guessWhat.length){

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

if(game.count[i] === game.guessWhat[i]){

     console.log("bien " + game.count[i]);
}
else{ console.log("mal " + game.count[i]); }
}}
Alright! i got it
LOL
So guys any of you have any idea on why the if is not triggering when the length is the same? :c
abkmrad
@abkmrad
Nov 12 2016 10:45
hello friends i need a help

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

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

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

Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:46
@Argestis i++ without space
abkmrad
@abkmrad
Nov 12 2016 10:46
what i get as result is undefined
Alexandro Pequeno
@Argestis
Nov 12 2016 10:46
aight, one sec.
Krishna Bhandari
@krishna8723
Nov 12 2016 10:47
what is wrong with this code please help.
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:47
@abkmrad yes because checkProp does not exist in the object, checkProp is a variable not key itself
Krishna Bhandari
@krishna8723
Nov 12 2016 10:47

// 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(wasThatTrue){
return "Yes, that was true";
}
return " No, that was false";

// Only change code above this line.

}

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

Instructions
Create an if statement inside the function to return "Yes, that was true" if the parameter wasThatTrue is true and return "No, that was false" otherwise.
Alexandro Pequeno
@Argestis
Nov 12 2016 10:49
Still not :c @ghulamshabir
someone help me with this pls
stumped as to why it is not working
@ghulamshabir maybe?
Divya Rani
@Divya063
Nov 12 2016 10:51

@Divya063
window.onload = function () {

var submit=document.getElementById('login_btn');
submit.onclick=function() {
//create a response
var request=new XMLHttpRequest();
//capture the response
request.onreadystatechange=function(){
if(request.readyState===XMLHttpRequest.DONE){
if(request.status===200){
//capture response
console.log('user logged in');
alert('logged in successfully');

       }else if (request.status===403){
           alert('username/password is correct');
       }else if (request.status===500){
           alert('something went wrong');

       }

   }

};

//Make a request
var username=document.getElementById('username').value;
var password=document.getElementById('password').value;
console.log(username);
console.log(password);
request.open('POST','http://divya063.imad.hasura-app.io/login',true);
request.setRequestHeader('Content-Type','application/json');
request.send(JSON.stringify({username: username,password: password}));

};

};
window.onload = function () {
var register = document.getElementById('register_btn');
register.onclick =function() {
// Create a request object
var request = new XMLHttpRequest();

    // Capture the response and store it in a variable
    request.onreadystatechange = function () {
      if (request.readyState === XMLHttpRequest.DONE) {
          // Take some action
          if (request.status === 200) {
              alert('User created successfully');
              register.value = 'Registered!';
          } else {
              alert('Could not register the user');
              register.value = 'Register';
          }
      }
    };

    // Make the request
    var username = document.getElementById('username').value;
    var password = document.getElementById('password').value;
    console.log(username);
    console.log(password);
    request.open('POST', 'http://divya063.imad.hasura-app.io/create-user', true);
    request.setRequestHeader('Content-Type', 'application/json');
    request.send(JSON.stringify({username:username, password: password}));  


};

};

what is wrong with my login button it is not working

Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:51
@JackVizl you are comparing word's length with prevLen, shoud compare with longestLen
JackVizl
@JackVizl
Nov 12 2016 10:52
ahh of course
im an idiot
thanks again @ghulamshabir
CamperBot
@camperbot
Nov 12 2016 10:52
jackvizl sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:warning: jackvizl already gave ghulamshabir points
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:52
@Argestis use bracket notation to access property
JackVizl
@JackVizl
Nov 12 2016 10:54
@ghulamshabir how did you get so good?
Alexandro Pequeno
@Argestis
Nov 12 2016 10:54
game[guessWhat] you mean?
O:
abkmrad
@abkmrad
Nov 12 2016 10:55
that how i solve it it's work now :

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

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

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

Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:55
@JackVizl lol, thanks, helping here people made me good
CamperBot
@camperbot
Nov 12 2016 10:55
ghulamshabir sends brownie points to @jackvizl :sparkles: :thumbsup: :sparkles:
:cookie: 251 | @jackvizl |http://www.freecodecamp.com/jackvizl
Terryd12345
@Terryd12345
Nov 12 2016 10:57
hey guys on record collection I'm a bit confused on exactly why my code isn't working. As a test I used:
if (prop !== 'tracks' && value !== '' ) {
collection.id[prop] = value; }
Trying to figure out how to past the first test but not sure why that doesn't work, it should be assigning value to prop right?
Ghulam Shabir
@ghulamshabir
Nov 12 2016 10:58
@Terryd12345 id is a variable, you can not use variables in dot notation
Ian
@toianw
Nov 12 2016 10:58
@Argestis that if statement will be executed before any click events are triggered, so will never be true;
Terryd12345
@Terryd12345
Nov 12 2016 10:59
@ghulamshabir oh okay thanks.
CamperBot
@camperbot
Nov 12 2016 10:59
terryd12345 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:cookie: 977 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Alexandro Pequeno
@Argestis
Nov 12 2016 10:59
@toianw Yeah i know, i'm trying to figure how to triger it after it :c
Ian
@toianw
Nov 12 2016 11:00
@Argestis you could put it in a function and call that function from inside the click event handlers
Alexandro Pequeno
@Argestis
Nov 12 2016 11:03
@toianw You Sir/Miss, I wish you a very happy life, full of money and lots of cookies, thank you very much.
CamperBot
@camperbot
Nov 12 2016 11:03
argestis sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
:cookie: 416 | @toianw |http://www.freecodecamp.com/toianw
Ian
@toianw
Nov 12 2016 11:04
@Argestis thank you! same to you :smile:
CamperBot
@camperbot
Nov 12 2016 11:04
toianw sends brownie points to @argestis :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @argestis |http://www.freecodecamp.com/argestis
Bogdan Gatej
@Bogdan2992
Nov 12 2016 11:05
hello
i need help again
i'm at the task Record Collection
Stephen James
@sjames1958gm
Nov 12 2016 11:05
@Divya063 Do you see any console errors? -
Jeff Shapiro
@Jeff-Shapiro
Nov 12 2016 11:05
Hey @sjames1958gm