These are chat archives for FreeCodeCamp/HelpJavaScript

18th
Apr 2017
Joseph
@revisualize
Apr 18 2017 00:00
I could go to an event.
Henry
@GitHub-Henry
Apr 18 2017 00:01
for a break (in chrome enter) chrome://network-error/-106 then up arrow
Joseph
@revisualize
Apr 18 2017 00:01
space bar
Henry
@GitHub-Henry
Apr 18 2017 00:02
either one
Joseph
@revisualize
Apr 18 2017 00:03
blob
@GitHub-Henry Well, if you hit the up arrow while you're still in the address bar. It doesn't do anything.
Henry
@GitHub-Henry
Apr 18 2017 00:04
down arrows are better when you get to the flying birds
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 00:05
@VikrantSingh13 add this to your css
  #timer {
    margin: 0;
  }
if mean the margin above the timer
Joseph
@revisualize
Apr 18 2017 00:06
Whelp.
blob
Enough of me goofing off
@HeebieGeeBee @sjames1958gm @awb715 :v:
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 00:07
laters
Vikrant Singh
@VikrantSingh13
Apr 18 2017 00:11
@HeebieGeeBee thanks i was trying to add it to the timer class
CamperBot
@camperbot
Apr 18 2017 00:11
vikrantsingh13 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1369 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
meitarbe
@meitarbe
Apr 18 2017 00:14
Hi guys can someoone please help me with an Ajax problem?
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 00:20
@meitarbe i can try
if you say what it is
keithdidier
@keithdidier
Apr 18 2017 00:20
It won't let me add anymore JSON Objects, anyone know what to do?
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
];
meitarbe
@meitarbe
Apr 18 2017 00:21
i @HeebieGeeBee Im at the weather app challange
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 00:21
@keithdidier why not?
you just add an object to the array
meitarbe
@meitarbe
Apr 18 2017 00:21
var locationRequest = new XMLHttpRequest();                                           
    locationRequest.open("GET", "http://ip-api.com/json", false);    
    locationRequest.send();
var locationData = JSON.parse(locationRequest.response);    

var reqString = "api.openweathermap.org/data/2.5/weather?lat=" + Math.floor(locationData.lat) + "&lon=" + Math.floor(locationData.lon) + "&appid=9b17a4c2ccdea677db3b68a90c1f1ded";



var weatherRequest = new XMLHttpRequest();                                           
    weatherRequest.open("GET", reqString, false);    
    weatherRequest.send();
var weatherData = JSON.parse(weatherRequest.response);
@HeebieGeeBee this is my JS code but from some reasen I the seconed AJAX call doesnt work
@HeebieGeeBee the reqString is ok Ive checked it already
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 00:26
@meitarbe you running this in a codepen?
keithdidier
@keithdidier
Apr 18 2017 00:27
Here's my code. Point out anything you see wrong , please.
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true

  // Add record here
  "artist" : "Metalica",
  "title" : "One",
  "release_year" : 1991,
  "formats" : [
  "CD",
  "Cassette" ],

  }
];
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 00:27
@keithdidier youve added data inside the existing object
youre meant to add another object
keithdidier
@keithdidier
Apr 18 2017 00:28
@HeebieGeeBee Does that mean create another var?
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 00:29
@keithdidier no just create another element i the myMusic array thats a new object
Daniel Mattox
@dmattox10
Apr 18 2017 00:29
Is it ok, if I create a convoluted function to complete "Factorialize a Number" that is unnecessary but works, because I can't find a neat way to complete it?
meitarbe
@meitarbe
Apr 18 2017 00:29
@HeebieGeeBee NO on my computer
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 00:30
@meitarbe think you might be have sychronous issues
you might need to use a promise
@meitarbe or use a different method for the ajax call
meitarbe
@meitarbe
Apr 18 2017 00:31
@HeebieGeeBee can you please explain a lil bit more? Im completly new with Ajax
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 00:31
and stick the second call to the weather api inside the ip lookup callback
keithdidier
@keithdidier
Apr 18 2017 00:31
@HeebieGeeBee Using curly braces or square brackets?
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 00:32
@meitarbe well ive never used the xmlhttprequest method myself
so dont know too much about it
@keithdidier objects use curly brackets
Joseph
@revisualize
Apr 18 2017 00:33
cbot
CamperBot
@camperbot
Apr 18 2017 00:33
you called?
meitarbe
@meitarbe
Apr 18 2017 00:33
@HeebieGeeBee OK thank you !!
CamperBot
@camperbot
Apr 18 2017 00:33
meitarbe sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1370 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 00:33
arrays use brackets
@meitarbe seems like it might be an old method
@meitarbe but couldnt say for sure
Joseph
@revisualize
Apr 18 2017 00:35
hi.
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 00:36
@revisualize yo
Joseph
@revisualize
Apr 18 2017 00:37
@keithdidier You just need to create an array with two objects as elements. [ { ... } , { ... } ] please note the , between array elements.
keithdidier
@keithdidier
Apr 18 2017 00:38
It printed as "null".
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
 [{"artist" : "Metalica", "title" : "One", "release_year" : 1991, "formats" : ["CD", "MP3"]}] // Add record here
];
Joseph
@revisualize
Apr 18 2017 00:38
@keithdidier You don't have a , between your array elements.
@keithdidier Also, you didn't add an object.
You did this.
[ { .... } [ { .... } ] ]
Josh Bourke
@Warmtinnie
Apr 18 2017 00:41
could some one help me with "Accessing Objects Properties with Variables" i am having a bit of trouble

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

// Only change code below this line;

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

Joseph
@revisualize
Apr 18 2017 00:41
@Warmtinnie sure.
@Warmtinnie variables hold values.
@Warmtinnie what value does playerNumber hold?
Josh Bourke
@Warmtinnie
Apr 18 2017 00:42
16?
Joseph
@revisualize
Apr 18 2017 00:42
@Warmtinnie Can you use that value of playerNumber inside the object access of testObj instead of hard coding it?
Josh Bourke
@Warmtinnie
Apr 18 2017 00:43
it asks me to out the playernumber into bracketnotation but when i do that it never work
Joseph
@revisualize
Apr 18 2017 00:43
Show me.
playernumber and playerNumber aren't the same thing.
Josh Bourke
@Warmtinnie
Apr 18 2017 00:43
yer sorry miss typed
Joseph
@revisualize
Apr 18 2017 00:43
@Warmtinnie It's all good. Can you show me?
Josh Bourke
@Warmtinnie
Apr 18 2017 00:44

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

// Only change code below this line;

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

Joseph
@revisualize
Apr 18 2017 00:44
@Warmtinnie In that what value does playerNumber hold?
Josh Bourke
@Warmtinnie
Apr 18 2017 00:44
should i but the testObj
does it hold the bracket?
or the number?
Joseph
@revisualize
Apr 18 2017 00:44
@Warmtinnie By doing var playerNumber = [16]; // Change this Line you're making playerNumber an array with 1 element: 16
@Warmtinnie If playerNumber is supposed to hold the value 16 what happens when you use playerNumber in here: var player = testObj["16"]; instead of hard coding it?
@Warmtinnie as stated above. Variables hold values.
Josh Bourke
@Warmtinnie
Apr 18 2017 00:46
when i do that it still says that playerNumber should be a number and should be using bracket notation

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

// Only change code below this line;

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

Joseph
@revisualize
Apr 18 2017 00:47
@Warmtinnie Look.
playerNumber should just be 16
@Warmtinnie You then use playerNumber in the next line down.
Because playerNumber stores the value 16
keithdidier
@keithdidier
Apr 18 2017 00:48
New code. Still not working @revisualize
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
[ {"artist" : "Metalica", "title" : "One", "release_year" : 1991 } , {"formats": "CD", "MP3"} ] // Add record here
];
Joseph
@revisualize
Apr 18 2017 00:49
@Warmtinnie Doing this: testObj["16"]; you're not using the variable value. You're hard coding "16" in your object access.
Andrei Dushkou
@burn1ng
Apr 18 2017 00:49
@revisualize thank you, only now i understand what you mean) challenge is accomplished)
CamperBot
@camperbot
Apr 18 2017 00:49
burn1ng sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3764 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Apr 18 2017 00:49
@keithdidier Still incorrect. You're still doing [ { .... } [ { .... } ] ]
@keithdidier You just need to create an array with two objects as elements. [ { ... } , { ... } ] please note the , between array elements.
Nicholas Johnson
@newplasticideas
Apr 18 2017 00:49

Hi all, I need some help with my quote machine. Basically, I have an animation to fade the text in and out but I can still see the text updating before the fade out/empty/append/fade in happens. Here's the codepen, I have been stumped on this one for a while so any help would be fantastic. http://codepen.io/newplasticideas/pen/WjebyQ?editors=0110

Pay no mind to the function inside the comment. I'm working on a function that will allow the font size to adjust based on string length. I am hoping this will prevent the div container from adjusting its height. It's a problem to solve another day, although, if you do have a moment to look at it... up to yall :grinning:

Joseph
@revisualize
Apr 18 2017 00:50
@keithdidier You're missing a , between your array elements.
@keithdidier You're also not adding an object. you're adding an array with an object in it..
:busstop:
:v:
hovig27
@hovig27
Apr 18 2017 00:51
i need help in this <<Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.>>
Josh Bourke
@Warmtinnie
Apr 18 2017 00:51
@revisualize so store the value into the playerNumber and then using the playerNumber variable in player?
Joseph
@revisualize
Apr 18 2017 00:53
@Warmtinnie try it and show me.
Josh Bourke
@Warmtinnie
Apr 18 2017 00:53
i did it thank you @revisualize
CamperBot
@camperbot
Apr 18 2017 00:53
warmtinnie sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3765 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Apr 18 2017 00:54
@Warmtinnie you need to learn that concept.
Roxroy
@roxroy
Apr 18 2017 00:54
@hovig27 , the % divides a number , however it give the reminder part , eg 5 % 3 is that same as ( 5 divided by 3 reminder 2) . So the answer is 2
Josh Bourke
@Warmtinnie
Apr 18 2017 00:54
i think i just kept getting confused when i kept saying use bracket notation
Joseph
@revisualize
Apr 18 2017 00:57
@Warmtinnie Well, I hope it makes sense because you'll need that concept a LOT in your journey.
@hovig27 Remainder:
http://images.tutorvista.com/cms/images/38/remainder1.PNG
13 % 2 is 1 ... 26 % 5 is 1 ... 24 % 6 is 0
24 % 5 is 4 ... 219 % 20 is 19
Just like in my examples above you use the % operator just like any other math operator (+, -, *, /)
ROBUSTO8
@ROBUSTO8
Apr 18 2017 00:58

can someone point out to what is wrong with my "Mutations" code? :

function mutation(arr) {
for (var i = 0; i < arr.length; i++) {
arr[i] = arr[i].toLowerCase();
}

var arrTwo = arr[1];
for (var j = 0; j < arrTwo.length; j++) {
if (arr[0].indexOf(arrTwo[j]) > 0) {
return true;
} else {
return false;
}

}
}

CamperBot
@camperbot
Apr 18 2017 00:58
:star2: 3766 | @revisualize |http://www.freecodecamp.com/revisualize
keithdidier sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
Augustus Bacud
@gigmaore
Apr 18 2017 01:03
hey guys can you help me?
Andrei Dushkou
@burn1ng
Apr 18 2017 01:05
of course, what's the problem?
Roxroy
@roxroy
Apr 18 2017 01:05
@gigmaore , hint. start the string with ' instead of "
Augustus Bacud
@gigmaore
Apr 18 2017 01:06
oh
thanks
Andrei Dushkou
@burn1ng
Apr 18 2017 01:06
@gigmaore start and end of your string should be '
and don't miss to erase unused backspaces
Augustus Bacud
@gigmaore
Apr 18 2017 01:07
got it! Thanks
Daniel Mattox
@dmattox10
Apr 18 2017 01:11
Time to learn. This code works, solves the "Factorialize a Number" algorithm challenge. BUT, what do I need to change to make the "if" at the beginning unnecessary when it tries "factorialize(0)?
function factorialize(num) {
  var factor = num;
  if (factor < 1) {
    factor = 1;
  }
  while (num > 1) {
    factor *= num -1;
    num--;
    console.log("Factor " + factor);
    console.log("num " + num);
  }

  return factor;
}

factorialize(5);
Roxroy
@roxroy
Apr 18 2017 01:12
@gigmaore , also remove the escaping i.e. the \
Stephen James
@sjames1958gm
Apr 18 2017 01:15
@dmattox10 start your factor at 1 then have your loop not run even once when num < 2
Maribeth
@MBKalfoglou
Apr 18 2017 01:16
I'm on "Escape Sequences in Strings" in Javascript, and I cannot figure out what to do. I'm typing it exactly how it says.
var myStr = "FirstLinen\SecondLine\rThirdLine"; // Change this line
Roxroy
@roxroy
Apr 18 2017 01:17
@dmattox10 , instead of factor = 1; just return 1; right away
Daniel Mattox
@dmattox10
Apr 18 2017 01:18
Thanks @sjames1958gm , @roxroy
CamperBot
@camperbot
Apr 18 2017 01:18
dmattox10 sends brownie points to @sjames1958gm and @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 706 | @roxroy |http://www.freecodecamp.com/roxroy
:star2: 6772 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 18 2017 01:18
@MBKalfoglou Well it is \n not n\ and you are missing two escape sequences for backslash
Maribeth
@MBKalfoglou
Apr 18 2017 01:19
All right, I see it now. Thank you!
Stephen James
@sjames1958gm
Apr 18 2017 01:19
@ROBUSTO8 You are returning true on the first letter if it is there - you never check any other letters
You need to return false inside the loop and true after the loop
@MBKalfoglou :+1:
Gebre Mesquitta
@MtZionCode
Apr 18 2017 01:22

Hey I'm in the Switch Statements challenge and these are what I've writing per following the instructions given....do you see where I have made mistakes? function caseInSwitch(val) {
var answer = "alpha";
switch (answer) {
case "alpha":
break;

case "beta":
  break;

case "gamma":
  break;

case "delta":

} ......thanks in advance for your help!

ROBUSTO8
@ROBUSTO8
Apr 18 2017 01:22
@sjames1958gm thanks
thanks @sjames1958gm
CamperBot
@camperbot
Apr 18 2017 01:22
robusto8 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6773 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Joseph
@revisualize
Apr 18 2017 01:23
@MtZionCode You shouldn't be hard coding answer before the switch.
@MtZionCode By hard coding answer to be "alpha" .. it will always be "alpha"
Gebre Mesquitta
@MtZionCode
Apr 18 2017 01:24
oh! ok...so what do I put instead of "answer"?
Joseph
@revisualize
Apr 18 2017 01:24
@MtZionCode When you have a function declaration of function caseInSwitch(val) you have a function name of caseInSwitch and the parameter of val.
Gebre Mesquitta
@MtZionCode
Apr 18 2017 01:25
@revisualize, so it should be "switch (caseInSwitch)"?
Joseph
@revisualize
Apr 18 2017 01:25
@MtZionCode When you do a function call caseInSwitch('alpha') the parameter val gets the value of 'alpha'
@MtZionCode When you do a function call caseInSwitch('bobRoss') the parameter val gets the value of 'bobRoss'
Gebre Mesquitta
@MtZionCode
Apr 18 2017 01:25
@revisualize hmmm
Joseph
@revisualize
Apr 18 2017 01:26
@MtZionCode When you do a function call caseInSwitch('whateverYouWantInThisSpot') the parameter val gets the value of 'whateverYouWantInThisSpot'
mateo
@mateospetcare
Apr 18 2017 01:26
in repl.li I get this function to work for numbers up to 29 however in freecodecamp it does not work. I even changed the quotes to double quotes.
var roman = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X'];
var number = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; 

var romanNum ="";

function convertToRoman(num) {
 if(number.indexOf(num) !== -1 && num <= 10){
  romanNum += roman[number.indexOf(num)];
  reCurseNum = number[number.indexOf(num)] - num;
   convertToRoman(reCurseNum)
 } else if(num > 10) {
   var largestNumber = Math.max.apply( Math, number);
    romanNum +=  roman[number.indexOf(largestNumber)]; 
    reCurseNum = num - largestNumber;
    convertToRoman(reCurseNum)
 } else {

 }
  return romanNum;
}
Joseph
@revisualize
Apr 18 2017 01:26
@MtZionCode So, from there.. you can use the parameter val inside of your function just like you'd use a variable.
Moisés Man
@moigithub
Apr 18 2017 01:26
@mateospetcare use local variables....
FCC test call ur function multiple times, if u have global, they wont reset on each call.. keeping its previous values
Joseph
@revisualize
Apr 18 2017 01:27
@MtZionCode Make sense so far?
@MtZionCode The parameter holds the value of the argument that is passed from the function call.
Gebre Mesquitta
@MtZionCode
Apr 18 2017 01:27
@revisualize yeah it does! So should I leave the brackets empty?
Joseph
@revisualize
Apr 18 2017 01:28
@MtZionCode What "brackets"?
Gebre Mesquitta
@MtZionCode
Apr 18 2017 01:29
@revisualize the parenteses I meant...the parentheses that comes after switch...example: "switch ()"
Joseph
@revisualize
Apr 18 2017 01:29
@MtZionCode No you need to put a value in the switch ()
@MtZionCode You have to pass a value to the switch so that It will know which case to look for.
Gebre Mesquitta
@MtZionCode
Apr 18 2017 01:30
@revisualize ok...thanks! Let me figure the rest out
CamperBot
@camperbot
Apr 18 2017 01:30
mtzioncode sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3767 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Apr 18 2017 01:30
@MtZionCode Okay.
mateo
@mateospetcare
Apr 18 2017 01:30
@moigithub i'll give it a shot. thanks!
CamperBot
@camperbot
Apr 18 2017 01:30
mateospetcare sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3120 | @moigithub |http://www.freecodecamp.com/moigithub
Nicholas Johnson
@newplasticideas
Apr 18 2017 01:34
any of you guys having trouble accessing codepen right now?
appears to be down on my end in AUS
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 01:35
@newplasticideas yeah
loaded now though
well not quite
anthonygallina1
@anthonygallina1
Apr 18 2017 01:37
@newplasticideas up here calif us
Joseph
@revisualize
Apr 18 2017 01:41
@MtZionCode Solve it?
barki mustapha
@barkinet
Apr 18 2017 01:48
json.forEach(function(val) {
var keys = Object.keys(val);
html += "<div class = 'cat'>";
keys.forEach(function(key) {
html += "<strong>" + key + "</strong>: " + val[key] + "<br>";
});
html += "</div><br>";
});

<script>
$(document).ready(function() {

$("#getMessage").on("click", function() {
   $.getJSON("/json/cats.json", function(json) {

var html = "";
// Only change code below this line.
json.forEach(function(val) {
var keys = Object.keys(val);
html += "<div class = 'cat'>";
keys.forEach(function(key) {
html += "<strong>" + key + "</strong>: " + val[key] + "<br>";
});
html += "</div><br>";
});


// Only change code above this line.

     $(".message").html(html);

   });
});
});
</script>

<div class="container-fluid">
<div class = "row text-center">
<h2>Cat Photo Finder</h2>
</div>
<div class = "row text-center">
<div class = "col-xs-12 well message">
The message will go here
</div>
</div>
<div class = "row text-center">
<div class = "col-xs-12">
<button id = "getMessage" class = "btn btn-primary">
Get Message
</button>
</div>
</div>
</div>

TheTaxmt
@TheTaxmt
Apr 18 2017 02:00
Anyone else having issues with parts of code being returned as not a function? Example I'm having: exampleVar.shift() is being returned as not a function
Coy Sanders
@coymeetsworld
Apr 18 2017 02:01
@TheTaxmt what is exampleVar? Need some context there
shift() is an array function, FYI
Gabriel Rodriguez
@grodriguez330
Apr 18 2017 02:02

hey guys im stuck on this isLess Function. this is what i have:
function isLess(a, b) {
// Fix this code
if (a < b) {
return a < b ;
}

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

TheTaxmt
@TheTaxmt
Apr 18 2017 02:02
I'm trying to do the nextInLine queue lesson where you have to return the element removed by .shift but each time I try to use it it shows up as not a function
Gabriel Rodriguez
@grodriguez330
Apr 18 2017 02:02
its supposed to return true and does for 10,15 but when you change the numbers to 15,10 it doesnt return false. idk what im doing wrong
TheTaxmt
@TheTaxmt
Apr 18 2017 02:03
wait if it's an array function do I have to toss the brackets on what I was trying to .shift
Coy Sanders
@coymeetsworld
Apr 18 2017 02:03
@TheTaxmt again, need more context. I don't know what exampleVar is. Can you show your code?
TheTaxmt
@TheTaxmt
Apr 18 2017 02:04
function nextInLine(arr, item) {
// Your code here
var stepOne=arr.push(item);
var removedFromArr=stepOne.shift();
return removedFromArr; // Change this line
}
Coy Sanders
@coymeetsworld
Apr 18 2017 02:05
arr.push() doesn't return an array
it returns a number, the size of the array after the push
number is a primitive, it has no functions
I can't run 5.shift(), or 5.toString(), etc
you need to shift the array
TheTaxmt
@TheTaxmt
Apr 18 2017 02:07
I think I gotcha
Yep I got it. Thanks for that, didn't realize that was what .push returns
yayoamigo
@yayoamigo
Apr 18 2017 02:11
I created a youtube channel about my freecodecamp journey :) if anyone could subscribe that would be awesome https://www.youtube.com/watch?v=JW56Q-akvGw
Joseph
@revisualize
Apr 18 2017 02:15
@yayoamigo Your title is incorrect
@yayoamigo Java is not the same as JavaScript
@yayoamigo You can also cut out the new variable declaration and just return the str.split('').reverse().join('');
LeSean Johnson
@leseanbiz
Apr 18 2017 02:21
Is it looked down upon to use css/bootstrap templates for things like quote generator, local weather, & beyond?
yayoamigo
@yayoamigo
Apr 18 2017 02:23
@revisualize but thats no fun , variables are cool :)
c0d0er
@c0d0er
Apr 18 2017 02:23
does anybody know where the following code has problem? this is from http://beta.freecodecamp.com/en/challenges/es6/understand-the-differences-between-import-and-require
import {capitalizeString} from 'string_functions';
capitalizeString("hello!");
Joseph
@revisualize
Apr 18 2017 02:24
@yayoamigo But, still Java is not JavaScript. you should correct that.
David Miller
@DavidMillerFL
Apr 18 2017 02:26

OKAY so I just accidentally solved "Access MultiDimensional Arrays With Indexes”

I have no idea why this worked, can somebody please explain to me?

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

// Only change code below this line.
var myData = myArray[2][1];
MiguelM47
@MiguelM47
Apr 18 2017 02:26
I enter the values in the golfScore (5, 9) but it does not show "Go Home!". What am I doing incorrectly?
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes === 1) {
    return "Hole-in-one!";
  } else if (strokes <= par -2) {
    return "Eagle";
  } else if (strokes === par -1) {
    return "Birdie";
  } else if (strokes === par) {
    return "Par";
  } else if (strokes === par +1) {
    return "Bogey";
  } else if (strokes === par +2) {
    return "Double Bogey";
  } else if (strokes === par +3) {
    return "Go Home!";
  }
  // Only change code above this line
}
// Change these values to test
golfScore(5, 9);
Joseph
@revisualize
Apr 18 2017 02:26
@DavidMillerFL Sure.
David Miller
@DavidMillerFL
Apr 18 2017 02:27
I was supposed to make var myData = 8… and apparently I did, but I have no idea how it worked!
My face was so dumb founded when it said I completed the challenge
Joseph
@revisualize
Apr 18 2017 02:28
@DavidMillerFL
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
myArray[0] is [1,2,3]
myArray[0][0] is 1
myArray[0][1] is 2
myArray[1] is [4,5,6]
myArray[1][1] is 5
myArray[2] is [7,8,9]
myArray[2][0] is 7
myArray[3] is [[10,11,12], 13, 14]
myArray[3][0] is [10,11,12]
myArray[3][0][1] is 11
myArray[3][1] is 13
anderson
@anderson2825
Apr 18 2017 02:29
accessing35.png
Why will show this?
yayoamigo
@yayoamigo
Apr 18 2017 02:29
@revisualize Done :)
David Miller
@DavidMillerFL
Apr 18 2017 02:29

o.O Jesis christ, thank you x 1000 @revisualize

But how can I ‘’see’’ that also?

CamperBot
@camperbot
Apr 18 2017 02:29
davidmillerfl sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3768 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Apr 18 2017 02:30
@DavidMillerFL Practice makes permanent
@DavidMillerFL It helps that I wrote ...
Marlon
@mblmarlon
Apr 18 2017 02:31
has anybody done the MadLip ?

@mblmarlon Madlib.
String Concatenation with Variables.
Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an 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.

anderson
@anderson2825
Apr 18 2017 02:32
who tell me that problem?? thanks!
LeSean Johnson
@leseanbiz
Apr 18 2017 02:32
Is it looked down upon to use css/bootstrap templates for things like quote generator, local weather, & beyond?
john94
@lpy1994
Apr 18 2017 02:32
function towerBuilder(nFloors) {
  // build here
  var arr = [];
  for(var star = "*"; star.length <= nFloors; star += "*"){
    arr.push(star);
  }
  return arr;
}
console.log(towerBuilder(3));

/*å\
challenge: build tower.

1. find the right order to producing stars.
2. how to plug in spaces into each each element.

for example, a tower of 3 floors looks like below

[
  '  *  ', 
  ' *** ', 
  '*****'
]
and a tower of 6 floors looks like below

[
  '     *     ', 
  '    ***    ', 
  '   *****   ', 
  '  *******  ', 
  ' ********* ', 
  '***********'
]

*/
I am stucked
David Miller
@DavidMillerFL
Apr 18 2017 02:33
@revisualize Hm, I have no idea what this is here, but I’ll try to read it. Thank you again.
CamperBot
@camperbot
Apr 18 2017 02:33
davidmillerfl sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: davidmillerfl already gave revisualize points
TinCan-Assassin
@TinCan-Assassin
Apr 18 2017 02:33
My Icon Switcher function isn't working in my weather app. What am I doing wrong. iconImg is defined as an array of objects I made, and icon is defined (and logging) from the weather app.
function iconSwitcher() {
    //console.log(iconImg);
    //console.log(icon);

    for (var i = 0; i < iconImg.length; i++) {
        if (icon == iconImg[i].icon) {
            var image = iconImg[i].icon;
            $(".img").html("<img src='" + image + "' title= '" + icon + "' />");
            console.log(image);
        }

    }
}
Joseph
@revisualize
Apr 18 2017 02:33
@DavidMillerFL You just need to read the first 36 lines of that Gist.
David Miller
@DavidMillerFL
Apr 18 2017 02:33
Gist?
Joseph
@revisualize
Apr 18 2017 02:34
@leseanbiz What? You're not required to use Bootstrap for the challenges.
@DavidMillerFL gist.github.com
@DavidMillerFL That link I posted is a Gist.
LeSean Johnson
@leseanbiz
Apr 18 2017 02:34
yeah, but it’s easier to me than straight css to make it look decent
Joseph
@revisualize
Apr 18 2017 02:35
Okay.
@leseanbiz Then use it if you want.
LeSean Johnson
@leseanbiz
Apr 18 2017 02:35
right, my question is….is it looked down upon to use templates for getting those things done?
Joseph
@revisualize
Apr 18 2017 02:35
@leseanbiz With projects you can do whatever you want. You just have to meet the check boxes.
@leseanbiz No.
@leseanbiz It doesn't matter.
LeSean Johnson
@leseanbiz
Apr 18 2017 02:35
ok, thanks! @revisualize
CamperBot
@camperbot
Apr 18 2017 02:35
leseanbiz sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3769 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Apr 18 2017 02:36
@leseanbiz You can do whatever you want.
@leseanbiz It's your project. You make it as awesome as you want. However, you want.
:muscle:s & :shit:
barki mustapha
@barkinet
Apr 18 2017 02:36

// If relevant, paste all of your challenge code in here
var max=0;
var min=0;
var sum=0;
function sumAll(arr) {
if(arr[0]>arr[1]){
max=arr[0];
min=arr[1];
}
else{
max=arr[1];
min=arr[0];
}
sum+=((max-min+1)*(min+max))/2;
return sum;
}

sumAll([10,5]); help

LeSean Johnson
@leseanbiz
Apr 18 2017 02:36
…..arms & poop?
Joseph
@revisualize
Apr 18 2017 02:37
@leseanbiz muscles and shit
LeSean Johnson
@leseanbiz
Apr 18 2017 02:37
word!
TinCan-Assassin
@TinCan-Assassin
Apr 18 2017 02:37
Did anyone see my question above?
David Miller
@DavidMillerFL
Apr 18 2017 02:38
Personally I prefer not using bootstrap and stuff. It overrides too many things. But for the portfolio challenge I went ahead and tried to implement it into my page.
Vicky Lai
@vickylai
Apr 18 2017 02:38

So my code is:

$(document).ready(function() {
    var offset = +8;
    var d = new Date()
    var hour = d.getHours
    var min = d.getMinutes

    console.log(hour, min);
})

Console log is:

function getHours() function getMinutes()

What am I not doing? I tried .toString but that didn't work.

David Miller
@DavidMillerFL
Apr 18 2017 02:38
I could just be not understanding… but I don’t like my buttons and things all looking like those found on other sites.
Joseph
@revisualize
Apr 18 2017 02:40
@TinCan-Assassin I saw your question above.
TinCan-Assassin
@TinCan-Assassin
Apr 18 2017 02:40
@revisualize Cool, can you help?
Joseph
@revisualize
Apr 18 2017 02:41
@TinCan-Assassin I have no idea.
TinCan-Assassin
@TinCan-Assassin
Apr 18 2017 02:41
Well, nuts.
barki mustapha
@barkinet
Apr 18 2017 02:42

function sumAll(arr) {
var max = Math.max(arr[0], arr[1]);
var min = Math.min(arr[0], arr[1]);

return (max + min) * (max - min + 1) / 2;
}

sumAll([1, 4]);

john94
@lpy1994
Apr 18 2017 02:42
function towerBuilder(nFloors) {
  // build here
  var arr = [];
  for(var star = "*"; star.length <= nFloors; star += "*"){
    arr.push(star);
  }
  return arr;
}
console.log(towerBuilder(3));

/*å\
challenge: build tower.

1. find the right order to producing stars.
2. how to plug in spaces into each each element.

for example, a tower of 3 floors looks like below

[
  '  *  ', 
  ' *** ', 
  '*****'
]
and a tower of 6 floors looks like below

[
  '     *     ', 
  '    ***    ', 
  '   *****   ', 
  '  *******  ', 
  ' ********* ', 
  '***********'
]

*/
can anybody help me this
building a triangle with JS
a challenge from codewar.com
Vikram
@vikramnr
Apr 18 2017 02:43
@khaduch Thanks
CamperBot
@camperbot
Apr 18 2017 02:43
vikramnr sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2748 | @khaduch |http://www.freecodecamp.com/khaduch
Vicky Lai
@vickylai
Apr 18 2017 02:43
@TinCan-Assassin It's possible .img as a class is being used elsewhere. Try a unique id instead... '#iconimg' for example
Looks fine otherwise...
TinCan-Assassin
@TinCan-Assassin
Apr 18 2017 02:48
@vickylaixy Tried that first.
queenoflamps
@queenoflamps
Apr 18 2017 02:51
````

function destroyer(arr) {
  var args = Array.from(arguments);
  function filterMe(value) {
    for (var i = 1; i < args.length; i++) {
        return value !== args[i];
    }
  }
  return args[0].filter(filterMe);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
can anyone help me wit this? I've tried many different approaches but it always only returns with the first value removed
this is seek and destroy no.98 btw
barki mustapha
@barkinet
Apr 18 2017 02:55

function diffArray(arr1, arr2) {
var newArr = [];
arr1.filter(function(x) {
for (var i=0; i<arr1.length; i++) {
if (arr2.indexOf(arr1[i]) < 0) {
newArr.push(arr1[i]);
}
}
});

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

console.log(newArr);
return newArr;

}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);

HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 02:56
@queenoflamps you need to return false inside the loop and true outside it
queenoflamps
@queenoflamps
Apr 18 2017 02:57
ok
bstahler123
@bstahler123
Apr 18 2017 02:57
@HeebieGeeBee https://infinite-retreat-23791.herokuapp.com/project.html . check out my first app.
It’s a column/row system?
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 02:58
@bstahler123 looks good
queenoflamps
@queenoflamps
Apr 18 2017 02:59
@HeebieGeeBee I'm confused as what you mean to return true outside the loop
bstahler123
@bstahler123
Apr 18 2017 02:59
@HeebieGeeBee did it work?
queenoflamps
@queenoflamps
Apr 18 2017 02:59
do i create another loop to return true
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 02:59
@bstahler123 seemed to
@queenoflamps well if you find that element in the array matches one of the args values
you want it removed from the array
so returning false
queenoflamps
@queenoflamps
Apr 18 2017 03:00
ok
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 03:00
but if it doesnt match you want the loop to continues
queenoflamps
@queenoflamps
Apr 18 2017 03:01
@HeebieGeeBee thanks i think i get it now
CamperBot
@camperbot
Apr 18 2017 03:01
queenoflamps sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1371 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
c0d0er
@c0d0er
Apr 18 2017 03:01
is my code correct for this challenge http://beta.freecodecamp.com/en/challenges/es6/use-export-to-reuse-a-code-block?
challenge: Below are two variables that I want to make available for other files to use. Utilizing the first way I demonstrated export, export the two variables.
const foo = "bar";
const boo = "far";
export {foo, boo};
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 03:02
@DavidMillerFL why are oyu looking at a c# page
for javascript
Alexander Køpke
@alexanderkopke
Apr 18 2017 03:02
@queenoflamps inside a function once you make a return the function is done and so the loop only gets to run once when you return on every iteration.
David Miller
@DavidMillerFL
Apr 18 2017 03:03
Hmm I google searched “Understanding multidimensional arrays” and that came up, didn’t realize what I was looking at was for C#, but funny enough it gave a bit more context as to how to use MDA’s I think
@HeebieGeeBee
queenoflamps
@queenoflamps
Apr 18 2017 03:03
@alexanderkopke i thought so but i was unsure about fixing it
David Miller
@DavidMillerFL
Apr 18 2017 03:04
is it based on a column / row type of system?
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 03:04
not really
Alexander Køpke
@alexanderkopke
Apr 18 2017 03:04
@queenoflamps you can use an if statement to check if the conditions are right and then return if they are
David Miller
@DavidMillerFL
Apr 18 2017 03:05
Hm.. okay. Then I still don’t fully grasp why, for example, [2][1] gives a value of 8 in my problem @HeebieGeeBee
queenoflamps
@queenoflamps
Apr 18 2017 03:05
ok
@alexanderkopke thanks
CamperBot
@camperbot
Apr 18 2017 03:06
queenoflamps sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1319 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 03:06
nameofthemainarray[initialelement][elementofinitialelement]
@DavidMillerFL
so if initialelement is an array of values you can access them using an index value
maybe if you think of an array as a box might be easier
David Miller
@DavidMillerFL
Apr 18 2017 03:09
omg I see it now… 0, 1, 2… 0, 1. There’s like… layers.
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 03:09
so if a box just has items in it then you can just pick out the element
Burak
@BurakAy
Apr 18 2017 03:09
@DavidMillerFL the [2] is the array with the 2nd index (which is the third array since it's 0 based) and the [1] is the second value in the [2] array
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 03:10
but if one of those elements in a box is another box containing more elements
you have to look in that box aswell to access what that box inside the bigger box holds
c0d0er
@c0d0er
Apr 18 2017 03:10
is my code correct for this challenge http://beta.freecodecamp.com/en/challenges/es6/use--to-import-everything-from-a-file?
challenge: The code below requires the contents of a file, "capitalize_strings", found in the same directory as it, imported. Add the appropriate import * statement to the top of the file, using the object provided.
import * as myStringModule from "capitalize_strings";
myStringModule.capitalize("foo");
myStringModule.lowercase("Foo");
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 03:11
but that smaller box could contain another box aswell
Joseph
@revisualize
Apr 18 2017 03:11
@c0d0er You know the Beta is full of bugs. I haven't worked through the beta.
FullStackC
@FullStackCassim
Apr 18 2017 03:11
Hey guys new to JavaScript. Stuck on Assign the contents of a to variable b.
David Miller
@DavidMillerFL
Apr 18 2017 03:11
I see. @HeebieGeeBee Thank you again, you’re awesome for helping so many people on here. I’m going to tinker with the arrays a bit more and see if I can select more things (on purpose) this time.
CamperBot
@camperbot
Apr 18 2017 03:11
davidmillerfl sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1372 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Burak
@BurakAy
Apr 18 2017 03:11
@DavidMillerFL since it's 0 based indexing you start counting with 0
Joseph
@revisualize
Apr 18 2017 03:12
@DavidMillerFL Again:
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
myArray[0] is [1,2,3]
myArray[0][0] is 1
myArray[0][1] is 2
myArray[1] is [4,5,6]
myArray[1][1] is 5
myArray[2] is [7,8,9]
myArray[2][0] is 7
myArray[3] is [[10,11,12], 13, 14]
myArray[3][0] is [10,11,12]
myArray[3][0][1] is 11
myArray[3][1] is 13
c0d0er
@c0d0er
Apr 18 2017 03:12
@revisualize is my code correct?
Burak
@BurakAy
Apr 18 2017 03:12
so 0 is the 1st element, 1 is the 2nd element, 2 is the 3rd element etc...
@DavidMillerFL
Joseph
@revisualize
Apr 18 2017 03:12
@c0d0er No idea. I haven't worked through the beta.
David Miller
@DavidMillerFL
Apr 18 2017 03:12
@BurakAy @revisualize Thank you guys. Reading now.
CamperBot
@camperbot
Apr 18 2017 03:12
davidmillerfl sends brownie points to @burakay and @revisualize :sparkles: :thumbsup: :sparkles:
:warning: davidmillerfl already gave revisualize points
:cookie: 306 | @burakay |http://www.freecodecamp.com/burakay
c0d0er
@c0d0er
Apr 18 2017 03:13
@revisualize ok, thank you for your time
CamperBot
@camperbot
Apr 18 2017 03:13
c0d0er sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3770 | @revisualize |http://www.freecodecamp.com/revisualize
Burak
@BurakAy
Apr 18 2017 03:15
@DavidMillerFL no problem, thanks
CamperBot
@camperbot
Apr 18 2017 03:15
burakay sends brownie points to @davidmillerfl :sparkles: :thumbsup: :sparkles:
:cookie: 164 | @davidmillerfl |http://www.freecodecamp.com/davidmillerfl
barki mustapha
@barkinet
Apr 18 2017 03:20

function numToRomanNumeralLetter(num) {

switch(num) {
case 1:
return "I";
case 4:
return "IV";
case 5:
return "V";
case 6:
return "VI";
case 9:
return "IX";
case 10:
return "X";
case 40:
return "XL";
case 50:
return "L";
case 90:
return "XC";
case 100:
return "C";
case 400:
return "CD";
case 500:
return "D";
case 900:
return "CM";
case 1000:
return "M";
}
}

function convertToRoman(num) {

var romanNumeral = "";

console.log("Num originally is: " + num);

do {

if (num>=1000) {

  num -= 1000;
  romanNumeral += numToRomanNumeralLetter(1000);
  console.log("Num is now 1000 less: "+ num); 

} else if (num>=900) {

  num -= 900;
  romanNumeral += numToRomanNumeralLetter(900);
  console.log("Num is now 900 less: "+ num);

} else if (num>=500) {

  num -= 500;
  romanNumeral += numToRomanNumeralLetter(500);
  console.log("Num is now 500 less: "+ num);

} else if (num>=400) {

  num -= 400;
  romanNumeral += numToRomanNumeralLetter(400);
  console.log("Num is now 400 less: "+ num);

} else if (num>=100) {

  num -= 100;
  romanNumeral += numToRomanNumeralLetter(100);
  console.log("Num is now 100 less: "+ num);

} else if (num>=90) {

  num -= 90;
  romanNumeral += numToRomanNumeralLetter(90);
  console.log("Num is now 100 less: "+ num);

} else if (num>=50) {

  num -= 50;
  romanNumeral += numToRomanNumeralLetter(50);
  console.log("Num is now 50 less: "+ num);

} else if (num>=40) {

  num -= 40;
  romanNumeral += numToRomanNumeralLetter(40);
  console.log("Num is now 40 less: "+ num);

} else if (num>=10) {

  num -= 10;
  romanNumeral += numToRomanNumeralLetter(10);
  console.log("Num is now 10 less: "+ num);

} else if (num>=5) {

  if (num === 9) {

    num -= 9;
    romanNumeral += numToRomanNumeralLetter(9);
    console.log("Num is now 9 less: "+ num);

  } else if (num === 6) {

    num -= 6;
    romanNumeral += numToRomanNumeralLetter(6);
    console.log("Num is now 6 less: "+ num);

  } else {

    num -= 5;
    romanNumeral += numToRomanNumeralLetter(5);
    console.log("Num is now 5 less: "+ num);

  }

} else if (num>=1) {

  if (num === 4) {

    num -= 4;
    romanNumeral += numToRomanNumeralLetter(4);
    console.log("Num is now 4 less: "+ num);

  } else {

    num -= 1;
    romanNumeral += numToRomanNumeralLetter(1);
    console.log("Num is now 1 less: "+ num);

  }
} 

} while (num >= 1)

console.log("Roman numeral is: " +romanNumeral);
return romanNumeral;

}

convertToRoman(400);

David Miller
@DavidMillerFL
Apr 18 2017 03:20
var myArray = 
  [ [1,2,3],  <— 0th box
    [4,5,6], <— 1st box
    [7,8,9], <— 2nd box
    [<— 3rd box

           [10,11,12], <— 4th box 

 13, 14]  <— Also 3rd box?
];
So is this…. accurate? I just sort of re-organized the spacing and lines to ‘see it’ better.
devonwlkns86
@devonwlkns86
Apr 18 2017 03:20
I don't entirely understand what i'm missing here?...help!
var myStr = "FirstLine\n\\"SecondLine\"\\rThirdLine.";
Joseph
@revisualize
Apr 18 2017 03:21
@devonwlkns86 You have too many "s
@devonwlkns86 You're escaping "s inside of your string. And that is not a requirement of the lesson.
@DavidMillerFL That logic isn't quite correct.
@DavidMillerFL But, sure.
@DavidMillerFL Your 4th box is actually [3][0]
David Miller
@DavidMillerFL
Apr 18 2017 03:24
hmm let me see what the console says @revisualize
Joseph
@revisualize
Apr 18 2017 03:24
@DavidMillerFL Okay. What does it say?
David Miller
@DavidMillerFL
Apr 18 2017 03:25
You’re right. It’s [3][0]… but then, where I’m pointing to and labled ‘'3rd box’’… what is that? It’s nested, so it kind of is a curveball to me.
@revisualize ^
Joseph
@revisualize
Apr 18 2017 03:25
@DavidMillerFL Let me ask this.
David Miller
@DavidMillerFL
Apr 18 2017 03:26
Sure
Joseph
@revisualize
Apr 18 2017 03:26
@DavidMillerFL var arr = [ ["b1" , "d1"] , ["f2" , "h2"] , ["j3" , "l3"] ];
What is arr[2]?
David Miller
@DavidMillerFL
Apr 18 2017 03:27
((Forgive my lack of understanding. I only just learned what arrays are today. Thank you everyone for your patience and help))
Looking, one sec @revisualize
Well now wait a second...
Todd Abraham
@toddabraham
Apr 18 2017 03:29
Hello FCCers. I need some help with the Basic JavaScript Course exercise Stand in Line. I’ve watched one Coding Tutorials 360 YouTube video work through, but still do not understand how he came to the end result.
David Miller
@DavidMillerFL
Apr 18 2017 03:29
Is [2] the entire ["b1" , "d1"] , ["f2" , "h2"] , ["j3" , "l3”]
?
Joseph
@revisualize
Apr 18 2017 03:30
@DavidMillerFL Nope.
David Miller
@DavidMillerFL
Apr 18 2017 03:30
If it’s not, then I’m going to say arr[2] is j3, l3
Todd Abraham
@toddabraham
Apr 18 2017 03:30

Would anyone mind helping me understand what’s going on here? ```
function nextInLine(arr, item) {
// Your code here
arr.push(item);
var item2 = arr.shift();
return item2; // Change this line
}

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

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

Joseph
@revisualize
Apr 18 2017 03:30
@DavidMillerFL That is also technically incorrect.
David Miller
@DavidMillerFL
Apr 18 2017 03:30
Hm… well crap!
Joseph
@revisualize
Apr 18 2017 03:30
@DavidMillerFL Look...
Todd Abraham
@toddabraham
Apr 18 2017 03:31
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  var item2 = arr.shift();
  return item2;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Alexander Køpke
@alexanderkopke
Apr 18 2017 03:31
@queenoflamps args is all the data passed in. [[1, 2, 3, 1, 2, 3], 2, 3] if you shifted args that would leave you with [2, 3]. arr btw is the first argument passed into the the function [1, 2, 3, 1, 2, 3]. <--- arr. it is this arr that we want to filter through because it is the only argument that has the parts we want . Also consider reading up on the indexOf method.
Gulsvi
@gulsvi
Apr 18 2017 03:31
@toddabraham arr.shift() removes the first item AND also tells you what was removed if you assign it to a value or return it
arr.push(item) adds an item to the end of an array
Joseph
@revisualize
Apr 18 2017 03:31
@DavidMillerFL var arr = [ ["b1" , "d1"] , ["f2" , "h2"] , ["j3" , "l3"] ];
What is arr[2]?
arr[2] is the array that contains two elements: "j3" and "l3" ... ["j3" , "l3"]
David Miller
@DavidMillerFL
Apr 18 2017 03:32
Wait that’s what I said lol, j3, l3.
Gulsvi
@gulsvi
Apr 18 2017 03:32
image.png

Example of push/unshift/shift/pop:

var arr = [1,2,3];
return arr.push(9); // returns 4, the new length. Now your array is [1,2,3,9]
return arr.unshift(8); // returns 5, the new length. Now your array is [8,1,2,3,9]
return arr.shift(); // returns 8, the item removed. Now your array is [1,2,3,9]
return arr.pop(); // returns 9, the item removed. Now your array is [1,2,3]

@toddabraham

David Miller
@DavidMillerFL
Apr 18 2017 03:33
Wait that’s a 1 not an l
Todd Abraham
@toddabraham
Apr 18 2017 03:33
@SkyCoder01 Thanks for that. Where I got lost is in understanding how the guy in the YouTube video knew to create - var item2 = arr.shift();
CamperBot
@camperbot
Apr 18 2017 03:33
toddabraham sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:star2: 1075 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Alexander Køpke
@alexanderkopke
Apr 18 2017 03:33
@toddabraham shift is a method that returns what has been removed which can be stored in a variable if you liike. var removed = [1,2,3].shift(); shift removes 1 and stores it in the removed variable.
patrickjbritton
@patrickjbritton
Apr 18 2017 03:33

ok.. so.. this remainder thing is confusing me. How am I supposed to write it? "Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator."

// Only change code below this line

var remainder;

Joseph
@revisualize
Apr 18 2017 03:34
@DavidMillerFL But, it isn't just j3, l3.
@DavidMillerFL It is an array.
@DavidMillerFL It's an array that contains two element.
@DavidMillerFL Those two elements are "j3" & "l3".
@DavidMillerFL It may seem like it is thin slicing down to the verbiage. But, it is critical.
David Miller
@DavidMillerFL
Apr 18 2017 03:36
hm… I can see how there’s a difference. It’s kind of like picking an entire div vs picking out an element nested inside of it.. at least in my mind that’s kind of how it sounds.
Joseph
@revisualize
Apr 18 2017 03:37
@DavidMillerFL Because when you do something like this:
var arr = [ [ "a1" ] , [ "b2" , "c2" ] , [ "d3" , "e3" , "f3" ] , [ [ "g4" , "h4" ] , "i4" , "k4" ] ]
@DavidMillerFL Then when I ask. What is arr[3]
Alexander Køpke
@alexanderkopke
Apr 18 2017 03:37
it is kinda like you want your groceries with or without a bag. It makes a big difference
David Miller
@DavidMillerFL
Apr 18 2017 03:37

it is kinda like you want your groceries with or without a bag. It makes a big difference

I like that! @alexanderkopke

patrickjbritton
@patrickjbritton
Apr 18 2017 03:38
oo I figured out I feel silly lol
David Miller
@DavidMillerFL
Apr 18 2017 03:39

[ [ "g4" , "h4" ] , "i4" , "k4" ] ]

or

[ "g4" , "h4" ] , "i4" , "k4” ]?

@revisualize

Alexander Køpke
@alexanderkopke
Apr 18 2017 03:39
@patrickjbritton that is the feeling of getting smarter! :)
Joseph
@revisualize
Apr 18 2017 03:40
@DavidMillerFL arr[3] is an array that contains 3 elements. The 0 index in the array is an array that contains two elements, "g4" & "h4" ([ "g4" , "h4" ]). The 1 index in arr[3] is a string value of "i4" and the 2 index in arr[3] is also a string value of "k4" ... The whole arr[3] is the value of [ [ "g4" , "h4" ] , "i4" , "k4" ]
@DavidMillerFL Make sense?
David Miller
@DavidMillerFL
Apr 18 2017 03:44
Trying to make it make sense. @revisualize - The way you’ve got arr3 set up just completely screws with my brain lol.
Joseph
@revisualize
Apr 18 2017 03:44
@DavidMillerFL It's supposed to.
David Miller
@DavidMillerFL
Apr 18 2017 03:44
the array in an array in an array. I get a little lost
Joseph
@revisualize
Apr 18 2017 03:44
@DavidMillerFL That's what you should be learning.
David Miller
@DavidMillerFL
Apr 18 2017 03:45
I’m trying, I don’t want to move forward on FCC until I familiarize myself with this.
barki mustapha
@barkinet
Apr 18 2017 03:45

function whatIsInAName(collection, source) {
var keys = Object.keys(source);
var arr = collection.filter(function(obj){
for(var i = 0; i < keys.length; ++i)
if(obj.hasOwnProperty(keys[i]) && obj[keys[i]] === source[keys[i]] && i == keys.length - 1)
return true;
});
return arr;
}

whatIsInAName([{"b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });

David Miller
@DavidMillerFL
Apr 18 2017 03:55
I want to ‘’unwrap’’ this. Is that the wrong way of thinking?
var arr = [
[ "a1" ] ,
[ "b2" , "c2" ] ,
[ "d3" , "e3" , "f3" ] ,
[ [ "g4" , "h4" ] ,"i4" , "k4" ] ] <—— Here’s where it get’s all screwy. All these extra brackets. It becomes difficult to tell what elements are part of which arrays.
One thing I’m a bit stuck by is that they seem to be able to ‘’share’’ closing brackets if I’m not mistaken.
Joseph
@revisualize
Apr 18 2017 03:58
var arr = [ 
             [ "a1" ] ,
             [ "b2" , "c2" ] , 
             [ "d3" , "e3" , "f3" ] , 
             [ [ "g4" , "h4" ] ,"i4" , "k4" ]  
           ]
var arr = [ 
             [ "a1" ] ,
             [ "b2" , "c2" ] , 
             [ "d3" , "e3" , "f3" ] , 
             [ 
                [ "g4" , "h4" ] ,
                "i4" , 
                "k4" 
             ]  
           ]
var arr = [          // this is where the parent array starts.
             [ "a1" ] ,        // this is arr[0]
             [ "b2" , "c2" ] , // this is arr[1]
             [ "d3" , "e3" , "f3" ] ,   // this is arr[2]
             [                       // this is where arr[3] starts
                [ "g4" , "h4" ] ,   // this is arr[3][0]
                "i4" ,             // this is arr[3][1]
                "k4"              // this is arr[3][2]
             ]                   // this is where arr[3] ends
           ];         // This is where the parent array ends
David Miller
@DavidMillerFL
Apr 18 2017 04:03
I hate i4 and k4 in these examples lol, but I can… see it. Kind of.
Ok reading.
Moustapha
@moustaflo
Apr 18 2017 04:04
Probably something wrong in my filterer function
function sumPrimes(num) {
var prims = [2,3,5,7];
var tryi = "";
  var arr = [];
for(i=2; i<num+1; i++){
  arr.push(i);
}
 function filterer(out){
 if(prims.map(function(val){return out % val;}).reduce(function(a,b){return a*b;}) !== 0) {return true;}   
   else{
     return false;
  }
}
  return arr.filter(filterer).reduce(function(a,b){return a+b; });
}

sumPrimes(10);
john94
@lpy1994
Apr 18 2017 04:06
function towerBuilder(nFloors) {
  // build here
  var arr = [];
  var board = "" ;

 for (var line = 0; line < nFloors; line++){

   arr.push("*")
  }
  return arr;
}
console.log(towerBuilder(3));

/*å\
challenge: build tower.

1. find the right order to producing stars.
2. how to plug in spaces into each element.

for example, a tower of 3 floors looks like below

[
  '  *  ', 
  ' *** ', 
  '*****'
]
and a tower of 6 floors looks like below

[
  '     *     ', 
  '    ***    ', 
  '   *****   ', 
  '  *******  ', 
  ' ********* ', 
  '***********'
]

*/
need some help on this build tower challenge
barki mustapha
@barkinet
Apr 18 2017 04:07

function myReplace(str, before, after) {
var strArr = str.split(' ');
var index = strArr.indexOf(before);
var arr1 = strArr.slice(0,index);
arr1.push(after);
var arr2 = strArr.slice(index + 1, strArr.length);
return arr1.concat(arr2).join(' ');
}

myReplace("He is Sleeping on the couch", "Sleeping", "Sitting");

Help
@revisualize can u help
David Miller
@DavidMillerFL
Apr 18 2017 04:09
So if I wanted to select only “e3” in your example, that would be arr[2][1] ?
john94
@lpy1994
Apr 18 2017 04:10
@barkinet what’s wrong
Joseph
@revisualize
Apr 18 2017 04:10

@DavidMillerFL From:

var arr = [ [ "a1" ] , [ "b2" , "c2" ] , [ "d3" , "e3" , "f3" ] , [ [ "g4" , "h4" ] , "i4" , "k4" ] ];

arr[2][1] is the string value of "e3"

David Miller
@DavidMillerFL
Apr 18 2017 04:13

Yes that’s what I meant. Did I ask wrong?

arr[3][1] is the string value of h4, also, right? I’m trying to practice “targeting” or “selecting” certain elements inside of arrays. I actually don’t know how to articulate what it is that I’m asking lol. @revisualize

Joseph
@revisualize
Apr 18 2017 04:13
@DavidMillerFL arr[3][1] is the string value of "i4"
@DavidMillerFL If you want to access the string value of "h4" you need to do arr[3][0][1]
David Miller
@DavidMillerFL
Apr 18 2017 04:15
throws laptop
barki mustapha
@barkinet
Apr 18 2017 04:17
function myReplace(str, before, after) {
var newStr = [];
newStr = str.split(" ");
for(var i = 0; i < newStr.length; i++) {
if(newStr[i] === before) {
newStr.splice(i, 1, after);
}
}
newStr = newStr.join(" ");
return newStr;
}

Search and Replace
Perform a search and replace on the sentence using the arguments provided and return the new sentence.

First argument is the sentence to perform the search and replace on.

Second argument is the word that you will be replacing (before).

Third argument is what you will be replacing the second argument with (after).

NOTE: Preserve the case of the original word when you are replacing it. For example if you mean to replace the word "Book" with the word "dog", it should be replaced as "Dog"

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

Here are some helpful links:

Array.prototype.splice()
String.prototype.replace()
Array.prototype.join()

David Miller
@DavidMillerFL
Apr 18 2017 04:20

Ok I see it! [3][0] selects the entire array of [ "g4" , "h4” ]

and the addition of [1] selects the “h4” inside of [3][0].

Kevin0920
@Kevin0920
Apr 18 2017 04:22
hi anyone can help?

function orderMyLogic(val) {
if (val < 10) {
return "Less than 10";
}
else if (val < 5) {
return "Less than 5";
}
else {
return "Greater than or equal to 10";
}
}

// Change this value to test
orderMyLogic();

David Miller
@DavidMillerFL
Apr 18 2017 04:23
Every time you go another layer in, you need to add another [number]!
Kevin0920
@Kevin0920
Apr 18 2017 04:23
I am not sure what value will fit to this output coming out as return less than 5
Ogundele Olumide
@Lumexralph
Apr 18 2017 04:25
@Kevin0920 (val < 10)condition will not allow val < 5 condition to be executed in your program because val that's less than 5 is also less than 10, maybe you re-arrange the logic of your conditional statements
NMusey
@NMusey
Apr 18 2017 04:26
Can someone help with my code? I've narrowed it down to below line 27:

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 ++;
break;
case 7:
case 8:
case 9:
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count --;
}

var ret = "";

if (count > 0)
{
ret = str(count) + " Hold";
}
else
{
ret = str(count) + " Bet";
}console.log(
return ret;
// Only change code above this line
}

Joseph
@revisualize
Apr 18 2017 04:27
@NMusey count ++; remove the space
@NMusey console.log( remove that
@NMusey str(count) where is your function str?
@NMusey Doing str(count) is a function call to a function name str passing the argument count
Ogundele Olumide
@Lumexralph
Apr 18 2017 04:29
@NMusey str() this is a Python function of coercing value to string, use JS string function
Kevin0920
@Kevin0920
Apr 18 2017 04:30
got thanks
Ogundele Olumide
@Lumexralph
Apr 18 2017 04:30
@Kevin0920 String(count);
intcreate
@intcreate
Apr 18 2017 04:33
can any1 help me with this
function getBiggest(x, y) { if(getBiggest(x > y)) { return x; } else if(x < y) { return y; } else { return x || y; } //x and y are integers. Return the larger integer //if they are the same return either one }
Ogundele Olumide
@Lumexralph
Apr 18 2017 04:34
@intcreate why're you doing this if(getBiggest(x > y) ?
intcreate
@intcreate
Apr 18 2017 04:35
its a problem i need to solve
Ogundele Olumide
@Lumexralph
Apr 18 2017 04:35
@intcreate getBiggest is the name of your function, how do you create an if statement in JS?
intcreate
@intcreate
Apr 18 2017 04:36
if(condition) {
} else {
}
Ogundele Olumide
@Lumexralph
Apr 18 2017 04:36
@intcreate
if(condition) {

      }
@intcreate so what's getBiggest doing there? do you think it should be there?
shajal-kumer
@shajal-kumer
Apr 18 2017 04:37

var a;
var b = 2;

var a = 7;
var b = 7;

In here ,,,a should be assigned to b with =
what's meaning
intcreate
@intcreate
Apr 18 2017 04:37
nvm i got it
Ogundele Olumide
@Lumexralph
Apr 18 2017 04:37
@shajal-kumer you're declaring an already declared variable
john94
@lpy1994
Apr 18 2017 04:38
···
···
for (var i = 1; i < 10; i += 2) {
    for (var k = 0; k < (4 - i / 2); k++) {
        console.log(" ");
    }
    for (var j = 0; j < i; j++) {
        console.log("*");
    }
    console.log("");
}
Ogundele Olumide
@Lumexralph
Apr 18 2017 04:39

@shajal-kumer

var x = 1;
var y;
y = x;

tha's synonymous to what you're trying to do

john94
@lpy1994
Apr 18 2017 04:39
guys how can i return the result in the form of arrays
intcreate
@intcreate
Apr 18 2017 04:39
wo thats a long javascript algorithm
Ogundele Olumide
@Lumexralph
Apr 18 2017 04:40
@lpy1994 create an empty array before the loops and push to it in the loop
john94
@lpy1994
Apr 18 2017 04:40
@Lumexralph tried won’t work
Ogundele Olumide
@Lumexralph
Apr 18 2017 04:41
then simply do console.log([value]); in the loop
shajal-kumer
@shajal-kumer
Apr 18 2017 04:41

// Setup
var a;
var b = 2;

// Only change code below this line

Do not change code above the line
a should have a value of 7
b should have a value of 7
a should be assigned to b with =
How cav i Solve
Ogundele Olumide
@Lumexralph
Apr 18 2017 04:42
@shajal-kumer assign a value of 7, then assign a to b
shajal-kumer
@shajal-kumer
Apr 18 2017 04:43
Thanks @Lumexralph
CamperBot
@camperbot
Apr 18 2017 04:43
shajal-kumer sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1528 | @lumexralph |http://www.freecodecamp.com/lumexralph
Dan North
@almostkewl
Apr 18 2017 04:43
Newbie question, if you guys are just playing around with js and trying to write a program, do you use an editor or just dev tools console?
Joseph
@revisualize
Apr 18 2017 04:44
@almostkewl Depends.
Sandesh Shrestha
@UnovaXan
Apr 18 2017 04:44
@almostkewl you could use jsbin or codepen or just the console. it's a matter of preference
Joseph
@revisualize
Apr 18 2017 04:45
@almostkewl I do a mix of both. I use an editor sometimes. But, because I'm bouncing from workstation to workstation. I tend to just have things on my GitHub.
TylerB72
@TylerB72
Apr 18 2017 04:46
Access the myStorage object and assign the contents of the glove box property to the gloveBoxContents variable. Use bracket notation for properties with a space in their name.
myStorage["glove box"].maps;

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

// Only change code below this line

myStorage["glove box"].maps;

help pls
Sandesh Shrestha
@UnovaXan
Apr 18 2017 04:47
remove the .maps
TylerB72
@TylerB72
Apr 18 2017 04:48
i need to use dot notation as well as bracket notation though
i tried mystorage.maps["glove box"] and that didn't work either
Sandesh Shrestha
@UnovaXan
Apr 18 2017 04:49
can you send me the link to the challenge?
David Miller
@DavidMillerFL
Apr 18 2017 04:49
How the hell do you guys remember all of this? .shift? .pop?
I’m worried I’m going to forget this as soon as I move to the next section.
Ogundele Olumide
@Lumexralph
Apr 18 2017 04:50
@TylerB72 becasue car.inside are nested in the object
Kurt Johnson
@pompan129
Apr 18 2017 04:50
@DavidMillerFL MDN is your friend
David Miller
@DavidMillerFL
Apr 18 2017 04:51
MDN?
Sandesh Shrestha
@UnovaXan
Apr 18 2017 04:51
@TylerB72 var gloveBoxContents = myStorage.car.inside["glove box"];
Ogundele Olumide
@Lumexralph
Apr 18 2017 04:51
@DavidMillerFL the more you code the more you remember some....but I still use the doc most time for more understanding
Sandesh Shrestha
@UnovaXan
Apr 18 2017 04:51
@DavidMillerFL Mozilla Developers Network
TylerB72
@TylerB72
Apr 18 2017 04:51
Dang I didn't even see that. Thanks guys.
Sandesh Shrestha
@UnovaXan
Apr 18 2017 04:53
@DavidMillerFL you can add MDN to your browser search and just do a search everytime you need to check something
no one remembers all that
you just need to have the concept of what can be done to achieve something
David Miller
@DavidMillerFL
Apr 18 2017 04:53
I see, do they make it for Chrome?
Sandesh Shrestha
@UnovaXan
Apr 18 2017 04:54
just add MDN to the end of what ever you're searching for
Kurt Johnson
@pompan129
Apr 18 2017 04:54
@DavidMillerFL just google .shift() js MDN
David Miller
@DavidMillerFL
Apr 18 2017 04:54
@UnovaXan @pompan129 Thanks guys!
CamperBot
@camperbot
Apr 18 2017 04:54
davidmillerfl sends brownie points to @unovaxan and @pompan129 :sparkles: :thumbsup: :sparkles:
:cookie: 240 | @unovaxan |http://www.freecodecamp.com/unovaxan
:cookie: 500 | @pompan129 |http://www.freecodecamp.com/pompan129
Sandesh Shrestha
@UnovaXan
Apr 18 2017 04:55
My first Brownie Points from the chat :D
High Five @pompan129 !!
Kurt Johnson
@pompan129
Apr 18 2017 04:55
thanks @UnovaXan
CamperBot
@camperbot
Apr 18 2017 04:55
pompan129 sends brownie points to @unovaxan :sparkles: :thumbsup: :sparkles:
:cookie: 241 | @unovaxan |http://www.freecodecamp.com/unovaxan
Kurt Johnson
@pompan129
Apr 18 2017 04:56
high 5.
Joseph
@revisualize
Apr 18 2017 04:58
@DavidMillerFL Practice Makes Permanent
patrickjbritton
@patrickjbritton
Apr 18 2017 05:13
Spellung mattirs -_-
Femi Adewuyi
@femi5ezekiel
Apr 18 2017 05:14
please help me with this challenge

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

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

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

bilaal-s
@bilaal-s
Apr 18 2017 05:15
Hello guys, why do I get a 404 with the openweathermap api call?
https://codepen.io/bilaal-s/pen/dWyrgM?editors=1010
Sandesh Shrestha
@UnovaXan
Apr 18 2017 05:15
@femi5ezekiel it should be like this
var fahrenheit = celsius *(9/5) + 32;
you take in the celsius variable as a parameter
multiply by 9/5 and add 32 to it
Yeshu Kochher
@theyeshu
Apr 18 2017 05:17
Hello Everyone! Please have a look at my code and let me know if it's need a better way.
function repeatStringNumTimes(str, num) {
  var newStr = "";

  if (num > 0) {
    for (var i = 0; i < num; i++) {
      newStr += str;
    }
  }
  return newStr;
}

repeatStringNumTimes("abc", 3);
AnthonyYY
@AnthonyYY
Apr 18 2017 05:17
anybody could tell me how to match all non-alphanumeric characters by Regexp
David Miller
@DavidMillerFL
Apr 18 2017 05:17

Create a shopping list in the variable myList. The list should be a multi-dimensional array containing several sub-arrays.

The first element in each sub-array should contain a string with the name of the item. The second element should be a number representing the quantity i.e.

["Chocolate Bar", 15]
There should be at least 5 sub-arrays in the list.

var myList = 
[ "Choclate Bar", 20,
  ["ass", 3,
    ["red", 11,
     ["green", 1,
      ["blue", 14,
       ["Is it working?", 13,]
      ]
     ]
    ]
  ]
];
Sandesh Shrestha
@UnovaXan
Apr 18 2017 05:18
@AnthonyYY I'm at the same problem XD
var re = "[^\w\s]/gi";
David Miller
@DavidMillerFL
Apr 18 2017 05:18
Are those not at least 5 sub arrays?
Sandesh Shrestha
@UnovaXan
Apr 18 2017 05:18
this is the regexp for non-alphanumeric chars
AnthonyYY
@AnthonyYY
Apr 18 2017 05:18
@UnovaXan oh ,thank you
CamperBot
@camperbot
Apr 18 2017 05:18
anthonyyy sends brownie points to @unovaxan :sparkles: :thumbsup: :sparkles:
:cookie: 242 | @unovaxan |http://www.freecodecamp.com/unovaxan
Sandesh Shrestha
@UnovaXan
Apr 18 2017 05:19
@DavidMillerFL You have to end each of them separately
you're nesting them
Markus Kiili
@Masd925
Apr 18 2017 05:19
@DavidMillerFL Like this: var myList = [[...],[...],[...],...];
David Miller
@DavidMillerFL
Apr 18 2017 05:19
@UnovaXan So I want them ‘’side by side’’ so to speak. Siblings, not parent-children
Femi Adewuyi
@femi5ezekiel
Apr 18 2017 05:20
@UnovaXan Thanks a lot. It works.
CamperBot
@camperbot
Apr 18 2017 05:20
femi5ezekiel sends brownie points to @unovaxan :sparkles: :thumbsup: :sparkles:
:cookie: 243 | @unovaxan |http://www.freecodecamp.com/unovaxan
David Miller
@DavidMillerFL
Apr 18 2017 05:20
@UnovaXan Thank you, I’ll try making them siblings now.
CamperBot
@camperbot
Apr 18 2017 05:20
davidmillerfl sends brownie points to @unovaxan :sparkles: :thumbsup: :sparkles:
:warning: davidmillerfl already gave unovaxan points
David Miller
@DavidMillerFL
Apr 18 2017 05:21
It worked!
NMusey
@NMusey
Apr 18 2017 05:24
@revisualize @Lumexralph Thanks. Looks like I'm writing half JS half python
CamperBot
@camperbot
Apr 18 2017 05:24
nmusey sends brownie points to @revisualize and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1529 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 3771 | @revisualize |http://www.freecodecamp.com/revisualize
Henry
@GitHub-Henry
Apr 18 2017 05:29
@bilaal-s if you haven't figured out the 404 here's something that will help you figure it out https://www.youtube.com/watch?v=AXGB4tIRNgM
Shayan
@ShayanS
Apr 18 2017 05:31
I'm having a problem with the following exercise:-
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr

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

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

can anyone assist please?
sudip chhetri
@SudipChhetri
Apr 18 2017 05:34
hey is there anyone to help me solving pomodoro clock
bilaal-s
@bilaal-s
Apr 18 2017 05:38
@GitHub-Henry will give it a look! :)
sudip chhetri
@SudipChhetri
Apr 18 2017 05:39
I dont know how to create minute and time I have no idea about this
Andrew Strong
@bathorystoy
Apr 18 2017 05:40
i understand how remainders work but i can’t work out how to write them
h1tag
@h1tag
Apr 18 2017 05:40
@SudipChhetri check setTimeout() and setInterval() methods
sudip chhetri
@SudipChhetri
Apr 18 2017 05:41
What does it do @fortMaximus
h1tag
@h1tag
Apr 18 2017 05:41
@SudipChhetri read about them
sudip chhetri
@SudipChhetri
Apr 18 2017 05:41
ok thanks @fortMaximus
CamperBot
@camperbot
Apr 18 2017 05:41
sudipchhetri sends brownie points to @fortmaximus :sparkles: :thumbsup: :sparkles:
:cookie: 725 | @fortmaximus |http://www.freecodecamp.com/fortmaximus
h1tag
@h1tag
Apr 18 2017 05:42
@ShayanS why are you calling multiplyAll again inside?
bilaal-s
@bilaal-s
Apr 18 2017 05:43
@GitHub-Henry interesting... it returns an error object,
{error: ["You are not authorized to do what you just did. Contact support@codepen.io"]}
__SharifTarver__
@Sharifdesigns22
Apr 18 2017 05:44

What's wrong with my code? function golfScore(par, strokes) {

if (strokes === 1){

return "Hole-in-one!";

} else if (strokes <= par - 2){
return "Eagle";
} else if (strokes === par - 1) {
return "Birdie";
} else if (strokes === par) {
return "Par";
} else if (strokes === par + 1) {
return "Bogey";
} else if (strokes === par + 2) {
return "Double Bogey";
} else if (strokes >= par + 3) {
return "Go Home";
}
// Only change code above this line
}

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

Golf Code Challenge
help please
Jor
@joreyesl
Apr 18 2017 05:54
@Sharifdesigns22 try refreshing the page
chen_peng
@cp1223420008
Apr 18 2017 05:55
help please
Nicholas Johnson
@newplasticideas
Apr 18 2017 05:56
hi all, still having trouble with this one. I'm trying to write a function that will display my quotes that are over 20 characters in a smaller font to prevent the container div resizing on every click. I've been asking around for ages, haven't found anything that works yet. Here's my codepen! http://codepen.io/newplasticideas/pen/WjebyQ
I've quoted out my attempted function as it's not working.
*commented out
chen_peng
@cp1223420008
Apr 18 2017 05:57

variable @screen-tablet is undefined

.page {

max-width: 728px;

}

}

variable @screen-tablet is undefined
Henry
@GitHub-Henry
Apr 18 2017 05:58
@newplasticideas why not make the display area large enough to hold the largest quote?
h1tag
@h1tag
Apr 18 2017 05:59
@femi5ezekiel
  • first, you should be using the text FirstLine SecondLine ThirdLine instead of NigerianDollars humanresouces nursealabere
  • second: the way you're doing it is you're reassigning a new value for myStr and redeclaring myStr using var each time
  • third: you're not using all the required escape sequence characters
Nicholas Johnson
@newplasticideas
Apr 18 2017 06:00
@GitHub-Henry I'm keeping it small so it's mobile friendly, essentially. I'm also trying to futureproof the functionality as I don't know what my quotes are actually going to be yet.
Henry
@GitHub-Henry
Apr 18 2017 06:01
@newplasticideas are you saying if you increase the height of your display area a mobile device couldn't contain your largest quote?
Nicholas Johnson
@newplasticideas
Apr 18 2017 06:02
@GitHub-Henry haha! my mistake, for some reason i thought you were suggesting I widen the div.
Jor
@joreyesl
Apr 18 2017 06:04
@newplasticideas i thought we came up with an approach
Shayan
@ShayanS
Apr 18 2017 06:05
Thanks @leftynaut for your help with Checkpoint: Profile Lookup
CamperBot
@camperbot
Apr 18 2017 06:05
shayans sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
:cookie: 631 | @leftynaut |http://www.freecodecamp.com/leftynaut
Nicholas Johnson
@newplasticideas
Apr 18 2017 06:07
@joreyesl I lost that conversation :worried:
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 06:07

@newplasticideas


$('#generator').click(function newQuote() {
    var randomNumber = quoteLog[Math.floor(Math.random() * quoteLog.length)];
    var maximumLength = 10;
    var shrinkMe = randomNumber.quote;
    if (shrinkMe.length > maximumLength) {
        $('#quotehere').css("font-size", "10px")
    } else (
        $('#quotehere').css("font-size", "15px")
    )
    $( "#quotehere" ).fadeOut( "slow", function() {
    $( "#quotehere" ).empty().append(randomNumber.quote).fadeIn();
  });
    $("#authorhere").fadeOut("slow", function() {
        $( "#authorhere" ).empty().append(randomNumber.name).fadeIn();
    });
    /*

    */

});

think this is what you want to do

cusbus
@cusbus
Apr 18 2017 06:07
hey all - trying to figure out a basic question on ++

var myVar = 87;

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

goal is to use the ++ operator to get 88
Femi Adewuyi
@femi5ezekiel
Apr 18 2017 06:08
please help
Mohammed Sameeruddin
@loophole-sameer
Apr 18 2017 06:08
one help from anyone of you .....
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:09
@cusbus you can just do myVar++;
iam not able find the mistake .... pls rectify
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:09
@femi5ezekiel tried anything?
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:09
@femi5ezekiel you can't have spaces there
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:09
@cusbus myVar++;
Nicholas Johnson
@newplasticideas
Apr 18 2017 06:09
@HeebieGeeBee giving that a go right now. Thanks!
CamperBot
@camperbot
Apr 18 2017 06:09
newplasticideas sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1373 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:10
@HeebieGeeBee :wave:
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 06:10
@newplasticideas sorry i put paranthesis for the else not curly brackets, make sure you change it
@Lumexralph yo
cusbus
@cusbus
Apr 18 2017 06:10
@UnovaXan you da man :) thank you!
CamperBot
@camperbot
Apr 18 2017 06:10
cusbus sends brownie points to @unovaxan :sparkles: :thumbsup: :sparkles:
:cookie: 244 | @unovaxan |http://www.freecodecamp.com/unovaxan
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 06:10
@Lumexralph how goes it?
Femi Adewuyi
@femi5ezekiel
Apr 18 2017 06:11
@Lumexralph i am not getting it
cusbus
@cusbus
Apr 18 2017 06:11
@Lumexralph thank you sir :)
CamperBot
@camperbot
Apr 18 2017 06:11
cusbus sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1530 | @lumexralph |http://www.freecodecamp.com/lumexralph
Shayan
@ShayanS
Apr 18 2017 06:11
@fortMaximus yes I got it , thanks anyway!
CamperBot
@camperbot
Apr 18 2017 06:11
:cookie: 726 | @fortmaximus |http://www.freecodecamp.com/fortmaximus
shayans sends brownie points to @fortmaximus :sparkles: :thumbsup: :sparkles:
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:11
@HeebieGeeBee goes it well, cooking yam soup, trying to finish my calculator and time for work..... hols over
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 06:12
@newplasticideas also you can set different styling for different media types you dont have to keep it small on big screens so it will appear big on little ones
@Lumexralph oh nice
im about to go shop
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:13
@femi5ezekiel you have to escape some characters in JS so the interpreter/engine don't get them missed up for something else
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:13
@HeebieGeeBee calculator without eval or new Function is a big work but it was interesting too
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 06:14
yeah i heard i did mine with eval
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:14
@femi5ezekiel So your string should basically be like this:
var myStr = "FirstLine\n\SecondLine\\rThirdLine";
notice that there is no spacing
\n gives you a new line
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 06:14
but think i will redo with better code without eval
at some point
Kurt Johnson
@pompan129
Apr 18 2017 06:14
eval is dangerous.
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:14
backslash itself must be escaped
Nicholas Johnson
@newplasticideas
Apr 18 2017 06:14

@HeebieGeeBee true, I think media queries might be more practical at this point for futureproofing than confining my desktop display to 500px the way I have.

So the code you've given me is almost working. It definitely shrinks the font for longer strings but it won't return to a larger size for shorter strings. I will have a play around, maybe set another if statement for smaller strings.

Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:14
\r gives you a carriage return
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 06:15
@newplasticideas well you had your maxlength set to 10
and did you change the else to curly brackets like i said
you had no quotes that were less than 10 characters in length
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:15
@HeebieGeeBee am seriously thinking of how the calculator will handle brackets ( ) but mehn..... i can think of using recursion to get the product of the value there's another bracket in the the brackets but it's looking like i'll leave it to improve on it whenever I have the time
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:16
var myStr = "FirstLine\n\SecondLine\\rThirdLine";
damn chat
its removing the escaped backlash
Nicholas Johnson
@newplasticideas
Apr 18 2017 06:16
@HeebieGeeBee Yep changed the curly brackets. I just double checked my string lengths, I'd been underestimating how long the placeholders were! Will keep adjusting. Thanks for your time, this is gonna help immensely.
CamperBot
@camperbot
Apr 18 2017 06:16
newplasticideas sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: newplasticideas already gave heebiegeebee points
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 06:16
var randomNumber = quoteLog[Math.floor(Math.random() * quoteLog.length)];
    var maximumLength = 50;
    var shrinkMe = randomNumber.quote;
    if (shrinkMe.length > maximumLength) {
        $('#quotehere').css("font-size", "10px")
        console.log('long')
    } else {
        console.log('short')
        $('#quotehere').css("font-size", "25px")
    }
    $( "#quotehere" ).fadeOut( "slow", function() {
    $( "#quotehere" ).empty().append(randomNumber.quote).fadeIn();
  });
    $("#authorhere").fadeOut("slow", function() {
        $( "#authorhere" ).empty().append(randomNumber.name).fadeIn();
    });
@newplasticideas
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:17
@HeebieGeeBee how do you do that snipped thingy?
*snippet
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:17
@UnovaXan '''
CamperBot
@camperbot
Apr 18 2017 06:17
:bulb: to format code use backticks! ``` more info
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:18
@UnovaXan click on more info link
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:18
@HeebieGeeBee where's your GIF ?
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 06:18
^there
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:18
@HeebieGeeBee :laughing:
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:18
var myStr = "FirstLine\n\\SecondLine\\\rThirdLine";
Samir Jain.
@SamirJain
Apr 18 2017 06:18
please review my code on Lookup:
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:18
nice :D
Samir Jain.
@SamirJain
Apr 18 2017 06:18
```

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

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

 if (contacts[i].hasOwnProperty(prop)) {
 return contacts[i][prop];
 }
 else {
 return "No such property";
 }
 }
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 06:19
@SamirJain return no such contact outside loop
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:19
@SamirJain
Here's an outline, if you follow it step-wise it'll help a great deal in telling you what to do or step you missed
1. you need a loop to pick each objects
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                  return the value of prop in the object
                 1.1.1.2  return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 06:19
and nest the second if/ else into the first if statement
anyways im off to shop
laters enjoy the soup @Lumexralph
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:20
@HeebieGeeBee enjoy
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:20
@SamirJain why do you have else after the if without any statements in between?
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:20
@HeebieGeeBee yeah :smile:
Markus Kiili
@Masd925
Apr 18 2017 06:20
@Lumexralph @HeebieGeeBee Morning.
devpaaji
@devpaaji
Apr 18 2017 06:20
@Masd925 gm frind
@Lumexralph hello mr py
@HeebieGeeBee how you are
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:21
@SamirJain It should look something like this
var i = 0;
  while (i<contacts.length) {
    if(contacts[i].firstName == firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      } else {
        return "No such property";
      } 

    }
    i++;
  }

  return "No such contact";
Markus Kiili
@Masd925
Apr 18 2017 06:21
@devpaaji Hi.
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:21
@Masd925 you ran away for the hols, right? good morning
Markus Kiili
@Masd925
Apr 18 2017 06:21
@Lumexralph hols?
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:21
@Masd925 easter hols?
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:22
@SamirJain you can use the for loop
just modify the if statements
@Lumexralph ??
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:22
@UnovaXan why giving the answer instead of using his code to help him out?
Markus Kiili
@Masd925
Apr 18 2017 06:22
@Lumexralph Yeah, nice long weekend. I was here occasionally.
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:23
@UnovaXan sorry for the mix up
Neil Ganotisi
@neilUnreal
Apr 18 2017 06:24
Hey guys, not so much a FCC course-related question, but I do need to find an easier way to parse a JSON in browser and test values. Say you have a JSON (ex: https://owapi.net/api/v3/u/Unreal-11505/blob?format=json_pretty) loaded in your browser, can you use the dev console to check values (ex: eu.achievements.defense.armor_up) without playing the trial and error game with a text editor and browser?
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:25
@Masd925 i was able to finish my pong game and almost done with that calculator but wrote the possible algorithm for implementing brackets, just have so much to do, i'll go back to improve on it
Markus Kiili
@Masd925
Apr 18 2017 06:25
@HeebieGeeBee Competition yesterday wen't well. 5min41s on static apnea. About same as my practise record.
@Lumexralph Good, good.
Ogundele Olumide
@Lumexralph
Apr 18 2017 06:26
@Masd925 cool :clap:
@Masd925 time for work..... later bro
Kurt Johnson
@pompan129
Apr 18 2017 06:27
@neilUnreal you mean besides just a find for "armor_up"? does it have to be in the console. You can iterate over objects?
KarimBen
@KarimBenKarim
Apr 18 2017 06:29
hi there, I'm working with codePen , I can't pass http request because the site itself is loaded on my browser with htpps request, how should I do? I tried to changer either the codepen request type or the one of my api ( OpenWeatherMap) it didn't work, how should I do?
Neil Ganotisi
@neilUnreal
Apr 18 2017 06:31
Well I mean, instead of guessing and checking your code in a nodeJS environment (ex: checking to see if JSONresult.eu.achievements.defense.armor_up is a defined value [would have been using console.log to check]), would there be a way to do it in-browser?
Amanda
@amandaphoenix
Apr 18 2017 06:32

@Sharifdesigns22 == is equality operator and === is strict equality
You probably don't want it to be strict because it means both the data type and value is compared

Did the "Eagle" one work for you? :)

Benjamin
@XenoCoding
Apr 18 2017 06:34
Why don't my All, Online, Offline buttons work?
Amanda
@amandaphoenix
Apr 18 2017 06:34
I think I may have replied to a message that is ages old... my bad
Markus Kiili
@Masd925
Apr 18 2017 06:35
@amandaphoenix It is better to always use strict equality. JS abstract equality algorithm is a mess.
Femi Adewuyi
@femi5ezekiel
Apr 18 2017 06:35
Help please
Joseph
@revisualize
Apr 18 2017 06:35
@femi5ezekiel Remove the spaces
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:35
@femi5ezekiel you want to remove the spaces in between the strings
Joseph
@revisualize
Apr 18 2017 06:35
@femi5ezekiel myStr should have encoded text with the proper escape sequences and no spacing.
Amanda
@amandaphoenix
Apr 18 2017 06:35
for the golf code challenge specifically? @Masd925
Markus Kiili
@Masd925
Apr 18 2017 06:36
@amandaphoenix Always.
Amanda
@amandaphoenix
Apr 18 2017 06:36
Ok, thanks
Femi Adewuyi
@femi5ezekiel
Apr 18 2017 06:36
@revisualize @UnovaXan How please
Joseph
@revisualize
Apr 18 2017 06:36
@femi5ezekiel You just remove the spaces.
@femi5ezekiel This is a sentence with spaces.
@femi5ezekiel Thisisasentencewithoutspaces.
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:37
@femi5ezekiel you have a space before and after the escaped characters
Amanda
@amandaphoenix
Apr 18 2017 06:37
@femi5ezekiel it'll look like a whole bunch of \\ in weird areas but it works
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:38
"blahblah\nblahblah\\blahblah\\\r"
Amanda
@amandaphoenix
Apr 18 2017 06:38
ok i'm off trying to be helpful hahahah i'm a n00b
:D
Joseph
@revisualize
Apr 18 2017 06:38
@femi5ezekiel There's no trick to it. You just delete the spaces in your string like the instructions state.
Amanda
@amandaphoenix
Apr 18 2017 06:38
var myStr = "FirstLine\n\ etcetcetc
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:38
@amandaphoenix that's totally fine
we all learn from sharing
Amanda
@amandaphoenix
Apr 18 2017 06:39
hey how do you paste the code in black boxes on this chat?
Sandesh Shrestha
@UnovaXan
Apr 18 2017 06:39
add ```
Joseph
@revisualize
Apr 18 2017 06:39

If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format: ..... PLEASE try with a small block of code before you try to make a bigger one.
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

vatsal28
@vatsal28
Apr 18 2017 06:39

function myLocalScope() {
myVar = 'use strict';

console.log(myVar);
}
myLocalScope();

Why am I not able to pass this -.-?
Joseph
@revisualize
Apr 18 2017 06:40
@femi5ezekiel Did you solve the challenge?
Mohamed Derhalli
@derhallim
Apr 18 2017 06:40
Wololo
vatsal28
@vatsal28
Apr 18 2017 06:40
I have to declare local variable first and then remove the console line, but it doesn't work
Amanda
@amandaphoenix
Apr 18 2017 06:40
var myStr = "FirstLine\n\\SecondLine\\\rThirdLine"
ooh
Mohamed Derhalli
@derhallim
Apr 18 2017 06:40
@revisualize :v:
Joseph
@revisualize
Apr 18 2017 06:40
@amandaphoenix Do you have that site flyingsologear?
Amanda
@amandaphoenix
Apr 18 2017 06:40
@revisualize yes what's up?
Mohamed Derhalli
@derhallim
Apr 18 2017 06:40
@Masd925 why did u leave the main room? :joy:
Joseph
@revisualize
Apr 18 2017 06:41
@amandaphoenix Have you looked at it recently?
Amanda
@amandaphoenix
Apr 18 2017 06:41
@revisualize oh no what happened? I'm looking at it now
Femi Adewuyi
@femi5ezekiel
Apr 18 2017 06:41
@UnovaXan @amandaphoenix @revisualize It looks horrific but it works Thanks.
CamperBot
@camperbot
Apr 18 2017 06:41
femi5ezekiel sends brownie points to @unovaxan and @amandaphoenix and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 245 | @unovaxan |http://www.freecodecamp.com/unovaxan
:cookie: 191 | @amandaphoenix |http://www.freecodecamp.com/amandaphoenix
:star2: 3772 | @revisualize |http://www.freecodecamp.com/revisualize
seanrhee
@seanrhee
Apr 18 2017 06:41
Hey guys, me again. Stuck on "Seek and Destroy"

function destroyer(arr) {
  // Remove all the values
  function destroy(x){
    for(var i = 1; i < arguments; i++){
      if(x != arguments[i]){
        return true;
      }if (x == arguments[i]){
        return false;
      }
    }
  }

  //return arguments;
  var destroyed = arr.filter(destroy);
  return destroyed;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Joseph
@revisualize
Apr 18 2017 06:41
@amandaphoenix The video is gone.
Amanda
@amandaphoenix
Apr 18 2017 06:41
:O
Markus Kiili
@Masd925
Apr 18 2017 06:41
@derhallim I don't hang there too much. Too fast for me ;)
Amanda
@amandaphoenix
Apr 18 2017 06:42
oh yes I hid that when I applied for a job, one sec, thanks for letting me know
seanrhee
@seanrhee
Apr 18 2017 06:42
i'm wondering if there's a way for me to call arguments[1] of the destroyer function from within destroy(x)
Markus Kiili
@Masd925
Apr 18 2017 06:42
@seanrhee Filter callback destroy has its own arguments object.
Amanda
@amandaphoenix
Apr 18 2017 06:42
@revisualize I thought the site had disappeared or something
@revisualize okay great it's back in action. Thanks for reminding me to put it back up
CamperBot
@camperbot
Apr 18 2017 06:43
amandaphoenix sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3773 | @revisualize |http://www.freecodecamp.com/revisualize
seanrhee
@seanrhee
Apr 18 2017 06:44
@Masd925 i'm not sure if i understand
Markus Kiili
@Masd925
Apr 18 2017 06:45
@seanrhee Inside destroy, you are not accessing destroyers arguments.
seanrhee
@seanrhee
Apr 18 2017 06:46
ah I guess that's where I'm having troubles because if I use arguments[1] within destroy, it seems to want to call to the 2nd argument of destroy, rather than destroyer
Markus Kiili
@Masd925
Apr 18 2017 06:46
@seanrhee Filter method automatically iterates arr under the hood and passes each element (number) into destroy. Therefore arguments object inside destroy only has one element which is the number passed by filter (arr element being iterated).
Joseph
@revisualize
Apr 18 2017 06:47
@amandaphoenix :+1:
Markus Kiili
@Masd925
Apr 18 2017 06:47
You have to find a way to access destroyers arguments object inside the callback function destroy.
Benjamin
@XenoCoding
Apr 18 2017 06:49
@Masd925 Do you know why my all/online/offline buttons aren't working?
Jor
@joreyesl
Apr 18 2017 06:51
@seanrhee you should assign arguments object to a variable inside destroyer then you can refer to that variable inside destroy
Markus Kiili
@Masd925
Apr 18 2017 06:52
@XenoCoding Try to console.log something from the click callbacks so you see if they are working.
Benjamin
@XenoCoding
Apr 18 2017 06:52
@Masd925 They are.
Joseph
@revisualize
Apr 18 2017 06:56
@Masd925 Hi. :wave: ... :v: :zzz:
Markus Kiili
@Masd925
Apr 18 2017 06:56
@revisualize Sleep well.
Joseph
@revisualize
Apr 18 2017 06:57
:zzz: ... :sailboat: ... :zzz: ... :sailboat: :sunrise: ... :zzz: ... :sailboat: :tropical_fish: :sunrise: ... :zzz: ... :sailboat: :tropical_fish: :dolphin: :whale2: :sunrise: ... :zzz:
I'll be dreaming about sailing off to a beautiful tropical island.
Markus Kiili
@Masd925
Apr 18 2017 06:58
@revisualize There hugging your precious ECMAScript standard...
devpaaji
@devpaaji
Apr 18 2017 06:58
@Masd925
is there a major diff when we write
li[i].style.display = "";
vs
Joseph
@revisualize
Apr 18 2017 06:58
Ahhh... Amazing 40ft sailboat under my feet. Wind in my hair. Lovely alcoholic beverage in my hand.
That's the shit dreams are made of.
devpaaji
@devpaaji
Apr 18 2017 06:59
li[i].style.display = "none";
Amanda
@amandaphoenix
Apr 18 2017 06:59

i did exactly as the pseudocode...

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

oops
Markus Kiili
@Masd925
Apr 18 2017 06:59
@devpaaji Googling can tell you better than I can on that matter.
Joseph
@revisualize
Apr 18 2017 07:00
@amandaphoenix You're not re-assigning the answer variable in your switch cases statements.
@amandaphoenix You should be re-assigning answer because that's what you're returning at the bottom of your function.
ANYHOW!
I'm off to dream about tropical islands off in the distance. Sails above my head and a lovely 40ft sailing yacht where I'm at the helm.. (Or maybe autopilot is at the helm and I'm just enjoying the views.)
Amanda
@amandaphoenix
Apr 18 2017 07:01
what is re-assigning?
seanrhee
@seanrhee
Apr 18 2017 07:02
man, i am just not understanding this i think
devpaaji
@devpaaji
Apr 18 2017 07:02
@Masd925 It (li[i].style.display = ""; sets the display style to the default value for that element.
Amanda
@amandaphoenix
Apr 18 2017 07:02
haha okay good night!
Joseph
@revisualize
Apr 18 2017 07:02
@amandaphoenix
var str = '';
How do you re-assign the variable str to a new string value?
Changed the variable because I didn't want to confuse your function.
devpaaji
@devpaaji
Apr 18 2017 07:04
If a word is found on a string
we can use indexOf to check that
Amanda
@amandaphoenix
Apr 18 2017 07:04
answer = val;
?
Joseph
@revisualize
Apr 18 2017 07:05
@amandaphoenix No.
devpaaji
@devpaaji
Apr 18 2017 07:05
if not found === -1
Amanda
@amandaphoenix
Apr 18 2017 07:05
ah.
devpaaji
@devpaaji
Apr 18 2017 07:05
if found >=0 or > -1
correct @Masd925
Joseph
@revisualize
Apr 18 2017 07:05
@amandaphoenix Look.
var str = ''; ... this is variable declaration and assignment.
Amanda
@amandaphoenix
Apr 18 2017 07:05
I keep getting "expected an assignment or function call and instead saw an expression?"
beside alpha, beta, gamma, and delta
Joseph
@revisualize
Apr 18 2017 07:05
@amandaphoenix
str = "new value";
This is variable re-assignment.
seanrhee
@seanrhee
Apr 18 2017 07:05

Could someone help me out with it? I thought i understood it, but it's still not clicking in my brain


function destroyer(arr) {
  // Remove all the values
  function destroy(x){
    if (x){
      return true;
    }
  }

  var destroyed;

  for (var i = 1; i < arr.length; i++){
    var check = arguments[i];
    destroyed = arr.filter(destroy);
  }



  //return arguments;

  return destroyed;
}

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

:(

Joseph
@revisualize
Apr 18 2017 07:06
@amandaphoenix You need to re-assign the answer variable inside of your switch cases.
answer = "string value";
rugano
@rugano
Apr 18 2017 07:06
@amandaphoenix like this: switch(val) { case 1: answer = "alpha"; break;
Amanda
@amandaphoenix
Apr 18 2017 07:07
ohhhh
it worked, thanks @revisualize @rugano ... go sleep! and dream of yachts
CamperBot
@camperbot
Apr 18 2017 07:08
:cookie: 192 | @rugano |http://www.freecodecamp.com/rugano
amandaphoenix sends brownie points to @revisualize and @rugano :sparkles: :thumbsup: :sparkles:
:warning: amandaphoenix already gave revisualize points
Jor
@joreyesl
Apr 18 2017 07:08
@seanrhee your destroy function isnt filtering anything. You should be checking whether x matches any of the other arguments passed to destroyer. If it does return false, otherwise return true.
rugano
@rugano
Apr 18 2017 07:08
switch(val){
case 1:
answer = "alpha";
break;
Amanda
@amandaphoenix
Apr 18 2017 07:09

  switch(val) {
    case 1: 
      answer="alpha";
      break;
    case 2:
      answer="beta";
      break;
    case 3:
      answer="gamma";
      break;
    case 4:
      answer="delta";
      break;
  }
  val=answer;
cool... thanks guys!
I have the opposite of any computing background ever. hahaha you guys are lifesavers.
Markus Kiili
@Masd925
Apr 18 2017 07:11
@seanrhee It is better to filter only once return arr.filter(destroy); and loop the arguments inside destroy.
More efficient and easier to understand.
seanrhee
@seanrhee
Apr 18 2017 07:13
so the final line of code should be return arr.filter(destroy);?
Joseph
@revisualize
Apr 18 2017 07:14
@amandaphoenix you dont need to overwrite val at the end.
Markus Kiili
@Masd925
Apr 18 2017 07:14
@seanrhee Yes.
seanrhee
@seanrhee
Apr 18 2017 07:16
so i think i understand better but i 'm just not quite there

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

  return arr.filter(destroy);
}
sorry i keep bothering you guys about the same thing, i'm just totally lost in this one
Markus Kiili
@Masd925
Apr 18 2017 07:17
@seanrhee You first need to store destroyers arguments object on a variable var args = arguments; and then loop args inside the destroy. You are not accessing destroyers arguments there now.
Joseph
@revisualize
Apr 18 2017 07:18
arguments scopes to the function of access.
Markus Kiili
@Masd925
Apr 18 2017 07:19
@seanrhee Filter iterates arr automatically, so no need to loop arr.
x is the arr element being iterated by filter.
Joseph
@revisualize
Apr 18 2017 07:19
The outer function destroyer has its own set of arguments and destroy has its own set of argumwnts
Whatever. I cant spell on my phone.
I loath that challenge.
Markus Kiili
@Masd925
Apr 18 2017 07:20
@seanrhee Inside destroy, return false if x is equal to any of args elements. Return true after the loop.
Joseph
@revisualize
Apr 18 2017 07:20
I havent completed smallest common yet though.
I know i will beed orime factorization for that one too. Ick.
Prime*
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 07:21
@Masd925 yo!
Markus Kiili
@Masd925
Apr 18 2017 07:22
@HeebieGeeBee Hi.
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 07:22
sweet sweel done with the competitiion
no idea what static apnea means but sounds good
seanrhee
@seanrhee
Apr 18 2017 07:22
OH MY GOD @Masd925 you are the effing man dude
thank you @Masd925
CamperBot
@camperbot
Apr 18 2017 07:22
seanrhee sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3867 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Apr 18 2017 07:22
@HeebieGeeBee Just holding breath underwater.
seanrhee
@seanrhee
Apr 18 2017 07:23
i've been stuck on that one for like 3 days
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 07:23
@Masd925 woah and almost 6 mins
Markus Kiili
@Masd925
Apr 18 2017 07:23
@HeebieGeeBee Yeah, being alone for 6 minutes nowadays is nice.
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 07:23
lol
sounds like a man whos been married a while
Markus Kiili
@Masd925
Apr 18 2017 07:24
Yeah, that's me.
@seanrhee :+1:
Philipp Scholz
@philipp32
Apr 18 2017 07:28
Hey,
:)
It says here that it can't read the value 97 of undefined.
function fearNotLetter(str) {
  for (var i=1; i<str.length; i++){
      if (str.charCodeAt(i) - str.charCodeAt(i-1) !== 1 ){
      return String.fromCharCode(str.charCodeAt(i));
    } 
  }  
  return "undefined";
}
fearNotLetter("abce");
Couldn't find the undefined. :/ What am I missing?
Jor
@joreyesl
Apr 18 2017 07:30
@philipp32 you should start at i=1?
Markus Kiili
@Masd925
Apr 18 2017 07:30
@philipp32 .fromCharCode is a method of string constructor String, not strings.
Philipp Scholz
@philipp32
Apr 18 2017 07:30
@Masd925 What does that mean?
Markus Kiili
@Masd925
Apr 18 2017 07:31
@philipp32 You cannot call it on a string. You need to do String.fromCharCode(...)
And you need to use a number (charcode) as an argument.
Philipp Scholz
@philipp32
Apr 18 2017 07:32
@Masd925 I did that. Now it says that str.fromCharCode is not a function.
Markus Kiili
@Masd925
Apr 18 2017 07:32
String.fromCharCode, not str.fromCharCode
rugano
@rugano
Apr 18 2017 07:34
What is wrong with my card counting code?
Philipp Scholz
@philipp32
Apr 18 2017 07:34
@Masd925 What is the difference between the two? In the first version I write string, in the second version I use a string which is named str.
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 07:34
btw what is letterCode[i] meant to be?
Philipp Scholz
@philipp32
Apr 18 2017 07:36
@HeebieGeeBee
function fearNotLetter(str) {
  for (var i=1; i<str.length; i++){
      if (String.charCodeAt(i) - String.charCodeAt(i-1) !== 1 ){
      return String.fromCharCode(str.charCodeAt(i));
    } 
  }  
  return "undefined";
}
fearNotLetter("abce");
Markus Kiili
@Masd925
Apr 18 2017 07:36
@philipp32 String methods are inherited from String.prototype to all strings, so you can call them on any string str.slice() etc. The fromCharCode does not involve any particular string (it turns a number into a character), so it is stored on the String constructor and is not inherited to all strings. You need to call it with String.fromCharCode(...).
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 07:37
no str.charCodeAt(i)
but String.fromCharCode(......
Philipp Scholz
@philipp32
Apr 18 2017 07:37
function fearNotLetter(str) {
  for (var i=1; i<str.length; i++){
      if (String.charCodeAt(str[i]) - String.charCodeAt(str[i-1]) !== 1 ){
      return String.fromCharCode(String.charCodeAt(str[i]));
    } 
  }  
  return "undefined";
}
fearNotLetter("abce");
Markus Kiili
@Masd925
Apr 18 2017 07:38
@philipp32 As @HeebieGeeBee said, charCodeAt is a string method and must be called on some string.
Philipp Scholz
@philipp32
Apr 18 2017 07:38
Now all I get String.charCodeAt is not a function.
I do understand that. I probably just don't know how to express that in code. I'm stuck. :/
Jor
@joreyesl
Apr 18 2017 07:39
@philipp32 chartCodeAt() you call it on the string str. fromCharCode() is a static method, you call it on the String object
Mohamed Derhalli
@derhallim
Apr 18 2017 07:39
:v:
when u can't sleep and u wanna code, but u can't code
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 07:40
```
function fearNotLetter(str) {
  for (var i=1; i<str.length; i++){
      if (str.charCodeAt(i) - str.charCodeAt(i-1) !== 1 ){
      return String.fromCharCode(str.charCodeAt(i));  // but im not even sur ethis is needed why not just return str[i]
    } 
  }  
  return "undefined";
}
fearNotLetter("abce");
```
Vivek
@vivekmittal7
Apr 18 2017 07:40
can someone explain me how does javascript return true or false based on this function:-

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

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

devpaaji
@devpaaji
Apr 18 2017 07:40
@Masd925 you see indexof is both String and Array method
so few methods are common in JS
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 07:41
@derhallim yo
Mohamed Derhalli
@derhallim
Apr 18 2017 07:41
hey @HeebieGeeBee
wassup man
devpaaji
@devpaaji
Apr 18 2017 07:41
@derhallim hello
how are you
Mohamed Derhalli
@derhallim
Apr 18 2017 07:41
@devpaaji gd gd , u?
Philipp Scholz
@philipp32
Apr 18 2017 07:41
@HeebieGeeBee @Masd925 Thank you.
CamperBot
@camperbot
Apr 18 2017 07:41
philipp32 sends brownie points to @heebiegeebee and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1374 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:star2: 3868 | @masd925 |http://www.freecodecamp.com/masd925
Austin Tice
@AustinTice
Apr 18 2017 07:41
can someone better explain the reduce method to me? I can't quite grasp it.
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 07:42
not much just had fresh french baguette and some nutella with some coffee for breakfast
so its a good day so far
Markus Kiili
@Masd925
Apr 18 2017 07:42
@devpaaji Yeah, but just same name for two different methods.
Austin Tice
@AustinTice
Apr 18 2017 07:43
I have completed the lesson, but I don't quite understand the concept.
Vivek
@vivekmittal7
Apr 18 2017 07:44

function isLess(a, b) {
return a < b ;
}

isLess(17, 15);

HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 07:44
@AustinTice reduce is an array iteration method that iterates over an array using a callback function that takes arguments, at least two, one thats an accumilator and one thats current value
Vivek
@vivekmittal7
Apr 18 2017 07:44
this function returns true, but i dont understand how does it know it's true or false
rugano
@rugano
Apr 18 2017 07:44
var count = 0;
function cc(card){
var count = "increment/decrement";
switch(card) {
case +1:
cards = "2,3,4,5,6";
break;

case 0:
cards = "7,8,9";
break;

case -1:
cards = "10,'J','Q','K','A'";
break;
}
return "count +Bet || count +Hold";
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
HeebieGeeBee
@HeebieGeeBee
Apr 18 2017 07:44
but the callback has options for more arguments
Pieter Stokkink
@forkerino
Apr 18 2017 07:44
morning!
Austin Tice
@AustinTice
Apr 18 2017 07:45
It's more for iteration and condensing arrays?
Markus Kiili
@Mas