These are chat archives for FreeCodeCamp/HelpJavaScript

26th
Jun 2016
shivam kumar
@shivamgpt38
Jun 26 2016 00:00
i am stuck in make object properties private
Moisés Man
@moigithub
Jun 26 2016 00:00

ie.. @liproqq

var  found=true;
for(.....){
    if(some check not valid) {
             found=false;
      }
}
if(found===true){
   arr.push(....)
}

using counter... probably will be something like ...

var  propFound = 0;
for(.....){
    if(some check not valid) {
             propFound++;
      }
}
if(propFound  == keys.length ){
   arr.push(....)
}
shivam kumar
@shivamgpt38
Jun 26 2016 00:00

var Bike = function() {

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

this.getGear=function(get){

};

this.setGear=function(set){
return set;
};
};

it didn't work like expacted
myBike.getGear() should return 4 after calling myBike.setGear(4).
Ghost
@ghost~56a80c91e610378809be5d28
Jun 26 2016 00:03
@shivamgpt38 please format
help format
CamperBot
@camperbot
Jun 26 2016 00:03

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

shivam kumar
@shivamgpt38
Jun 26 2016 00:04
This message was deleted
This message was deleted
Michael Karpinski
@karpimpski
Jun 26 2016 00:05
hey, can anybody tell me why I keep getting an "undefined" at the top of my list, and why calculations like .31 are missing a penny?
shivam kumar
@shivamgpt38
Jun 26 2016 00:05
This message was deleted
CamperBot
@camperbot
Jun 26 2016 00:05
:bulb: to format code use backticks! ``` more info
James Daniel
@izulien
Jun 26 2016 00:06
@shivamgpt38 PM me and I'll help you out.
Diego Mayer
@Chrono79
Jun 26 2016 00:10
@shivamgpt38 look again at the code example of the challenge
shivam kumar
@shivamgpt38
Jun 26 2016 00:11
there is no example code that is the problem
@Chrono79
@izulien it says myBike.getGear() should return 4 after calling myBike.setGear(4).
Diego Mayer
@Chrono79
Jun 26 2016 00:12
@shivamgpt38 and what's this?:

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

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

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

  this.getSpeed = function() {
    return speed;
  };
};
shivam kumar
@shivamgpt38
Jun 26 2016 00:13
opss :-3
@Chrono79 i didn't see that
thank you @Chrono79 @izulien
CamperBot
@camperbot
Jun 26 2016 00:13
shivamgpt38 sends brownie points to @chrono79 and @izulien :sparkles: :thumbsup: :sparkles:
:cookie: 187 | @izulien |http://www.freecodecamp.com/izulien
:star2: 1308 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 26 2016 00:14
@shivamgpt38 you have to do something like that (not exactly the same)
shivam kumar
@shivamgpt38
Jun 26 2016 00:14
ok
James Daniel
@izulien
Jun 26 2016 00:15
I just noticed my code was missing semi-colons and was still accepted.. corrected now though
@shivamgpt38 I would recommend actually adding the set/get mentioned so you can see what is being returned in the console. myBike.setGear(4); myBike.getGear();
shivam kumar
@shivamgpt38
Jun 26 2016 00:19
yes it is working now

var gear=5;
this.getGear=function(){
return gear;
};
this.setGear=function(set){
gear=set;

};

sometime i overthink the situation
:worried:
thx everyone :smile:
James Daniel
@izulien
Jun 26 2016 00:20
@shivamgpt38 Good job. The same happens to me as well. I was just looking at a block of text earlier and returning the wrong item ;)
shivam kumar
@shivamgpt38
Jun 26 2016 00:21
hehe :+1:
@izulien
ok bye good night
E-Tank
@E-Tank
Jun 26 2016 00:44

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var holdingArray;
  var holdingArray2;
  var finalArray;
  holdingArray = arr.slice(0, size);
  holdingArray2 = arr.slice(-size);
  finalArray.push(holdingArray, holdingArray2);
   return arr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Returns 'TypeError: Cannot read property 'push' of undefined'
Diego Mayer
@Chrono79
Jun 26 2016 00:45
@E-Tank var finalArray; <- that's not an array, that's undefined
ALMY91
@ALMY91
Jun 26 2016 00:46

function isArrayLike(a) {
if (a && // a is not null, undefined, etc. For it to become true, both of the statements must be true.
typeof a === "object" && // a is an object


isFinite(a.length) && // a.length is a finite number.

 a.length >= 0 && // a.length is non-negative

a.length===Math.floor(a.length) && // a.length is an integer .

Math.floor() function returns the largest integer less than or equal to a given number.




a.length < 4294967296) // a.length < 2^32
 return true; // Then a is array-like
 else
 return false; // Otherwise it is not
}
E-Tank
@E-Tank
Jun 26 2016 00:46
I typed out a big thing beforehand but apparently that doesn't matter. Yay.
var finalArray = [];
ALMY91
@ALMY91
Jun 26 2016 00:46
Hi guys i don understand what there was this criteria in the function
a.length < 4294967296
whats the purpose of this
so what happens if its a.length < 4294967296)
it isn an array anymore?
E-Tank
@E-Tank
Jun 26 2016 00:47
Alright, Awesome. Gives me [["a","b"],["c","d"]] but now I don't know how to alter it for however many chunks I'm supposed to cut it into.
Diego Mayer
@Chrono79
Jun 26 2016 00:47
@E-Tank use a loop of some sort
E-Tank
@E-Tank
Jun 26 2016 00:47
Hrm.
ALMY91
@ALMY91
Jun 26 2016 00:50
@GarySiu so usually javascript can only handle up to this size?
Diego Mayer
@Chrono79
Jun 26 2016 00:50
@ALMY91 I think you wanted to ask if it was greater than because, lesser than returns true in that code
Ryan Williams
@Ryanwfile
Jun 26 2016 00:50
Can someone please help me with this tic tac toe codepen, the reset function is changing the isGameOver variable to false but something else is changing it to true before the main game function runs, I have everything console logged to help pinpoint the error. Any help is much appreciated. http://codepen.io/Ryanwfile/pen/YWNvGo
Gary Siu
@GarySiu
Jun 26 2016 00:51
@ALMY91 It's the theoretical limit in the spec. Whether the browser/worker/whatever works like that is another matter.
@Ryanwfile Taking a look
Ryan Williams
@Ryanwfile
Jun 26 2016 00:54
@GarySiu Thank you, much appreciated
CamperBot
@camperbot
Jun 26 2016 00:54
ryanwfile sends brownie points to @garysiu :sparkles: :thumbsup: :sparkles:
:cookie: 95 | @garysiu |http://www.freecodecamp.com/garysiu
sixtus9
@sixtus9
Jun 26 2016 00:57

Assign the value 7 to variable a.

Assign the contents of a to variable b.

can somebody help me with this?
Diego Mayer
@Chrono79
Jun 26 2016 00:59
@sixtus9 have you coded something?
sixtus9
@sixtus9
Jun 26 2016 01:00
var a = 7;
var b = var a;
i tried that
Diego Mayer
@Chrono79
Jun 26 2016 01:00
@sixtus9 delete all var keywords
the ones in the left are not needed, the one in the right is wrong
a and b, are already declared in the code above yours
sixtus9
@sixtus9
Jun 26 2016 01:02
thanks, that worked!
Diego Mayer
@Chrono79
Jun 26 2016 01:03
no problem
Gary Siu
@GarySiu
Jun 26 2016 01:05
@Ryanwfile Your reset function is adding an event listener every time it runs
Ryan Williams
@Ryanwfile
Jun 26 2016 01:07
@GarySiu the button has an onclick function but I don't understand why the isGameOver variable keeps reverting to true, how can I edit the reset function to make sure the isGameOver is true when it's clicked?
James Quiambao
@Jam3sQ
Jun 26 2016 01:09
Hey guys, im on the "Escape Sequnces in Strings" tutorial and it looks easy but i can't get it
Diego Mayer
@Chrono79
Jun 26 2016 01:10
@Jam3sQ show your code
James Quiambao
@Jam3sQ
Jun 26 2016 01:11
@Chrono79 lol Kinda new to this chat room thing, do i just copy and paste it here?
Moisés Man
@moigithub
Jun 26 2016 01:11
remove extra spaces.. add 1 space after colon @Jam3sQ
Diego Mayer
@Chrono79
Jun 26 2016 01:11
YEs, if you can, follow the instructions below to see it well formatted
CamperBot
@camperbot
Jun 26 2016 01:11

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

James Quiambao
@Jam3sQ
Jun 26 2016 01:12
var myStr = "Here is a backslash: \.\n\t\t Here is a new line with two tabs."; // Change this line
oops
one moment
Diego Mayer
@Chrono79
Jun 26 2016 01:12
remove this space: \t Here
you can edit your post, the ... right of the post time
James Quiambao
@Jam3sQ
Jun 26 2016 01:14
derp. Thanks @Chrono79
CamperBot
@camperbot
Jun 26 2016 01:14
jam3sq sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1309 | @chrono79 |http://www.freecodecamp.com/chrono79
Norvin Burrus
@ndburrus
Jun 26 2016 01:14
@Jam3sQ ...typing shift+ enter adds new lines. the backtick is the key to the left of the number 1 key.... :+1: also, you may find the chat/compose buttons to the right of the chat area useful, as an alternative...
Gary Siu
@GarySiu
Jun 26 2016 01:15
@Ryanwfile I don't really understand your code
function reset(isGameOver) {//reset is working except when computer wins
  $('#rst').on('click', function() {
    $('.btn-default').contents().filter(function() { //this function finds all of the text in the button elements and removes them
      return this.nodeType === 3;
    }).remove();
    document.getElementById('gameDisplay').innerHTML = "Game restarted";
    //need to empty squares as well not just the buttons
    i = 0;
    squares = document.querySelectorAll('.btn-default');
    console.log(isGameOver);
    //isGameOver = false;  I didn't need to change this to false because it was already false, slowly pinpointing this issue
    //this might be why reset only works sometimes, it appears when isGameOver is true the function fails to run even though it's set here
    console.log("Hopefully reset " + isGameOver);
  });
return isGameOver = false;
}
Diego Mayer
@Chrono79
Jun 26 2016 01:16
@ndburrus did you mean backtick? I have backslash at the left of the 1 but it's a spanish keyboard layout
Gary Siu
@GarySiu
Jun 26 2016 01:16
So this function is declared but never called?
But the inner function sets an event listener
ALMY91
@ALMY91
Jun 26 2016 01:17
@GarySiu thanjs
@GarySiu thanks
CamperBot
@camperbot
Jun 26 2016 01:17
almy91 sends brownie points to @garysiu :sparkles: :thumbsup: :sparkles:
:cookie: 96 | @garysiu |http://www.freecodecamp.com/garysiu
Gary Siu
@GarySiu
Jun 26 2016 01:17
Oh scratch that, it gets called in main
Norvin Burrus
@ndburrus
Jun 26 2016 01:17
@Chrono79 good catch, thanks :sparkles:
CamperBot
@camperbot
Jun 26 2016 01:17
ndburrus sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1310 | @chrono79 |http://www.freecodecamp.com/chrono79
b-fuze
@b-fuze
Jun 26 2016 01:17
Hey guys, I have a question about Regular Expressions working on regex testing sites but not in the actual Javascript. Has anyone had this problem?
ALMY91
@ALMY91
Jun 26 2016 01:17
another thing is
Diego Mayer
@Chrono79
Jun 26 2016 01:17
@ndburrus :+1:
ALMY91
@ALMY91
Jun 26 2016 01:17
what does sum() method refer to here
//Return the sum of the elements of array a(or array-like objects)
//The elements of array a must be all numbers or null and undefined are ignored.  
function sum(a) {
if (isArrayLike(a)){
var total =0;
for(var i=0; i<a.length; i++){ //Loop through all elements
var element=a[i];
if (element == null) continue; //Skip null and undefined
if (isFinite(element)) total+=element;
else throw new Error("sum(): elements must be finite numbers");
}
return total;

}
else throw new Error("sum(): argument must be array-like");
}


// Determine if a is an array-like object.
// Strings and functions have numeric length properties, but are
// excluded by the typeof test. In client-side JavaScript, DOM text
// nodes have a numeric length property, and may need to be excluded
// with an additional a.nodeType != 3 test.
function isArrayLike(a) {
 if (a && // a is not null, undefined, etc. For it to become true, both of the statements must be true. 
 typeof a === "object" && // a is an object
 isFinite(a.length) && // a.length is a finite number. It has an ending point
 a.length >= 0 && // a.length is non-negative
 a.length===Math.floor(a.length) && // a.length is an integer . 
 a.length < 4294967296) // a.length < 2^32
 return true; // Then a is array-like
 else
 return false; // Otherwise it is not
}



console.log(sum([1,2,3,4,5]));
Gary Siu
@GarySiu
Jun 26 2016 01:18
@b-fuze Regex is slightly different depending on the language you're using
The site might be perl/ruby/something flavored
ALMY91
@ALMY91
Jun 26 2016 01:18
i see that i have a function named sum(a)
but im not sure what they meant when they refer to sum()method
b-fuze
@b-fuze
Jun 26 2016 01:19
I'm only using JS (I test in Node.js and FF) and I use Javascript on regex101.com
Gary Siu
@GarySiu
Jun 26 2016 01:22
@b-fuze Could be a bug? What's your regex?
b-fuze
@b-fuze
Jun 26 2016 01:22
var regex = /eval\(function\(\w(?:,\w)+\)\{[^]+;return\s+p\}\('((?:[^](?!(?:[^\\](?='))))+[^]{2})',(\d+),(\d+),'((?:[^](?!(?:[^\\](?='))))+[^]{2})'\.split\('\|'\)/;
It's syntacically correct.
Joseph
@revisualize
Jun 26 2016 01:25
@b-fuze Need more info.
b-fuze
@b-fuze
Jun 26 2016 01:26
Trying to match the stuff in this:
var x = `<div id="player_code"><span id='flvplayer'></span>
<script type='text/javascript' src='http://www.videonest.net/player/rip-jwplayer.js'></script>
<script type='text/javascript'>eval(function(p,a,c,k,e,d){while(c--)if(k[c])p=p.replace(new RegExp('\\b'+c.toString(a)+'\\b','g'),k[c]);return p}('1b("1a").19({e:"0://4.1.3.1:b/d/a/9.8",c:"0",18:"17",16:"0://7.6.5/2/h-2.g",15:"0://4.1.3.1/~14/i/13/12.11",10:"z",y:"k%",x:"k%",w:"0://4.1.3.1:b/d/a/9.8",v:"u",t:"0://7.6.5",s:"0://7.6.5/2/r/j/j.q",p:[{f:"o",n:"0://7.6.5/2/h-2.g"},{f:"m",l:{e:\'0://4.1.3.1:b/d/a/9.8\',\'c\':\'0\'}}]});',36,48,'http|154|player|194|195|net|videonest|www|mp4|video|tqp7wgp2yrvgplbxtkx76d2e2wpcb2iyv5gmgvnib7j7wz56566fpvrnwi43ada47xbutthv|182|provider||file|type|swf|rip||blueratio|100|config|html5|src|flash|modes|xml|blue|skin|aboutlink|Videonest|abouttext|downloadlink|height|width|1427|duration|jpg|wdkgwuqdgjtd|00002|videones|image|flashplayer|start|startparam|setup|player_code|jwplayer'.split('|')))
</script><script type='text/javascript' src='http://www.videonest.net/player/jwplayer.html5.js'></script></div>
<!-- Video ADs code start here-->`
ALMY91
@ALMY91
Jun 26 2016 01:26
Hello?
Joseph
@revisualize
Jun 26 2016 01:26
@b-fuze WOW! What the hell is that :shit:
ALMY91
@ALMY91
Jun 26 2016 01:26
:3
b-fuze
@b-fuze
Jun 26 2016 01:26
It works on regex101 but otherwise, not in the actual JS.
Joseph
@revisualize
Jun 26 2016 01:27
@b-fuze Wow.. Well.. Ummm.. Good luck. I don't understand what the hell you're doing so.. I'm just going to drink my Smore Frapp and stare at my screen.
Moisés Man
@moigithub
Jun 26 2016 01:27
Diego Mayer
@Chrono79
Jun 26 2016 01:28
ALMY91
@ALMY91
Jun 26 2016 01:28
Hello ?:3
Ryan Williams
@Ryanwfile
Jun 26 2016 01:28
@GarySiu It seems to be working now, thanks for checking it out
CamperBot
@camperbot
Jun 26 2016 01:28
ryanwfile sends brownie points to @garysiu :sparkles: :thumbsup: :sparkles:
:warning: ryanwfile already gave garysiu points
Gary Siu
@GarySiu
Jun 26 2016 01:28
@Ryanwfile I didn't finish tracing it back
ALMY91
@ALMY91
Jun 26 2016 01:29
Hellllllppppppppp
Gary Siu
@GarySiu
Jun 26 2016 01:29
But it looks like at some point it gets set to '0' which is a truthy value
Or something like that?
ALMY91
@ALMY91
Jun 26 2016 01:29
:3
Leonid S. Knyshov
@wiseleo
Jun 26 2016 01:29
@ALMY91 It's more productive to post your question.
ALMY91
@ALMY91
Jun 26 2016 01:30
@wiseleo i posted but nobody replied meee
Leonid S. Knyshov
@wiseleo
Jun 26 2016 01:30
@ALMY91 you said "hellp" but I see no question
ALMY91
@ALMY91
Jun 26 2016 01:30
its actually above okay i'd post it again...
Diego Mayer
@Chrono79
Jun 26 2016 01:31
:point_up: 25 de junio de 2016 22:17 @wiseleo
Leonid S. Knyshov
@wiseleo
Jun 26 2016 01:31
OK I see your question, you are asking "what is a method"?
ALMY91
@ALMY91
Jun 26 2016 01:31
what does sum() method refer to here
@wiseleo
//Return the sum of the elements of array a(or array-like objects)
//The elements of array a must be all numbers or null and undefined are ignored.  
function sum(a) {
if (isArrayLike(a)){
var total = 0;
for(var i = 0; i<a.length; i++){ //Loop through all elements
var element=a[i];
if (element == null) continue; //Skip null and undefined
if (isFinite(element)) total+=element;
else throw new Error("sum(): elements must be finite numbers");
}
return total;
}
else throw new Error("sum(): argument must be array-like");
}



// Determine if a is an array-like object.
// Strings and functions have numeric length properties, but are
// excluded by the typeof test. In client-side JavaScript, DOM text
// nodes have a numeric length property, and may need to be excluded
// with an additional a.nodeType != 3 test.
function isArrayLike(a) {         
if (a && // a is not null, undefined, etc. For it to become true, both of the statements must be true. 
typeof a === "object" && // a is an object
isFinite(a.length) && // a.length is a finite number. It has an ending point
a.length >= 0 && // a.length is non-negative
a.length===Math.floor(a.length) && // a.length is an integer . 
a.length < 4294967296) // a.length < 2^32
return true; // Then a is array-like
else
return false; // Otherwise it is not
}


console.log(sum([1,2,3,4,5]));
@wiseleo i see a sum(a) function but im not sure what are they referring to in this code when they said sum() method
Leonid S. Knyshov
@wiseleo
Jun 26 2016 01:33
When you declare a function inside an object, it's called a "method". When you declare a variable inside an object, it's called a "property". They are just different names for functions and variables.
ALMY91
@ALMY91
Jun 26 2016 01:35
@wiseleo ah i see okay so when they say sum()method is fairly strict about arguments it accepts
,throws suitably informative errors if it is passed bad values. But also Offer abit of flexibility when working with array-like objects/ true arrays/ignore null and undefined array elements
@wiseleo it means that these criterias are for declared functions that are nested within functions (objects)
Leonid S. Knyshov
@wiseleo
Jun 26 2016 01:36
@ALMY91 I don't understand what you just asked. Was that a question or a definition as you perceive it?
ALMY91
@ALMY91
Jun 26 2016 01:36
@wiseleo right?
@wiseleo its a question :)
Leonid S. Knyshov
@wiseleo
Jun 26 2016 01:37
There is no difference between a function declared inside an object and a function declared in the global scope, except that functions declared inside objects are also referred to as "methods".
ALMY91
@ALMY91
Jun 26 2016 01:38
@wiseleo haha okay i get what u mean :)
@wiseleo thanks :)
CamperBot
@camperbot
Jun 26 2016 01:38
almy91 sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 161 | @wiseleo |http://www.freecodecamp.com/wiseleo
Greg Duncan
@GregatGit
Jun 26 2016 01:39
@ohiosierra I had to go (was getting late in my part of the world) there are some free how to's on chrome dev tools - but the more you use them the quicker you'll get at debugging you code. Often in the chrome console the error will come up immediately speeding things along
Gary Siu
@GarySiu
Jun 26 2016 01:42
@GregatGit @ohiosierra To add to that if you're registered on Codepen you can put the pen in "debug mode" which lets you use the devtools on your pen
sixtus9
@sixtus9
Jun 26 2016 01:42
myVar = myVar++;
Change the code to use the ++ operator on myVar
what am i doin wrong
Bonnie
@bonnierhee
Jun 26 2016 01:42
Could anyone tell me why i'm being thrown an error on the JS Escape Sequences in String exercise with this: var myStr = "Here is a backslash: \\.\n\t\t Here is a new line with two tabs."
Greg Duncan
@GregatGit
Jun 26 2016 01:42
@sixtus9 myVar++
Diego Mayer
@Chrono79
Jun 26 2016 01:42
@sixtus9 leave only myVar++;
@bonnierhee delete this space: \t Here
Greg Duncan
@GregatGit
Jun 26 2016 01:44
@GarySiu thanks - I havn't used their tools yet -
CamperBot
@camperbot
Jun 26 2016 01:44
gregatgit sends brownie points to @garysiu :sparkles: :thumbsup: :sparkles:
:cookie: 97 | @garysiu |http://www.freecodecamp.com/garysiu
Joseph
@revisualize
Jun 26 2016 01:44
@bonnierhee \t H remove the space.
b-fuze
@b-fuze
Jun 26 2016 01:45

@b-fuze try creating a regex https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
for use vars to build it

I don't understand, I wrote a regex already.

sixtus9
@sixtus9
Jun 26 2016 01:46
thx
Bonnie
@bonnierhee
Jun 26 2016 01:46
@Chrono79 @revisualize Thanks! Why do I have to do that?
CamperBot
@camperbot
Jun 26 2016 01:46
bonnierhee sends brownie points to @chrono79 and @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1311 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 1313 | @revisualize |http://www.freecodecamp.com/revisualize
Diego Mayer
@Chrono79
Jun 26 2016 01:50
@b-fuze then nvm, but that's a lot of js code, and some of it is showing as a comment for the // is that ok?
e:\'0://4.1.3.1 <- this //
bradulz
@bradulz
Jun 26 2016 01:50
can someone whose done the ceasers cipher challenge tell how im meant to go about looping around the metacharacters? ie. if its z - plus 13 would be m. Would i have to use %?
Taylor Morgan
@tmdesigned
Jun 26 2016 01:51
@bradulz yes, %26 for 26 letters in the alphabet
bradulz
@bradulz
Jun 26 2016 01:51
what about capital letters?
Manuel Kessel
@liproqq
Jun 26 2016 01:51

function myReplace(str, before, after) {
  if (before.charAt(0) === before.charAt(0).toUpperCase)
    {

      after.replace( after.charAt(0), after.charAt(0).toUpperCase);
    }

  return str.replace( before, after);
}

myReplace("Let us get back to more Coding", "Coding", "algorithms");
I need help with the if condition on the search and replace challenge
Joseph
@revisualize
Jun 26 2016 01:51
@bonnierhee Hashtag-instructions?
bradulz
@bradulz
Jun 26 2016 01:51
will %26 cover that too?
Taylor Morgan
@tmdesigned
Jun 26 2016 01:51
@bradulz oh, well, howevermany are in your array. I only had an array of 26 characters
Moisés Man
@moigithub
Jun 26 2016 01:51
@liproqq touppercaseis a function need () at the end
Taylor Morgan
@tmdesigned
Jun 26 2016 01:51
% (the size of your array)
b-fuze
@b-fuze
Jun 26 2016 01:52

@b-fuze then nvm, but that's a lot of js code, and some of it is showing as a comment for the // is that ok?
e:\'0://4.1.3.1 <- this //

Yeah, it should ignore that, normally..

And it does, on the site. But in JS itself it doesn't work.
bradulz
@bradulz
Jun 26 2016 01:52
@ohiosierra ok thanks
CamperBot
@camperbot
Jun 26 2016 01:52
bradulz sends brownie points to @ohiosierra :sparkles: :thumbsup: :sparkles:
:cookie: 163 | @ohiosierra |http://www.freecodecamp.com/ohiosierra
Taylor Morgan
@tmdesigned
Jun 26 2016 01:52
Can anyone think of a reason why inserting an object into an array would insert a variable's name instead of it's value?
i.e. smallPowersArray.push({lastNum:count}); -- where both lastNum and count are variables I defined
it is showing up in the debugger as lastNum:3, instead of lastNum's value
b-fuze
@b-fuze
Jun 26 2016 01:54
@ohiosierra lastNum is the key, count is the value.
Diego Mayer
@Chrono79
Jun 26 2016 01:54
@liproqq It's toUpperCase()
Taylor Morgan
@tmdesigned
Jun 26 2016 01:54
@b-fuze right, but lastNum is a variable
b-fuze
@b-fuze
Jun 26 2016 01:54

Your code is exact equiv to:

smallPowersArray.push({"lastNum":count});

Manuel Kessel
@liproqq
Jun 26 2016 01:54
@Chrono79 @moigithub thanks
CamperBot
@camperbot
Jun 26 2016 01:54
liproqq sends brownie points to @chrono79 and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1543 | @moigithub |http://www.freecodecamp.com/moigithub
:star2: 1312 | @chrono79 |http://www.freecodecamp.com/chrono79
Manuel Kessel
@liproqq
Jun 26 2016 01:55
I wonder how people coded before stack overflow :D
Taylor Morgan
@tmdesigned
Jun 26 2016 01:55
it's like, var lastNum = 3; var count = 3; smallPowersArray.push({lastNum:count});
why wouldn't it push {3,3}
b-fuze
@b-fuze
Jun 26 2016 01:55
Ik.
Carl P.
@alofacarl
Jun 26 2016 01:55
Do I need the zero at the end of the function? I pass the challenge with and without it... So is it needed?
singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal + currentVal;
}, 0);
b-fuze
@b-fuze
Jun 26 2016 01:55
You want computed key names then.
Taylor Morgan
@tmdesigned
Jun 26 2016 01:55
yes
or a way around it
b-fuze
@b-fuze
Jun 26 2016 01:56

That's an ES6 feature (doesn't work in all browsers) you do it like this:

var lastNum = 3; var count = 3; smallPowersArray.push({ [lastNum]: count });

Diego Mayer
@Chrono79
Jun 26 2016 01:56
@alofacarl in that case it's the same
Taylor Morgan
@tmdesigned
Jun 26 2016 01:57
I am factoring numbers, and right now I have an array of all prime factors, like [2,2,2,3,5]
Moisés Man
@moigithub
Jun 26 2016 01:57

without ES6 u can do like this

var obj = {};
obj[lastNum] = count
smallPowersArray.push(obj);

@ohiosierra

Carl P.
@alofacarl
Jun 26 2016 01:57
@Chrono79 ok thank you
CamperBot
@camperbot
Jun 26 2016 01:57
alofacarl sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1313 | @chrono79 |http://www.freecodecamp.com/chrono79
Taylor Morgan
@tmdesigned
Jun 26 2016 01:57
since I cant do 2^3, 3^1,5^1, I am trying to work around it by an object that has the number and its power as a key:value pair
b-fuze
@b-fuze
Jun 26 2016 01:58
Okey.
Taylor Morgan
@tmdesigned
Jun 26 2016 01:58
thanks @b-fuze I'll try that
CamperBot
@camperbot
Jun 26 2016 01:58
ohiosierra sends brownie points to @b-fuze :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for b-fuze
b-fuze
@b-fuze
Jun 26 2016 01:59
This message was deleted
Oh wait, nvm.
Moisés Man
@moigithub
Jun 26 2016 01:59
@ohiosierra exponentiation operation ??
^ = xor operator in javascript
probably u wanna use Math.pow
Taylor Morgan
@tmdesigned
Jun 26 2016 02:00
@moigithub I need to count the powers though, not just calculate them
its a way to get the least common multiple of several numbers, for that exercise
for each prime, you take the one with the highest exponent
it seemed easier before I got into this mess ;)
Moisés Man
@moigithub
Jun 26 2016 02:02
for least common multiple i googled for an algorithm :)
(imnot a math guy)
Juan Moraza
@Morazajuan
Jun 26 2016 02:03
i dont get what this is asking me... the challenge its called "Stand in Line" I need help
Taylor Morgan
@tmdesigned
Jun 26 2016 02:04
@moigithub well on the bright side it involved factorization, which led me to my first javascript recursive function
Norvin Burrus
@ndburrus
Jun 26 2016 02:04

..now, that's a riot... :smile:

@b-fuze Wow.. Well.. Ummm.. Good luck. I don't understand what the hell you're doing so.. I'm just going to drink my Smore Frapp and stare at my screen.

Diego Mayer
@Chrono79
Jun 26 2016 02:04
@Morazajuan you have to use 2 of the following array manipulation methods: push, pop, shift and unshift
Juan Moraza
@Morazajuan
Jun 26 2016 02:06
oh that makes more sense! thank you @Chrono79 let me try
CamperBot
@camperbot
Jun 26 2016 02:06
morazajuan sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1314 | @chrono79 |http://www.freecodecamp.com/chrono79
bradulz
@bradulz
Jun 26 2016 02:11
var output = "";
var final =  "";
var arr = [];
var output = "";
function rot13(str) { // LBH QVQ VG!
  for(var i= 0;i<str.length;i++)
    {
      if(str.charAt(i).match(/\W/))
        arr.push((str.charAt(i).charCodeAt(0))-13);
      else arr.push(str.charAt(i).charCodeAt(0));

    }
  arr = arr.map(function(val){return val -13;});
 for(var j = 0;j<arr.length;j++)
   {
     if(arr[j]<65 && arr[j] != 45)arr[j] = 91-(65-arr[j]);
     var temp = String.fromCharCode(arr[j]);
     output +=temp;

   }


  return output;
}

// Change the inputs below to test
rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.");
i decodes exactly how the tests want it but it won't pass?
Juan Moraza
@Morazajuan
Jun 26 2016 02:11

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

  return arr;  // Change this line
}

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


// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine([2], 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
mot working
not
Carlos Zavaleta
@nerdyamigo
Jun 26 2016 02:13
@Morazajuan you can use push, then pop then shift to do it
scratch pop lol i was looking at my code but i name a variable pop i didn't actually do a pop
Nick Irvine
@irvin3
Jun 26 2016 02:16
Hey can someone please tell me how you post code so that it looks like a screenshot?
Juan Moraza
@Morazajuan
Jun 26 2016 02:16
push and shift are good ideas? let me try
@cyberamigo
thanks @cyberamigo
CamperBot
@camperbot
Jun 26 2016 02:16
morazajuan sends brownie points to @cyberamigo :sparkles: :thumbsup: :sparkles:
:cookie: 206 | @cyberamigo |http://www.freecodecamp.com/cyberamigo
Carlos Zavaleta
@nerdyamigo
Jun 26 2016 02:18
@Morazajuan yeap cause you want to push that item to the end of the array and then with shift you can store the number that you removed from the array and then return it
Nathaniel Nasarow
@Torgian
Jun 26 2016 02:18
hey guys
Norvin Burrus
@ndburrus
Jun 26 2016 02:18
@ohiosierra this may be useful: Objects as maps :sparkles:
Nathaniel Nasarow
@Torgian
Jun 26 2016 02:18
working on the quote machine and I am getting an error about the API I am trying to access
Nick Irvine
@irvin3
Jun 26 2016 02:19
I was hoping someone could take a look at my code and answer a couple questions about the Return Largest Numbers in Arrays challenge
Nathaniel Nasarow
@Torgian
Jun 26 2016 02:19
XMLHttpRequest cannot load http://quotes.stormconsultancy.co.uk/random.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
Norvin Burrus
@ndburrus
Jun 26 2016 02:20
Leonid S. Knyshov
@wiseleo
Jun 26 2016 02:20
Ugh @Torgian that's a CORS issue
Nathaniel Nasarow
@Torgian
Jun 26 2016 02:21
Ah, any idea how to make it work through codeine?
code Pen
Leonid S. Knyshov
@wiseleo
Jun 26 2016 02:22
@Torgian I haven't run into that problem yet, but there should be an article on this.
Carlos Zavaleta
@nerdyamigo
Jun 26 2016 02:22
@Torgian use JSONP
Nick Irvine
@irvin3
Jun 26 2016 02:24
this is a test
Nick Irvine
@irvin3
Jun 26 2016 02:25
so I keep getting a "TypeError: Cannot read property 'length' of undefined. Does anyone know what the issue may be?
function largestOfFour(arr) {
  // You can do this!
  var x = arr;
  for(var i = 0; i < x.length; i++){
    for(var j = 1; j < x[i].length; i++){
      var a = 0;
      var b = 0;
      if(x[i][j] >x[i][a]){
        b = x[i][j];
        a++;
      }else{

      }
      var arr2 = [];
    arr2.push(b);
    }

  }
  return arr2;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Nathaniel Nasarow
@Torgian
Jun 26 2016 02:26
@ndburrus thanks
CamperBot
@camperbot
Jun 26 2016 02:26
torgian sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 717 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jun 26 2016 02:26
@Torgian you're welcome! enjoy... :sparkles:
Greg Duncan
@GregatGit
Jun 26 2016 02:26
@Torgian try putting this on the end ?callback=?
Moisés Man
@moigithub
Jun 26 2016 02:29
@irvin3 for(var j = 1; j < x[i].length; i++){
shouldnt be j++ instead of i++ ?
Ken Nawrocki
@nawrockp
Jun 26 2016 02:29
.
Nick Irvine
@irvin3
Jun 26 2016 02:29
wow, must have looked this over 20 times and missed that..
thanks @moigithub
CamperBot
@camperbot
Jun 26 2016 02:30
irvin3 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1544 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jun 26 2016 02:30
@irvin3 also having this inside the loop
var a = 0;
var b = 0;
it will ALWAYS reset to 0
Greg Duncan
@GregatGit
Jun 26 2016 02:30
@irvin3 You don't need x - just keep it arr the whole time
bradulz
@bradulz
Jun 26 2016 02:31
@moigithub i think he wants that though
but still should be declared globally
Moisés Man
@moigithub
Jun 26 2016 02:32
maybe.. :) @bradulz
Greg Duncan
@GregatGit
Jun 26 2016 02:32
@irvin3 this should be on the first line of the function var arr2 = [];
bradulz
@bradulz
Jun 26 2016 02:33
@GregatGit @irvin3 yea its emptying the array each time haha
Nick Irvine
@irvin3
Jun 26 2016 02:34
yea I originally was just using arr instead of creating x, didn't mean for the rest of the code to be checked yet haha I just couldnt get past that typing error
bradulz
@bradulz
Jun 26 2016 02:34
anyone done the ceasars cipher challenge?
Nick Irvine
@irvin3
Jun 26 2016 02:34
thanks @GregatGit tho
CamperBot
@camperbot
Jun 26 2016 02:34
irvin3 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 624 | @gregatgit |http://www.freecodecamp.com/gregatgit
Jason Keenan
@raavin
Jun 26 2016 02:34
@bradulz yup
bradulz
@bradulz
Jun 26 2016 02:35
would you be able to run this code for me?
var output = "";
var final =  "";
var arr = [];
var output = "";
function rot13(str) { // LBH QVQ VG!
  for(var i= 0;i<str.length;i++)
    {
      if(str.charAt(i).match(/\W/))
        arr.push((str.charAt(i).charCodeAt(0))-13);
      else arr.push(str.charAt(i).charCodeAt(0));

    }
  arr = arr.map(function(val){return val -13;});
 for(var j = 0;j<arr.length;j++)
   {
     if(arr[j]<65 && arr[j] != 45)arr[j] = 91-(65-arr[j]);
     var temp = String.fromCharCode(arr[j]);
     output +=temp;

   }


  return output;
}

// Change the inputs below to test
rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.");
ranranking
@ranranking
Jun 26 2016 02:37

Hello, I have a question. What is the correct way to do challenge 266? My code is:


function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line

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

    var ind = Object.keys(source).length;

    for (var j = 0; j < Object.keys(source).length; j++) {  

      if (collection[i].hasOwnProperty(Object.keys(source)[j]) === true && collection[i][Object.keys(source)[j]] === source[Object.keys(source)[j]]) {

        ind = ind;

      } else {

        ind -= ind;

      }

    }

    if (ind === Object.keys(source).length) {

      arr.push(collection[i]);

    }

  } 

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

It's working, but I think the way I use the variable ind is not right. What is a better way to do this challenge?

Jorge
@liberaltech
Jun 26 2016 02:38
i need help with marked.js
Jason Keenan
@raavin
Jun 26 2016 02:38
@bradulz move your variables inside the function, FCC don't like global variables ;)
Jorge
@liberaltech
Jun 26 2016 02:39
the github markdown isn't working properly is there a specific way to set up marked.js?
bradulz
@bradulz
Jun 26 2016 02:39
@raavin bloody legend, thanks mate
CamperBot
@camperbot
Jun 26 2016 02:39
bradulz sends brownie points to @raavin :sparkles: :thumbsup: :sparkles:
:cookie: 407 | @raavin |http://www.freecodecamp.com/raavin
Nick Irvine
@irvin3
Jun 26 2016 02:40
@moigithub I'm a little confused where the var a and var b should go so that they retain their values. you mind helping a little? ```
Juan Moraza
@Morazajuan
Jun 26 2016 02:42
@ndburrus it helped! thanks
CamperBot
@camperbot
Jun 26 2016 02:42
morazajuan sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 718 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jun 26 2016 02:42
@Morazajuan you're welcome :smile: excellent work!! :sparkles:
Sam Nave
@shrapnel2012
Jun 26 2016 02:42
Hi all. I am having a bit of an issue with the return early pattern for functions assignment. I am unsure of how to go about handling the instructions.
Like how do I modify Abtest to that A or B is less than 0? And show that properly. The example is a bit vague to me or I am just misreading it.
Thanks for any assistance.
Nick Irvine
@irvin3
Jun 26 2016 02:46
@moigithub nvm i think im really close to getting it
Nirajana
@Nirajana
Jun 26 2016 02:48
@shrapnel2012 Try by doing this:(a<0 || b<0)
Moisés Man
@moigithub
Jun 26 2016 02:51
@irvin3 i think.. ur a variable.. is ur indice for all ur sub-arrays... if(x[i][j] >x[i][a]){
but u already have the 2nd loop to keep track of subarray indices... (variable j )
then a is no needed
and .. b is to keep trackof the longest num of each subarray..... so u should move outside the 2nd loop (above)
and fix if(x[i][j] >x[i][a]){ should be if(x[i][j] > b ){
Sam Nave
@shrapnel2012
Jun 26 2016 02:55
@Nirajana thank you! However I am still trying to understand what else needs to be done besides entering this in. For example I need the return to be undefined
CamperBot
@camperbot
Jun 26 2016 02:55
shrapnel2012 sends brownie points to @nirajana :sparkles: :thumbsup: :sparkles:
:cookie: 206 | @nirajana |http://www.freecodecamp.com/nirajana
Tyler Del Rosario
@TylerDelRosario
Jun 26 2016 02:57
Hey everyone! I'm currently on Wherefore art thou, and I honestly need help understanding what exactly is object,keys() and what it does.
*object.keys()
Nirajana
@Nirajana
Jun 26 2016 02:59
@shrapnel2012 yes, the function will return undefined .
@Nirajana The undefined property indicates that a variable has not been assigned a value.
Sam Nave
@shrapnel2012
Jun 26 2016 03:03
blob
Nick Irvine
@irvin3
Jun 26 2016 03:04
would someone mind taking a look at this code and tell me why they think that it it returning [5,5,39,1001]. when it should return [5,27,39,1001]? ```

function largestOfFour(arr) {
  // You can do this!

  var arr2 = [];
  var a = 0;
  var b = 0;
  for(var i = 0; i < arr.length; i++){
    for(var j = 1; j < arr[i].length; j++){

      if(arr[i][j] >arr[i][a]){
        b = arr[i][j];
        a++;
      }


    }
    arr2.push(b);
  }

  return arr2;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Sam Nave
@shrapnel2012
Jun 26 2016 03:04
blob
@Nirajana so beyond this, what is needed?
Nick Irvine
@irvin3
Jun 26 2016 03:04
I feel like there must be an issue with me pushing my first value to an empty array
Tyler Del Rosario
@TylerDelRosario
Jun 26 2016 03:07
Could someone explain to me what object.keys() does? the MDN explanation doesnt make sense to me.
Joseph
@revisualize
Jun 26 2016 03:08
@HTMLNoob It gets the keys of an object.
Tyler Del Rosario
@TylerDelRosario
Jun 26 2016 03:09
keys?
Leonid S. Knyshov
@wiseleo
Jun 26 2016 03:09
keys are properties on an object
Joseph
@revisualize
Jun 26 2016 03:09
@HTMLNoob Let me show you an example.
Tyler Del Rosario
@TylerDelRosario
Jun 26 2016 03:09
ok
Nirajana
@Nirajana
Jun 26 2016 03:10
@shrapnel2012 you forgot to put the "if" statement in the condition. It should be like this: if(a<0 ||b<0){return undefined;}
Milo Hartsoe
@MiloATH
Jun 26 2016 03:11
In javascript, how does one accept an unknown number of parameters to a function?
nvm
Rickey Olsen
@rickeyolsen
Jun 26 2016 03:13
This message was deleted
Joseph
@revisualize
Jun 26 2016 03:13
@HTMLNoob
You understand how arrays are accessed via indexes.
var myArr = ["0","1","2"];
Well, Objects are accessed by keys that you define yourself.
var myObj = {
    key1: "One",
    key2: "Two",
    keyArray: ["a1", "b2"]
};
console.log(Object.keys(myObj));
// This returns: [ 'key1', 'key2', 'keyArray' ]
Rickey Olsen
@rickeyolsen
Jun 26 2016 03:13
i am currently on Counting Cards and the following code is not working. I am supposed to return count and a string.
function cc(card) {
  // Only change code below this line
  switch(card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count+=1;
      break;
    case 7:
    case 8:
    case 9:
      count+=0;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count-=1;
      break;   
  }

  if (count>0) {
    return count+""+"Bet";
  }
  else {
    return count+""+"Hold";
  }

  // Only change code above this line
}
Joseph
@revisualize
Jun 26 2016 03:14
@rickeyolsen You're missing a space before Bet and Hold.
Sam Nave
@shrapnel2012
Jun 26 2016 03:14
blob
@Nirajana The test says this isn't correct :(
Rickey Olsen
@rickeyolsen
Jun 26 2016 03:14
ah! I guess that would help... thanks @revisualize
CamperBot
@camperbot
Jun 26 2016 03:14
:star2: 1314 | @revisualize |http://www.freecodecamp.com/revisualize
rickeyolsen sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
DJ
@qualitymanifest
Jun 26 2016 03:16
@shrapnel2012 you're using quotation marks in 3 places that you shouldnt be using them
Nirajana
@Nirajana
Jun 26 2016 03:17
@shrapnel2012 try by removing the quotation marks from the condition as both the variable a and b are numbers, so u don't need quotation marks. Try this, it should work:if(a<0 ||b<0)
DJ
@qualitymanifest
Jun 26 2016 03:18
yes, that and undefined shouldn't be in quotation marks either. it's a primitive value
Nirajana
@Nirajana
Jun 26 2016 03:18
@Nirajana yes, and remove quotation marks from undefined as well
Sam Nave
@shrapnel2012
Jun 26 2016 03:19
@Nirajana @qualitymanifest whoa I feel dumb right now. Just got it! Thank you both so much!
CamperBot
@camperbot
Jun 26 2016 03:19
:warning: shrapnel2012 already gave nirajana points
:star2: 1223 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
shrapnel2012 sends brownie points to @nirajana and @qualitymanifest :sparkles: :thumbsup: :sparkles:
RichSFL
@RichSFL
Jun 26 2016 03:27
hi guys, what am I doing wrong?

// Initialize these three variables
var a = 5;
var b = 10;
var c = 'I'm a string';

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

I'm having problems with this line var c = 'I'm a string';
Leonid S. Knyshov
@wiseleo
Jun 26 2016 03:28

@RichSFL Use ``` to paste code to get syntax highlighting. :)

Your string in var c is incorrect. The combined string should be "I'm a String!"

var c = "I am part one ";
c += "of two";
// "I am part one of two"
Diego Mayer
@Chrono79
Jun 26 2016 03:29
@RichSFL var c = 'I'm a string'; you can't use single quotes both inside oan outside without escaping them
use double quotes instead, around the string
RichSFL
@RichSFL
Jun 26 2016 03:31
@wiseleo thank you. I used the work "am" and it worked, I guess the phrase "I'm a..." will give trouble because of the apostrophe?
CamperBot
@camperbot
Jun 26 2016 03:31
richsfl sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 177 | @wiseleo |http://www.freecodecamp.com/wiseleo
Diego Mayer
@Chrono79
Jun 26 2016 03:31
@RichSFL @wiseleo it says: "I am a"
RichSFL
@RichSFL
Jun 26 2016 03:32
@wiseleo you are right! It didn't say I'm, but I am
Diego Mayer
@Chrono79
Jun 26 2016 03:32
yes, the apostrophe is a single quote
RichSFL
@RichSFL
Jun 26 2016 03:32
great! thanks
Diego Mayer
@Chrono79
Jun 26 2016 03:32
no problem
Leonid S. Knyshov
@wiseleo
Jun 26 2016 03:32
@RichSFL Yes, apostrophes have special meaning and have to be escaped. That's one of the upcoming challenges.
Nirajana
@Nirajana
Jun 26 2016 03:41
Hey,how can I convert the switch statement into a lookup table?
CamperBot
@camperbot
Jun 26 2016 03:41
:bulb: to format code use backticks! ``` more info
Janodus
@janodus
Jun 26 2016 03:43
wow. is anyone else having problems with Seek and Destroy? I cannot get through this for some reason haha
Leonid S. Knyshov
@wiseleo
Jun 26 2016 03:46
@Nirajana Use ``` to get syntax highlighting :)
Joseph
@revisualize
Jun 26 2016 03:47
@Nirajana Accessing Objects Properties with Variables https://www.freecodecamp.com/challenges/accessing-objects-properties-with-variables
@janodus That one took me two hours a day across 4 days. I skipped it and came back around.
Janodus
@janodus
Jun 26 2016 03:48
@revisualize that's encouraging. i guess it's the filter function that I can't get to fully understand.
Joseph
@revisualize
Jun 26 2016 03:48
@janodus filter took me a while to learn. All filter() does is keep anything that is true.
Nirajana
@Nirajana
Jun 26 2016 03:51
This message was deleted
This message was deleted
blob
DJ
@qualitymanifest
Jun 26 2016 03:52
@Nirajana you're never changing result...
Janodus
@janodus
Jun 26 2016 03:53
@revisualize understood. i can think through a solution with 2 for statements.... but i'm really trying to use filter to see if the numbers match or not...
Nirajana
@Nirajana
Jun 26 2016 03:54
@qualitymanifest I tried by using function but it is also not working:
Joseph
@revisualize
Jun 26 2016 03:54
@Nirajana Accessing Objects Properties with Variables https://www.freecodecamp.com/challenges/accessing-objects-properties-with-variables
Nirajana
@Nirajana
Jun 26 2016 03:54
@Nirajana "alpha":function(){
result="Adams";
}
Joseph
@revisualize
Jun 26 2016 03:54
@Nirajana You're not modifying result and just returning it.
DJ
@qualitymanifest
Jun 26 2016 03:55
yeah, you're hardcoding it. you need to use your lookup object with the val given to your function
Leonid S. Knyshov
@wiseleo
Jun 26 2016 03:56
You can access your object like an array with [] notation.
Nirajana
@Nirajana
Jun 26 2016 03:57
@revisualize but the instructions say not to change code for return value!
Joseph
@revisualize
Jun 26 2016 04:00
@Nirajana So.. Reassign the result before you return it.
Sundeep
@pidugusundeep
Jun 26 2016 04:22
i ned help with ajax calls
i need help with ajax can any one help me out ?
Ricardo Diaz
@diazric
Jun 26 2016 04:22
I need help with var a =7;
Sorry!
Nirajana
@Nirajana
Jun 26 2016 04:23
@revisualize @qualitymanifest @wiseleo Thanks it worked. I changed the return value and used [] notation :)
CamperBot
@camperbot
Jun 26 2016 04:23
nirajana sends brownie points to @revisualize and @qualitymanifest and @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 194 | @wiseleo |http://www.freecodecamp.com/wiseleo
:star2: 1316 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 1225 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
Janodus
@janodus
Jun 26 2016 04:36
oh snap. was watching random youtube when something clicked with the Seek and Destroy challenge: I can use filter to check and see if each individual element in the array matches with the indexOf the arguments array!
Thompson Taing
@chibibouzu
Jun 26 2016 04:40
Hi, I was wondering if someone could give me advice on the chunky monkey challege. I'm having a hard time just starting to write the code for it.
Sean DiSanti
@badc0ded
Jun 26 2016 04:43
hi all
@chibibouzu break it up into pieces, the problem i mean
write out the logic before you worry about code
just how you would do the same thing manually
Norvin Burrus
@ndburrus
Jun 26 2016 04:45
@pidugusundeep ajax calls in what? can you be more specific?
Janodus
@janodus
Jun 26 2016 04:46
need some help guys, here's my code:

function destroyer(arr) {
  var args = [];  

  for (var i = 1; i < arguments.length; i++) {
    args.push(arguments[i]);
  }

  return arr.filter(function(element) {
    return args.indexOf(element) === -1;
  });


}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
this works... but i'm having a hard time understanding the syntax fully.
Sean DiSanti
@badc0ded
Jun 26 2016 04:48
one sec i'll comment it up
Thompson Taing
@chibibouzu
Jun 26 2016 04:49
@badc0ded I developed a for loop that would splice a section of the array and push it to a new array. But when I test the code, no values come up in my new array
Sean DiSanti
@badc0ded
Jun 26 2016 04:50
```

function destroyer(arr) {
  var args = [];  // creates an empty array

  for (var i = 1; i < arguments.length; i++) { //steps through the arguments iterative object and puts each into args created above
    args.push(arguments[i]);
  }

  return arr.filter(function(element) { // steps through arr
    return args.indexOf(element) === -1; //gets rid of any member of arr that isn't found in args
  });


}

destroyer([1, 2, 3, 1, 2, 3], 2, 3); // calls to test
```
Thompson Taing
@chibibouzu
Jun 26 2016 04:50
blob
blob
Sean DiSanti
@badc0ded
Jun 26 2016 04:51
@chibibouzu your conditions in your for loop are the issue
Norvin Burrus
@ndburrus
Jun 26 2016 04:51
@chibibouzu ok, we'll need to get familiar with the suggested methods {reference instructions: push, slice}. we can start here: splits an array (first argument) into groups the length of size (second argument) these may be helpful:
Sean DiSanti
@badc0ded
Jun 26 2016 04:51
the i = i+size specifically
Janodus
@janodus
Jun 26 2016 04:52
@badc0ded thanks for the help. so... I guess the question is: the "element" argument in the function callback after filter... it's saying that the function should keep track of the "elements in the array" right? Like how would JS react if "element" was not included?
CamperBot
@camperbot
Jun 26 2016 04:52
janodus sends brownie points to @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 385 | @badc0ded |http://www.freecodecamp.com/badc0ded
Sundeep
@pidugusundeep
Jun 26 2016 04:53
@ndburrus i want to send select option values to a php file and retutn values
Sean DiSanti
@badc0ded
Jun 26 2016 04:53
sorry my comment on the filter is wrong
you're checking for indexOf === -1
so arr when filtered will only contain the elements that are not listed in args
because anything that IS in args will get an index of 0 or greater
and make the return statement false
Janodus
@janodus
Jun 26 2016 04:54
understood.
i'm understanding this backwards for some reason hehe :)
Sean DiSanti
@badc0ded
Jun 26 2016 04:55
the understanding is more important than the direction
that's a good approach to the problem for doing it before understanding
Janodus
@janodus
Jun 26 2016 04:56
understood. i get the gist of it, and why it's actually very useful... but I think it's because I wouldn't have used the return within the return... instead i would've made a new variable, and then returned the variable with the filtered list on the next line.
Norvin Burrus
@ndburrus
Jun 26 2016 04:58
This message was deleted
Sean DiSanti
@badc0ded
Jun 26 2016 04:58
same here
Janodus
@janodus
Jun 26 2016 04:58
also, i'm not used to thinking of getting an array with a single return line, instead of trying to loop through an array... so yeah, it's definitely something new.
Sean DiSanti
@badc0ded
Jun 26 2016 04:58
pretty sure my solution was almost the same
(now i have to check of course)
Janodus
@janodus
Jun 26 2016 04:59
haha
Sundeep
@pidugusundeep
Jun 26 2016 04:59
@ndburrus did u get what i meant ?
Sean DiSanti
@badc0ded
Jun 26 2016 04:59
was that seek and destroy?
i actually wrote mine out more for once on that one
didn't do the indexOf -1
didn't even use filter
Janodus
@janodus
Jun 26 2016 05:00
@badc0ded yeah it's seek and destroy.
Janodus
@janodus
Jun 26 2016 05:01
could you post your solution? i'm curious to see how you solved this.
Sean DiSanti
@badc0ded
Jun 26 2016 05:01
oops, i'm i liar i did use filter
yours is better
function destroyer(arr) {
  // Remove all the values
  var haystack = arguments[0];
  var needles = [];
  for (var i = 0; i < arguments.length; i++) {
    needles.push(arguments[i]);
  }
  return haystack.filter(function(x){
    var good = true;
    for (var n = 0; n < needles.length; n++){
      if (needles[n] == x){
        good = false;
        break;
      }
    }
    return good;
  });
}
same logic, just written out more
Norvin Burrus
@ndburrus
Jun 26 2016 05:03
@chibibouzu how are we doing?
Janodus
@janodus
Jun 26 2016 05:03
@badc0ded not at all. i would've actually used the same writeout to some degree, but I was carefully looking through the syntax, which is why I tried the double returns.
problem is, I'm not 100% sure about the solution. Even though it works, I got it through experimenting instead of fully understanding where it would go. so i'm about 70% there, not necessarily 100% comfortable.
Thompson Taing
@chibibouzu
Jun 26 2016 05:04
@ndburrus i dont understand why im not returning values
I get an empty array with the correct number of sets, but there aren't any values in the array
Sean DiSanti
@badc0ded
Jun 26 2016 05:05
mine is the same as yours, but i didn't use indexOf to check for the values, i stepped through the array on each check, which is way less efficient
i'm not being modest to say yours is the better implementation
can't give a good reason why i did that
the loop i mean
silver537
@silver537
Jun 26 2016 05:06
Higher level functions for the win.
Sundeep
@pidugusundeep
Jun 26 2016 05:07
@ndburrus i links are usefull but passing multiple values on a select is what i needed
UtkarshShukla7
@UtkarshShukla7
Jun 26 2016 05:07
@chibibouzu can you paste your code .it will be much easier then.
Logan Klein
@Lkleindesigns
Jun 26 2016 05:07

a should be assigned to b with =
// Setup
var a;
var b = 2;

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

how do i assign a to b?
Sean DiSanti
@badc0ded
Jun 26 2016 05:08
b = a;
assignments are right to left
UtkarshShukla7
@UtkarshShukla7
Jun 26 2016 05:09
@Lkleindesigns and don't initialise them
again
Sean DiSanti
@badc0ded
Jun 26 2016 05:09
yeah, the keyword var destroys the first initialization
Logan Klein
@Lkleindesigns
Jun 26 2016 05:10
im not following, how should it look
but thank you for the help
UtkarshShukla7
@UtkarshShukla7
Jun 26 2016 05:10
@Lkleindesigns
a=7;
b=a;
Thompson Taing
@chibibouzu
Jun 26 2016 05:10
blob
i know my end conditions to my splice is incorrect
but i think i should return values at least
blob
Sean DiSanti
@badc0ded
Jun 26 2016 05:12
are you sure you want to be using splice?
slice is most likely what you intend
Thompson Taing
@chibibouzu
Jun 26 2016 05:13
@badc0ded thank you, that fixed most of my problems
CamperBot
@camperbot
Jun 26 2016 05:13
chibibouzu sends brownie points to @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 386 | @badc0ded |http://www.freecodecamp.com/badc0ded
Sean DiSanti
@badc0ded
Jun 26 2016 05:13
no problem
and then think about your first iteration
i = 0
nevermind, ignore that one
i misread
pretend i stopped talking while i was being helpful
:)
if you paste code without image, or do it in a codepen, it makes grabbing a copy to play with easier too
help format
CamperBot
@camperbot
Jun 26 2016 05:15

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

Logan Klein
@Lkleindesigns
Jun 26 2016 05:16
how do i turnoff the popups for this chat ;)
Sean DiSanti
@badc0ded
Jun 26 2016 05:17
top right of screen are settings
should have notifications options there
Norvin Burrus
@ndburrus
Jun 26 2016 05:19
@chibibouzu review/check the logic here: newarr.push(arr.splice (i, -(arr.length-add)) ); :sparkles: ...try replacing that code with ( i, add) :+1:
Sean DiSanti
@badc0ded
Jun 26 2016 05:29
what are you guys trying to do?
sorry i just keep seeing lists of links
and i may be able to help with a more direct answer
Norvin Burrus
@ndburrus
Jun 26 2016 05:30
@chibibouzu any output?
@badc0ded this is the issue: :point_up: June 26, 2016 12:53 AM copy: @pidugusundeep
Sean DiSanti
@badc0ded
Jun 26 2016 05:33
ok, so just name your select and make sure your options have values
if you can show code i can give more direct advice
Norvin Burrus
@ndburrus
Jun 26 2016 05:41

@badc0ded haha, that was funny... thanks for the humor... also for helping with the select/options exercise/issue :sparkles:

pretend i stopped talking while i was being helpful

CamperBot
@camperbot
Jun 26 2016 05:41
ndburrus sends brownie points to @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 388 | @badc0ded |http://www.freecodecamp.com/badc0ded
Sean DiSanti
@badc0ded
Jun 26 2016 05:41
no problem, i'm glad i could help
really do have a ton of experience with php though if there's still trouble
Norvin Burrus
@ndburrus
Jun 26 2016 05:43
@badc0ded i'm not certain if @pidugusundeep is still available...
Sean DiSanti
@badc0ded
Jun 26 2016 05:44
ah ok
super slow night tonight
in the rooms
Janodus
@janodus
Jun 26 2016 05:45
saturday night.
Sean DiSanti
@badc0ded
Jun 26 2016 05:45
so i keep hearing
Leonid S. Knyshov
@wiseleo
Jun 26 2016 05:45
laugh I can post a question that has been annoying me for a long time ;)
Sean DiSanti
@badc0ded
Jun 26 2016 05:45
go for it
the tough ones are the fun ones
Brooke Ann S.
@tinyinkling
Jun 26 2016 05:46
what am I doing wrong in the "Returning Boolean Values from Functions? :
function isLess(a, b) {
  // Fix this code
  return a === b;
}

// Change these values to test
isLess(10, 15);
Sean DiSanti
@badc0ded
Jun 26 2016 05:46
so you want to return true if one is less than the other
Brooke Ann S.
@tinyinkling
Jun 26 2016 05:46
yep!
Sean DiSanti
@badc0ded
Jun 26 2016 05:46
rather than === what should the comparison operator be
just change === to that
Brooke Ann S.
@tinyinkling
Jun 26 2016 05:46
ah...!
facepalm
Leonid S. Knyshov
@wiseleo
Jun 26 2016 05:47
OK Sean, let me figure out how to make it a stand-alone problem without going too deep into Express ;)
Brooke Ann S.
@tinyinkling
Jun 26 2016 05:47
Thank you @badc0ded !!
CamperBot
@camperbot
Jun 26 2016 05:47
tinyinkling sends brownie points to @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 389 | @badc0ded |http://www.freecodecamp.com/badc0ded
Sean DiSanti
@badc0ded
Jun 26 2016 05:47
ok, let me apologize in advance while i am an optimist my exposure to node and express has been deliberately minimal
no problem, i'm glad i could help
Norvin Burrus
@ndburrus
Jun 26 2016 05:48
@tinyinkling review/check the logic: return a === b; :sparkles:
Sean DiSanti
@badc0ded
Jun 26 2016 05:48
i promise to give it my best effort though
Leonid S. Knyshov
@wiseleo
Jun 26 2016 05:48
Basically, what I am dealing with is making an API call using the Request module, which in turn makes a second API call using Request.
And it's messy
Both are async. I will understand it eventually.
What I think I'll do is simulate the async stuff using SetTimeout, get that working, and then implement it as proper calls.
Sean DiSanti
@badc0ded
Jun 26 2016 05:51
is that a situation where you'd use promises?
Leonid S. Knyshov
@wiseleo
Jun 26 2016 05:51
I could probably make it easier with promises or with async/await, but I am using 3rd-party vendor libraries.
Leonid S. Knyshov
@wiseleo
Jun 26 2016 05:52
thanks @ndburrus , looking
CamperBot
@camperbot
Jun 26 2016 05:52
wiseleo sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 723 | @ndburrus |http://www.freecodecamp.com/ndburrus
Leonid S. Knyshov
@wiseleo
Jun 26 2016 05:53
Interesting...
Sean DiSanti
@badc0ded
Jun 26 2016 06:04
ok, i think i'm going to go jump on my bike for a bit and work off some cafe rio. have fun everybody
Leonid S. Knyshov
@wiseleo
Jun 26 2016 06:04
This message was deleted
Akshat
@Akshatkumar4433
Jun 26 2016 06:06

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

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

return collection;
}

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

Norvin Burrus
@ndburrus
Jun 26 2016 06:06
@wiseleo ...anytime. :sparkles:
Akshat
@Akshatkumar4433
Jun 26 2016 06:06
help me
CamperBot
@camperbot
Jun 26 2016 06:06

:point_right: algorithms merge sort [wiki]

Algorithm Merge Sort

Most modern languages have an inbuilt sort() function which automatically sorts an input array or list. Did you ever wonder how the sort function actually works on the inside?. Knowing common sorting algorithms and their implementations is the most important part of a coding interview. In this series of articles, we will look at several important sorting algorithms. How they are implemented, the time and space complexity etc. Our very first post is on Merge Sort.

:pencil: read more about algorithms merge sort on the FCC Wiki

Leonid S. Knyshov
@wiseleo
Jun 26 2016 06:06
@ndburrus Thanks, I'll spend some time on those
CamperBot
@camperbot
Jun 26 2016 06:06
wiseleo sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: wiseleo already gave ndburrus points
Akshat
@Akshatkumar4433
Jun 26 2016 06:06

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

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

return collection;
}

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

Leonid S. Knyshov
@wiseleo
Jun 26 2016 06:07
@Akshatkumar4433 please post your code as a codepen. :)
Akshat
@Akshatkumar4433
Jun 26 2016 06:07
how to solve this
i am struck on it
letter
later
Leonid S. Knyshov
@wiseleo
Jun 26 2016 06:09
@Akshatkumar4433 OK, so you are stuck... What have you tried so far?
Shraddha Parab
@Shraddha99
Jun 26 2016 06:32
Can Someone explain me the working of String.prototype.indexOf() I read the contents on MDN but that is pretty confusing . When does this function returns 1 and -1 . does -1 means string not found.?? and 1 means found . but then what 0 means .
Joseph
@revisualize
Jun 26 2016 06:36
@Akshatkumar4433 You read the instructions.
// Only change code below this line
function updateRecords(id, prop, value) {
// If prop does not contain the key "tracks", 
// then update or set the value for that incomplete prop.

// If prop does contain the key "tracks" 
// and its value is non-blank, 
// then push the value onto the end of its existing tracks array.
// If prop does not contain the key "tracks" before you update it, 
// create an empty array before pushing a track to it.

// If value is blank, 
// delete that prop.

// Always return the entire collection object.
  return collection;
}
@Shraddha99 Anything not -1 is a true value. 0 is the index where the value starts. So, that would refer to the start of the string.
Shraddha Parab
@Shraddha99
Jun 26 2016 06:42
okay @revisualize
so anything NOT -1 infers to Value /String Found?
Joseph
@revisualize
Jun 26 2016 06:43
"abcdefghijk".indexOf("a"); // returns 0
"abcdefghijk".charAt(0); // returns "a"
"abcdefghijk".indexOf("b"); // returns 1
"abcdefghijk".charAt(1); // returns "b"
mayuri nayak
@mayuri14
Jun 26 2016 06:44

function slasher(arr, howMany) {
// it doesn't always pay to be first
arr.slice(0,howMany);
return arr;
}

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

What is wrong in this code
Norvin Burrus
@ndburrus
Jun 26 2016 06:46
@mayuri14 review/check the method/s you'd like to use. this may be useful: Javascript Array Methods: Unshift(), Shift(), Push(), And Pop() :sparkles:
Joseph
@revisualize
Jun 26 2016 06:46
@ndburrus That doesn't help in this case.
Norvin Burrus
@ndburrus
Jun 26 2016 06:48
@revisualize it depends on which solution approach is chosen, doesn't it?
Joseph
@revisualize
Jun 26 2016 06:48
I guess. But, she has the solution.
just needs to not start with the 0 index.
Norvin Burrus
@ndburrus
Jun 26 2016 06:51
@revisualize from the code provided, the following output is generated: => [ 1, 2, 3 ]. the instructions indicate: slasher([1, 2, 3], 2) should return [3].
mayuri nayak
@mayuri14
Jun 26 2016 06:51
Return the remaining elements of an array after chopping off n elements from the head.
This is what I want to do
Joseph
@revisualize
Jun 26 2016 06:52
okay.
@mayuri14 So, why are you starting at the 0 index?
The slice() method returns a shallow copy of a portion of an array into a new array object.
Syntax
arr.slice([begin[, end]])
mayuri nayak
@mayuri14
Jun 26 2016 06:53
I want to Return the remaining elements of an array after chopping off n elements from the head.
Joseph
@revisualize
Jun 26 2016 06:54
OKAY!
If end is omitted, slice extracts through the end of the sequence (arr.length).
mayuri nayak
@mayuri14
Jun 26 2016 06:55
What to do
anilkmrck
@anilkmrck
Jun 26 2016 06:55
hi
Joseph
@revisualize
Jun 26 2016 06:55
arr.slice(howMany);
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 06:56
@mayuri14 your array will have 1,2 now. what should you get??
@mayuri14 arr.slice(0,n) selects the elements from 0th index to n-1th index, so basically, the first argument is inclusive and 2nd argument is exclusive
Shraddha Parab
@Shraddha99
Jun 26 2016 06:57
@mayuri14 arr.slice(howMany); pass this
mayuri nayak
@mayuri14
Jun 26 2016 06:57
That also doesn't work
Shraddha Parab
@Shraddha99
Jun 26 2016 06:57
it will work @mayuri14 arr.slice(howMany);
Joseph
@revisualize
Jun 26 2016 06:58
@mayuri14 It doesn't?
Norvin Burrus
@ndburrus
Jun 26 2016 06:58
@mayuri14 these may also be helpful (in addition to :point_up: June 26, 2016 2:46 AM ):
mayuri nayak
@mayuri14
Jun 26 2016 06:59
That didn't work
Joseph
@revisualize
Jun 26 2016 06:59
@mayuri14 Prove it?
mayuri nayak
@mayuri14
Jun 26 2016 06:59
Now I used splice Instead of slice , it worked
Norvin Burrus
@ndburrus
Jun 26 2016 07:00
@mayuri14 let's handle this in 2 parts 1) chopping off n elements from the head and 2) Return the remaining elements of an array
Joseph
@revisualize
Jun 26 2016 07:00
Worked for me!
blob
Shraddha Parab
@Shraddha99
Jun 26 2016 07:01
yes @revisualize this way it does
Joseph
@revisualize
Jun 26 2016 07:01
@Shraddha99 I know.
mayuri nayak
@mayuri14
Jun 26 2016 07:02
Yes that it works
Norvin Burrus
@ndburrus
Jun 26 2016 07:02
@revisualize @mayuri14 ...nicely done! :sparkles:
mayuri nayak
@mayuri14
Jun 26 2016 07:02
Thanks everyone
Akshat
@Akshatkumar4433
Jun 26 2016 07:03
Om
Norvin Burrus
@ndburrus
Jun 26 2016 07:03
@mayuri14 you're welcome :+1:
Joseph
@revisualize
Jun 26 2016 07:04
splice does array mutation. slice does not.
Sumit Kumar
@sumitk121
Jun 26 2016 07:05
can u plz help me in lookupprofile codes
Joseph
@revisualize
Jun 26 2016 07:06

This would not work.

function slasher(arr, howMany) {
  // it doesn't always pay to be first
  arr.slice(howMany);
  return arr;
}

because the arr is not mutated.
...
Whereas:

function slasher(arr, howMany) {
  // it doesn't always pay to be first
  arr.splice(howMany);
  return arr;
}

Would work because the arr is mutated.
But, per the instructions we don't need to mutate the arr
we just need to return the elements.

christianws
@christianws
Jun 26 2016 07:06

Yo can anyone help me with this query.

If we are talking about months (12 months in a year)

if I had two months -> first is March and second is January of following year.

What can I do to find out the number of months between them?
is there a way I can use modulus ?
with a max of 12 then it resets at 0?

Sumit Kumar
@sumitk121
Jun 26 2016 07:07
@Shraddha99 can u plz help me profile lookup
silver537
@silver537
Jun 26 2016 07:08
@ndburrus @revisualize @Shraddha99 @Krish2704 ty. Since someone doesnt know how to thank specific people.
CamperBot
@camperbot
Jun 26 2016 07:08
silver537 sends brownie points to @ndburrus and @revisualize and @shraddha99 and @krish2704 :sparkles: :thumbsup: :sparkles:
:cookie: 726 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 471 | @krish2704 |http://www.freecodecamp.com/krish2704
:star2: 1317 | @revisualize |http://www.freecodecamp.com/revisualize
:cookie: 255 | @shraddha99 |http://www.freecodecamp.com/shraddha99
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 07:10
@silver537 thanks lol
CamperBot
@camperbot
Jun 26 2016 07:10
krish2704 sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 371 | @silver537 |http://www.freecodecamp.com/silver537
UtkarshShukla7
@UtkarshShukla7
Jun 26 2016 07:15
@CurlyWS you can create a lookup table for months (use an array ) which returns a number(index) to the corresponding month.If that is what you need.
Poul Lynge Larsen
@Slitch
Jun 26 2016 07:16
I knew it! there is always a shorter way to write your code. Don't repeat yourself. JQuery Best Practices - Greg Franko http://gregfranko.com/jquery-best-practices/
UtkarshShukla7
@UtkarshShukla7
Jun 26 2016 07:18
@Slitch thanks for the link .It is very useful. :+1:
CamperBot
@camperbot
Jun 26 2016 07:18
utkarshshukla7 sends brownie points to @slitch :sparkles: :thumbsup: :sparkles:
:cookie: 49 | @slitch |http://www.freecodecamp.com/slitch
Rajdeep Roy
@RajdeepRoy
Jun 26 2016 07:25

myStr should have encoded text with the proper escape sequences and spacing.
myStr should have two tab characters \t
myStr should have one newline character \n
myStr should have a correctly escaped backslash character \
myStr should not have any spaces in between consecutive escape sequences.

\
1

2
var myStr = "Here is a backslash: .\\n\t\t Here is a new line with two tabs."; // Change this line
3

Please help
Catalin Scripcariu
@CatalinScr
Jun 26 2016 07:25

Hi, at The Simon Game I have an array with random values and I want to acces every value and with Jquery to change the opacity of the div's . The array fist has one value then 2 and so on
This is my code:

outmusic.map(function(val){

            $("#col"+val).css("opacity", "1");
            setTimeout(function(){
              $("#col"+val).css("opacity", "0.6");
        }, 800);



  })

My problem is that when array is increasing all the div's change the opacity in the same time. How can I stop at a value and the go to the next one after some seconds?

Luis Felipe López G.
@luishendrix92
Jun 26 2016 07:26
@RajdeepRoy \\nis not valid, try three backslashes and then the escaped new-line character
UtkarshShukla7
@UtkarshShukla7
Jun 26 2016 07:26
@RajdeepRoy remove the space between \t and Here
check the position of your .
Luis Felipe López G.
@luishendrix92
Jun 26 2016 07:27
@CatalinScr Use the index, multiply the 800 times the index + 1
in the setTimeOut I mean
THe callback (function) inside the map method takes not just the val but the val, the index and the array, you can use the index like this:
Rajdeep Roy
@RajdeepRoy
Jun 26 2016 07:28
@UtkarshShukla7 There is no gap btw /t
Luis Felipe López G.
@luishendrix92
Jun 26 2016 07:28
outmusic.map(function(val, index){
  var waitTime = (index + 1) * 800;
  $("#col"+val).css("opacity", "1");
  setTimeout(function(){
    $("#col"+val).css("opacity", "0.6");
  }, waitTime);
});
UtkarshShukla7
@UtkarshShukla7
Jun 26 2016 07:28
@RajdeepRoy look carefully what I said
\t Here
Catalin Scripcariu
@CatalinScr
Jun 26 2016 07:29
@luishendrix92 i will try now
Luis Felipe López G.
@luishendrix92
Jun 26 2016 07:29
@CatalinScr don't forget to add index as a parameter in the callback
you can adjust your waiting interval by changing the 800
Jeremy Howard
@jhoward0145
Jun 26 2016 07:32
question...when i am trying to resize an image...do i add the size reduction into the style sheet or underneath my new image source
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 07:33
@jhoward0145 as mentioned in the question
Gyeognphil Choi
@creativeworkers10
Jun 26 2016 07:33
I am stucked in the challenge: Stand in Line, anyone can explain me how should I pass this one?
Luis Felipe López G.
@luishendrix92
Jun 26 2016 07:34
@creativeworkers10 A queue normally works like this:
Add the new value to the array
Return the first item of the array and also delete it
Catalin Scripcariu
@CatalinScr
Jun 26 2016 07:35
@luishendrix92 is working in some parts but I want the second value to apear after the opacity of the first one become 0.6
Gyeognphil Choi
@creativeworkers10
Jun 26 2016 07:35
Thanks, I will try that way. @luishendrix92
CamperBot
@camperbot
Jun 26 2016 07:35
creativeworkers10 sends brownie points to @luishendrix92 :sparkles: :thumbsup: :sparkles:
:cookie: 804 | @luishendrix92 |http://www.freecodecamp.com/luishendrix92
Luis Felipe López G.
@luishendrix92
Jun 26 2016 07:35
@creativeworkers10 Remember .push and .shift
Gyeognphil Choi
@creativeworkers10
Jun 26 2016 07:36
@luishendrix92 Yep!! <3
michael dorsey
@mikedorsey1021
Jun 26 2016 07:36
hello everyone. I am stuck on the "golf code" exercise. problem is that i understand the basic scoring but not sure how to impliment that into code. can some please help.
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes = 1) {
    return "Hole-in-one!";
  }if (strokes <= 2){
    return "Eagle";
  }if (par = s){
    return "Par";
  }

  return "Go Home!";
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
Norvin Burrus
@ndburrus
Jun 26 2016 07:37
@creativeworkers10 have you identified the methods you'd like to use? ...this may be helpful:
Luis Felipe López G.
@luishendrix92
Jun 26 2016 07:37
@CatalinScr I haven't done that zipline yet, I'd have to play around with the timings and timeOuts, sorry that i can't help you any further
Catalin Scripcariu
@CatalinScr
Jun 26 2016 07:37
@luishendrix92 thanks for the input
CamperBot
@camperbot
Jun 26 2016 07:37
catalinscr sends brownie points to @luishendrix92 :sparkles: :thumbsup: :sparkles:
:cookie: 805 | @luishendrix92 |http://www.freecodecamp.com/luishendrix92
Norvin Burrus
@ndburrus
Jun 26 2016 07:41
@mikedorsey1021 review/check the syntax for the if/else if statement/s:
michael dorsey
@mikedorsey1021
Jun 26 2016 07:42
@ndburrus reviewing it now
Rajdeep Roy
@RajdeepRoy
Jun 26 2016 07:42
@luishendrix92 @UtkarshShukla7 Thank u all I have figured that out.
CamperBot
@camperbot
Jun 26 2016 07:42
rajdeeproy sends brownie points to @luishendrix92 and @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 806 | @luishendrix92 |http://www.freecodecamp.com/luishendrix92
:cookie: 729 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
UtkarshShukla7
@UtkarshShukla7
Jun 26 2016 07:45
@RajdeepRoy np :+1:
michael dorsey
@mikedorsey1021
Jun 26 2016 07:47
@ndburrus just unfinished code i haven't completed yet. let me try and revise it to see. also I am not sure how to say pseudocode: "if strokes is 2 less than par, then return 'eagle'." just not sure how to write out that expression
Leonid S. Knyshov
@wiseleo
Jun 26 2016 07:49
@mikedorsey1021 if (par - strokes >= 2) ...
michael dorsey
@mikedorsey1021
Jun 26 2016 07:49
@ndburrus good catch on the '=='.
@wiseleo I see...
@wiseleo now that i see it it makes so much sense lol
Leonid S. Knyshov
@wiseleo
Jun 26 2016 07:52
@mikedorsey1021 That challenge was interesting. I am used to doing it with objects, so all that extra typing was cumbersome. :)
shweta rajput
@ShwetaRajput
Jun 26 2016 07:52
i am having a problem in escaping quotes in java script. can anyone help?
Norvin Burrus
@ndburrus
Jun 26 2016 07:52
@mikedorsey1021 your interpretation is correct for the "strokes <= par -2". this would be the representation, if you choose to be consistent in how you're basing your condition/s (using strokes, in this scenario).
Leonid S. Knyshov
@wiseleo
Jun 26 2016 07:53
@ShwetaRajput - Let me guess, the challenge with tabs and newline characters?
Norvin Burrus
@ndburrus
Jun 26 2016 07:53
@mikedorsey1021 ...and, not too late :sparkles: that's always nice. :sparkles:
shweta rajput
@ShwetaRajput
Jun 26 2016 07:54
@wiseleo var myStr="I am a\"double quoted\" string inside \"double quotes\"";
this is my code
Leonid S. Knyshov
@wiseleo
Jun 26 2016 07:54
@ShwetaRajput Take a look at the tests. There is one more character in that string. ;)
Norvin Burrus
@ndburrus
Jun 26 2016 07:56
@RajdeepRoy ...where exactly should that . (period) be positioned? :sparkles:
shweta rajput
@ShwetaRajput
Jun 26 2016 07:56
@wiseleo no there isnt any
Norvin Burrus
@ndburrus
Jun 26 2016 07:57
@ShwetaRajput Which exercise (name) is this?
shweta rajput
@ShwetaRajput
Jun 26 2016 07:57
@ndburrus escaping literal quotes in strings from javascript
in output i can see the variable name also to which i have assigned the string
Norvin Burrus
@ndburrus
Jun 26 2016 08:00
@ShwetaRajput ok, we need to ensure the spacing is correct... :sparkles: it also looks like the puctuation needs correcting - did the period fly away? :sparkles:
Rajdeep Roy
@RajdeepRoy
Jun 26 2016 08:00
@ndburrus var myStr = "Here is a backslash: \.\n\t\tHere is a new line with two tabs.";
Hope it helps,I was away for a while.
Leonid S. Knyshov
@wiseleo
Jun 26 2016 08:01
@ShwetaRajput I am pretty sure there is one more character...
Take a very close look at
Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
shweta rajput
@ShwetaRajput
Jun 26 2016 08:03
i have written all hese characters
Norvin Burrus
@ndburrus
Jun 26 2016 08:03
@RajdeepRoy it looks like there is a backslash missing befor the period. the code for a backslash is \\. :+1: oops, typo...sorry.
Leonid S. Knyshov
@wiseleo
Jun 26 2016 08:03
about @ShwetaRajput
CamperBot
@camperbot
Jun 26 2016 08:03
:warning: no user found for shwetarajput
Leonid S. Knyshov
@wiseleo
Jun 26 2016 08:04
@ShwetaRajput What is the final character in your string before the closing quotation mark?
Rajdeep Roy
@RajdeepRoy
Jun 26 2016 08:04
@ndburrus The code ran and for backlash it is\ not//
Leonid S. Knyshov
@wiseleo
Jun 26 2016 08:04
backslash is actually \\
shweta rajput
@ShwetaRajput
Jun 26 2016 08:05
@wiseleo var myStr= "I am a\"double quoted\" string inside \"double quotes\".";
Leonid S. Knyshov
@wiseleo
Jun 26 2016 08:05
Have to double-escape the chat window
@ShwetaRajput almost correct. look at spacing between words
shweta rajput
@ShwetaRajput
Jun 26 2016 08:06
double escapemeans
Rajdeep Roy
@RajdeepRoy
Jun 26 2016 08:06
@ShwetaRajput Here var myStr= 'I am a\"double quoted\" string inside \"double quotes\".'; In this challenge there should be 2 ' and 4"
Joseph
@revisualize
Jun 26 2016 08:07
hep format
help format
CamperBot
@camperbot
Jun 26 2016 08:07

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

michael dorsey
@mikedorsey1021
Jun 26 2016 08:08
@ndburrus @wiseleo still no luck. I I'm pretty sure i have the syntax right but the code is not right. i guess i really have to understand golf to understand whats supposed to be happening but i think i get the gist of it:
```
Norvin Burrus
@ndburrus
Jun 26 2016 08:08
@RajdeepRoy have you made the final adjustment/s? :+1:
michael dorsey
@mikedorsey1021
Jun 26 2016 08:09
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes == 1) {
    return "Hole-in-one!";
  }else if (par - strokes <= 2){
    return "Eagle";
  }else if (par - strokes == 1){
    return "Birdie";
  }else if (par == strokes){
    return "Par";
  }else if (strokes - par == 1){
    return "Bogey";
  }else if (strokes - par == 2){
    return "Double Bogey";
  }else {
    return "Go Home!";
  }


  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
shweta rajput
@ShwetaRajput
Jun 26 2016 08:09
thanku everyone. it worked. as the same what i had wrote earlier
Joseph
@revisualize
Jun 26 2016 08:09
@mikedorsey1021 Your evaluations are not correct.
Rajdeep Roy
@RajdeepRoy
Jun 26 2016 08:09
@ndburrus Yeah It works fine
Joseph
@revisualize
Jun 26 2016 08:09
help golf
CamperBot
@camperbot
Jun 26 2016 08:09

:point_right: challenge golf code [wiki]

Challenge Golf Code

We will now use our knowledge about else if statements and comparison with equality, less and greater operators.

In the game of golf each hole has a par for the average number of strokes needed to sink the ball. Depending on how far above or below par your strokes are, there is a different nickname.

Your function will be passed a par and strokes. Return strings according to this table (based on order of priority - top (highest) to bottom (lowest)):

Strokes Return
1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"
>= par + 3 "Go Home!"

par and strokes will always be numeric and positive.

:pencil: read more about challenge golf code on the FCC Wiki

Norvin Burrus
@ndburrus
Jun 26 2016 08:09
@ShwetaRajput excellent. nice job! :fire:
@RajdeepRoy super :smile: way to go!
turboklerr
@turboklerr
Jun 26 2016 08:10
how do you do challenge 2 in javascript?
Sujal
@Sujal3757
Jun 26 2016 08:12
hello need help in record collection challenge
Norvin Burrus
@ndburrus
Jun 26 2016 08:12
@mikedorsey1021 the conditional statement starts by using strokes as the basis for evaluating the Strokes values (ie 1, <= par -2, par - 1, etc.). why not continue to use strokes on the left side of the condition all the way through the if/else if statement? this will support the logic, and also represents consistency. :) do you see this?
Joseph
@revisualize
Jun 26 2016 08:14
@Sujal3757 What have you done so far?
// Only change code below this line
function updateRecords(id, prop, value) {
// If prop does not contain the key "tracks", 
// then update or set the value for that incomplete prop.

// If prop does contain the key "tracks" 
// and its value is non-blank, 
// then push the value onto the end of its existing tracks array.
// If prop does not contain the key "tracks" before you update it, 
// create an empty array before pushing a track to it.

// If value is blank, 
// delete that prop.

// Always return the entire collection object.
  return collection;
}
michael dorsey
@mikedorsey1021
Jun 26 2016 08:14
@ndburrus all great points. I believe i understand now. let me try to rework
Norvin Burrus
@ndburrus
Jun 26 2016 08:16
@mikedorsey1021 what is happening is that the logic is being made incorrect by using different comparison evaluations in the conditional. clear as mud? :smile: ...there is no need to understand the game of golf - just being able to understand (and translate) the table relationships is all we need...
Sumit Kumar
@sumitk121
Jun 26 2016 08:17
@ndburrus hey
Sujal
@Sujal3757
Jun 26 2016 08:18
@revisualize this is where i have reached till now:-

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

// Only change code below this line
function updateRecords(id, prop, value) 
{
if(collection.hasOwnProperty(value)=="0")
  {
       delete collection[id].tracks;
       delete collection[id].artist;
  }
 else if(collection.hasOwnProperty(prop)!=collection[id][artist])
   {
     collection[id].artist=value;
   }
 return collection;}
// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Sumit Kumar
@sumitk121
Jun 26 2016 08:18
could u pls help me in MAKE OBJECT PROP. PRIVATE ??
Joseph
@revisualize
Jun 26 2016 08:18
@Sujal3757 You're not on the right track.
michael dorsey
@mikedorsey1021
Jun 26 2016 08:18
@ndburrus @revisualize @wiseleo finally got it. thank you for your help
CamperBot
@camperbot
Jun 26 2016 08:18
mikedorsey1021 sends brownie points to @ndburrus and @revisualize and @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @wiseleo |http://www.freecodecamp.com/wiseleo
:cookie: 728 | @ndburrus |http://www.freecodecamp.com/ndburrus
:star2: 1318 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 26 2016 08:19
@Sujal3757 I recommend re-reading the instructions.
Norvin Burrus
@ndburrus
Jun 26 2016 08:19
@mikedorsey1021 you're welcome... you are best in class!! excellent! :+1:
Sumit Kumar
@sumitk121
Jun 26 2016 08:20

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

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

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

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

var Bike = function(change) {

// Only change code below this line.
var gear;
this.setGear=function(){
return ;

};
this.getGear=function(){

};

};

var myCar = new Car();

var myBike = new Bike();

what should i change more in these codes?
@ndburrus
Andrew McKeever
@andmckvr13
Jun 26 2016 08:31
help missing letters
CamperBot
@camperbot
Jun 26 2016 08:31

:point_right: algorithm missing letters [wiki]

Algorithm Missing Letters

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

:checkered_flag: Problem Explanation:

You will create a program that will find the missing letter from a string and add it. If there is no missing letter, the program should return undefined. There is currently no test case for the string missing more than one letter, but if there was one, recursion would be used. Also, the letters are always provided in order so there is no need to sort them.

Relevant Links

:pencil: read more about algorithm missing letters on the FCC Wiki

DuyChip9901
@DuyChip9901
Jun 26 2016 08:45
a should be assigned to b with =
help me
CamperBot
@camperbot
Jun 26 2016 08:45

:point_right: adding environment variables [wiki]

Adding Envirioment Variables in Windows

Via GUI

  1. Download Varpanel.
  2. Open Varpanel.
  3. In PATH variable, add the relevant path (for example).

Via Command Line

Refer to this answer on Super User.

:pencil: read more about adding environment variables on the FCC Wiki

DuyChip9901
@DuyChip9901
Jun 26 2016 08:45
a should be assigned to b with =
help me
CamperBot
@camperbot
Jun 26 2016 08:45

:point_right: adding environment variables [wiki]

Adding Envirioment Variables in Windows

Via GUI

  1. Download Varpanel.
  2. Open Varpanel.
  3. In PATH variable, add the relevant path (for example).

Via Command Line

Refer to this answer on Super User.

:pencil: read more about adding environment variables on the FCC Wiki

Radosław
@BoguslawskiR
Jun 26 2016 08:48
I have an error with this code, "Cannot set property '0' of undefined" Can someone help me?

function chunkArrayInGroups(arr, size) {
var array=[];
var s = 0;
for(var i=0; i<Math.ceil(arr.length/size); i++)
{

  for(var j=0; j<size; j++)
    {
      if(s == arr.length){
        return array;
      }
      array[i][j]=arr[s];

      s++;
    }
}

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Sujal
@Sujal3757
Jun 26 2016 08:50
@revisualize i cannot define if else statement to target prop containing key"tracks" and update value for that incomplete prop. can U show me a single statement.
DuyChip9901
@DuyChip9901
Jun 26 2016 08:50
a should be assigned to b with =
Joseph
@revisualize
Jun 26 2016 08:50
@Sujal3757 Where does it say key tracks?
DuyChip9901
@DuyChip9901
Jun 26 2016 08:50
help me
CamperBot
@camperbot
Jun 26 2016 08:50

:point_right: adding snippets to sublime text [wiki]

Adding Snippets To Your Sublime Text Installation

If you are a user of sublime text (I hope you are, it kicks ass. You can get it here), then you may have already noticed some of the tab completion capabilities. For example, when you are opening an html tag such as <p>, it automatically closes the tag as soon as you type /. You can get similar functionality for pieces of code you end up re-writing over and over, and it's surprisingly easy!

Here's an example, which activates after typing div and then tab:

alt text

:pencil: read more about adding snippets to sublime text on the FCC Wiki

Joseph
@revisualize
Jun 26 2016 08:50
@DuyChip9901 You're not making any sense.
@Sujal3757 I guess it does. Odd.
Mustafijur rahman
@Dinar717
Jun 26 2016 08:51
about @revisualize
CamperBot
@camperbot
Jun 26 2016 08:51
:star2: 1319 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 26 2016 08:51
@Dinar717 stalker.
Norvin Burrus
@ndburrus
Jun 26 2016 08:52
This message was deleted
Mustafijur rahman
@Dinar717
Jun 26 2016 08:53
@revisualize lol this is not true.
Narapureddy Nethaji Reddy
@nethajireddy
Jun 26 2016 08:53
Smallest Common Multiple challenge help? is challenge working rightly?
Sujal
@Sujal3757
Jun 26 2016 08:53
@revisualize i am so confused about writing a statement can u review it and just state a single statement as a hint so i could progress further
DuyChip9901
@DuyChip9901
Jun 26 2016 08:54
help me
CamperBot
@camperbot
Jun 26 2016 08:54

:point_right: adding environment variables [wiki]

Adding Envirioment Variables in Windows

Via GUI

  1. Download Varpanel.
  2. Open Varpanel.
  3. In PATH variable, add the relevant path (for example).

Via Command Line

Refer to this answer on Super User.

:pencil: read more about adding environment variables on the FCC Wiki

Joseph
@revisualize
Jun 26 2016 08:56
@DuyChip9901 EXPLAIN YOUR PROBLEM! Give more context. We can't help you if we don't know what the hell you're trying to do.
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 08:56
can someone tell me why is my js not running properly?
Joseph
@revisualize
Jun 26 2016 08:57
@DuyChip9901 Saying "help me" over and over and over does nothing to give us more context to your problem or what you need help with.
@DuyChip9901 All you're doing by saying "help me" is causing @camperbot to flood chat over and over again.
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 08:57
whatever data present in the api should be added in the html
and i'm not doing the weather app yet, i'll just hve to get the data from api and add it in htm
can someone tell why is it not working?
DuyChip9901
@DuyChip9901
Jun 26 2016 08:59
i write "var a = b;"
it's not working
it says "a should be assigned to b with ="
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 08:59
@DuyChip9901 did you declare var b?
DuyChip9901
@DuyChip9901
Jun 26 2016 08:59
yes
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 08:59
@DuyChip9901 did you declare 'a' before?
@DuyChip9901 and a should be assigned to b means b=a not a=b
@revisualize
DuyChip9901
@DuyChip9901
Jun 26 2016 09:01
sorry but thank you to explain my problem
Norvin Burrus
@ndburrus
Jun 26 2016 09:03
@BoguslawskiR review/check the logic here: "i < Math.ceil ( arr.length / size ); i++" hint: the bold items need attention... can you also explain the strategy you'd like to use? for the first part, here: splits an array (first argument) into groups the length of size (second argument)
purnendutiwari
@purnendutiwari
Jun 26 2016 09:04
hi everyone... I have cleared challenge "Record Collection"
but i have need some clarification
Norvin Burrus
@ndburrus
Jun 26 2016 09:04
@DuyChip9901 Which exercise (name) is this? can you post your code?
help format @DuyChip9901
CamperBot
@camperbot
Jun 26 2016 09:04

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

purnendutiwari
@purnendutiwari
Jun 26 2016 09:05
this is working code

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

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

  }

  return collection;
}

// Alter values below to test your code
updateRecords(1245, "tracks", "Addicted to Love");
if I try this
delete collection[id].prop;
it doesn't work
i just want to know the reason it's not working
Mustafijur rahman
@Dinar717
Jun 26 2016 09:06
@purnendutiwari it won't because prop is a variable here
purnendutiwari
@purnendutiwari
Jun 26 2016 09:07
@Dinar717 how can I know if it's a property or a variable
Victor
@Vicktorius
Jun 26 2016 09:07
hello guys, can somebody help with this challange please

function nextInLine(arr, item) {
// Your code here
arr.push(["item"]);
var removed = arr.shift();

return removed; // Change this line
}

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

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

Narapureddy Nethaji Reddy
@nethajireddy
Jun 26 2016 09:07
Smallest Common Multiple challenge help? is challenge working rightly?
Mustafijur rahman
@Dinar717
Jun 26 2016 09:08
here "tracks" is a property directly.
@purnendutiwari
Leonid S. Knyshov
@wiseleo
Jun 26 2016 09:08
@purnendutiwari Here prop is actually a function parameter, which is always a variable unless hardcoded in the function declaration.
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:08
@Vicktorius arr.push(item) not arr.push(["item"])
Norvin Burrus
@ndburrus
Jun 26 2016 09:08
@Vicktorius what type of data does item represent? here: arr.push(["item"]);
Mustafijur rahman
@Dinar717
Jun 26 2016 09:08
but prop="tracks" or something else.
purnendutiwari
@purnendutiwari
Jun 26 2016 09:08
@Dinar717: I guess I am confused between property and variable
Mustafijur rahman
@Dinar717
Jun 26 2016 09:09
@purnendutiwari that means prop could have any value. but property is a value itself
@purnendutiwari
Leonid S. Knyshov
@wiseleo
Jun 26 2016 09:09
@purnendutiwari Properties are variables stored on an object.
Victor
@Vicktorius
Jun 26 2016 09:09
@Krish2704 I changed it, still doesnt work
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:09
@purnendutiwari properties are the ones which you have in an object and a variable can have anything
@Vicktorius show me your code again
Sujal
@Sujal3757
Jun 26 2016 09:09
@purnendutiwari thanks dude...
i thought of using selection from collection[id][tracks] but i think i was wrong in this cas
CamperBot
@camperbot
Jun 26 2016 09:09
sujal3757 sends brownie points to @purnendutiwari :sparkles: :thumbsup: :sparkles:
:cookie: 226 | @purnendutiwari |http://www.freecodecamp.com/purnendutiwari
Victor
@Vicktorius
Jun 26 2016 09:10

@Krish2704 function nextInLine(arr, item) {
// Your code here
arr.push("item");
var removed = arr.shift();

return removed; // Change this line
}

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

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

Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:10
@wiseleo about
Norvin Burrus
@ndburrus
Jun 26 2016 09:10
@Vicktorius how are we doing? ...see previous comment :point_up: June 26, 2016 5:08 AM
Victor
@Vicktorius
Jun 26 2016 09:10
@ndburrus stuck at this challange..
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:10
@Vicktorius not in quotes, just write item
about @wiseleo
CamperBot
@camperbot
Jun 26 2016 09:10
:cookie: 226 | @wiseleo |http://www.freecodecamp.com/wiseleo
Norvin Burrus
@ndburrus
Jun 26 2016 09:10
This message was deleted
Victor
@Vicktorius
Jun 26 2016 09:10
@Krish2704 oh thanks man
CamperBot
@camperbot
Jun 26 2016 09:10
vicktorius sends brownie points to @krish2704 :sparkles: :thumbsup: :sparkles:
:cookie: 477 | @krish2704 |http://www.freecodecamp.com/krish2704
purnendutiwari
@purnendutiwari
Jun 26 2016 09:11
@Dinar717 @Krish2704 thanks guys, i will try to read more about it, atleast now i know what was the mistake
CamperBot
@camperbot
Jun 26 2016 09:11
purnendutiwari sends brownie points to @dinar717 and @krish2704 :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @dinar717 |http://www.freecodecamp.com/dinar717
:cookie: 478 | @krish2704 |http://www.freecodecamp.com/krish2704
Victor
@Vicktorius
Jun 26 2016 09:12
@Krish2704 So you dont write arguments with [""] ?
I mean when you take them out
push*
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:13
@Vicktorius arr.push(variable) that's the syntax
Victor
@Vicktorius
Jun 26 2016 09:13
@Krish2704 yeah,but i mean in other challanges they were putting them in [""]
Andrew McKeever
@andmckvr13
Jun 26 2016 09:13
help boo who
CamperBot
@camperbot
Jun 26 2016 09:13

:point_right: algorithm boo who [wiki]

Algorithm Boo Who

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

Problem Explanation:

This program is very simple, the trick is to understand what a boolean primitive is. The programs requires a true or false answer.

Relevant Links

:pencil: read more about algorithm boo who on the FCC Wiki

Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:13
@Vicktorius nope
Chris Jolley
@bitfed
Jun 26 2016 09:14
Is anyone familiar with PhantomJS? I'm having trouble figuring out how to login to a website. This is what I have so far: https://gist.github.com/5e6e7b3a0d4ea1df441f1bbfc7a42435
Norvin Burrus
@ndburrus
Jun 26 2016 09:14
@Vicktorius this may be useful:
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:14
@Vicktorius take a look at this link
@Vicktorius they are pushing the whole array there which strings. you'll use here quotes too when its a string
Victor
@Vicktorius
Jun 26 2016 09:16
@Krish2704 ok so a string has multiple "levels" and in a function that's not the same
Chris Jolley
@bitfed
Jun 26 2016 09:18
Cool, thanks @ndburrus !
CamperBot
@camperbot
Jun 26 2016 09:18
bitfed sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 729 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jun 26 2016 09:18
@bitfed you're welcome! enjoy... :sparkles:
Edmund To
@edmundtfy
Jun 26 2016 09:21

Hello... I don't understand:
GIVEN Regular expression to find total number of white space

var expression = /\s+/g;

WHY finding total number of non-white space is

var expression = /\S/g;

BUT NOT with the plus

var expression = /\S+/g;
Abhisek Pattnaik
@abhisekp
Jun 26 2016 09:24
@edmundtfy bcz u r using the 'g' (global) flag
Stephen James
@sjames1958gm
Jun 26 2016 09:24
@edmundtfy The first will find each instance of 1 or more consecutive white space characters. The second will find each instance of one non-white space character. The last will find every instance of 1 or more white non-space characters. If you want to count the individual characters you the + cannot be used because it chunks the characters together.
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:25
can someone tell me why is this not working
Jamal
@JamalPolaya
Jun 26 2016 09:25
I get stuck at this code

var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:

 count+=1;

break;
case 7:
case 8:
case 9:

  count+=0;

break;
case 10:
case 'J':
case 'Q':
case 'k':
case 'A':

  count-=0;
  break;

}
return count + (count > 0 ? " Bet" : " Hold");
// Only change code above this line
}

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

Mustafijur rahman
@Dinar717
Jun 26 2016 09:25
@edmundtfy go here http://regexr.com/ and try yourself.
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:26
the data from api should be added in the html part
Stephen James
@sjames1958gm
Jun 26 2016 09:26
@JamalPolaya Watch the case of J, Q, K, A
Edmund To
@edmundtfy
Jun 26 2016 09:26
@sjames1958gm thanks a lot! totally cleared it up, thanks!
CamperBot
@camperbot
Jun 26 2016 09:26
edmundtfy sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1651 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 26 2016 09:26
@edmundtfy :+1:
Narapureddy Nethaji Reddy
@nethajireddy
Jun 26 2016 09:27
Smallest Common Multiple challenge help
Öznur
@otznua
Jun 26 2016 09:27

hello guys can you help me with this instructions; Instructions
Assign the value 7 to variable a.

Assign the contents of a to variable b.

couldn't make it work
my codes: var a;
var b = 2;
var a = 7;
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:28
@sjames1958gm can you help me
Stephen James
@sjames1958gm
Jun 26 2016 09:28
@Krish2704 sure
Jamal
@JamalPolaya
Jun 26 2016 09:28
@sjames1958gm sorry i doo not understand please more clear
Stephen James
@sjames1958gm
Jun 26 2016 09:28
@JamalPolaya Look at case 'k': it should be case 'K':
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:29
@sjames1958gm posted my question above
just a minute back
@otznua you're declaring variable a again
Stephen James
@sjames1958gm
Jun 26 2016 09:29
stand in line?
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:30
@sjames1958gm
apis data should be added in html
Jamal
@JamalPolaya
Jun 26 2016 09:30
@sjames1958gm I modified it but it does not run
Stephen James
@sjames1958gm
Jun 26 2016 09:32
@Krish2704 dump is an id so it needs $("#dump") not $(".dump")
Also, you don't have jquery loaded into your pen click setting.
@JamalPolaya what is count -= 0 supposed to be doing
Jamal
@JamalPolaya
Jun 26 2016 09:33
@sjames1958gm Oh thanks .Done!
CamperBot
@camperbot
Jun 26 2016 09:33
jamalpolaya sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1652 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 26 2016 09:33
@JamalPolaya :+1:
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:33
@sjames1958gm no dump is a class
Norvin Burrus
@ndburrus
Jun 26 2016 09:34
@otznua Which exercise (name) is this?
Victor
@Vicktorius
Jun 26 2016 09:34

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

// Setup
function trueOrFalse(wasThatTrue) {

// Only change code below this line.
if (wasThatTrue) {
return "Yes,that was true";
}
return "No,that was false";

// Only change code above this line.

}

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

Is there something wrong?
Norvin Burrus
@ndburrus
Jun 26 2016 09:35
@Vicktorius Which exercise (name) is this?
Victor
@Vicktorius
Jun 26 2016 09:35
@ndburrus Use Conditional Logic with If Statements
Mustafijur rahman
@Dinar717
Jun 26 2016 09:35
This message was deleted
Stephen James
@sjames1958gm
Jun 26 2016 09:35
@Krish2704 Oh, did not see that. But you still need jquery loaded - I you keep your devtools console open you would have seen $ is not defined which is a clue that jquery is not loaded.
Tomasz Klekner
@TomAlus
Jun 26 2016 09:36
if (wasThatTrue) {
return "Yes,that was true";
}
return "No,that was false";
@Vicktorius you're missing the else part of the statement
Stephen James
@sjames1958gm
Jun 26 2016 09:37
@Vicktorius make sure that you are returning the exact string with the correct spacing.
@TomAlus If the if is returning the else is not strictly required.
Norvin Burrus
@ndburrus
Jun 26 2016 09:37
@Vicktorius ...we need to carefully review the instructions... here: `Create an if statement inside the function to return "Yes, that was true " :sparkles: ...see what's happening?
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:37
@sjames1958gm i've added jquery now
and it's still not workking
Tomasz Klekner
@TomAlus
Jun 26 2016 09:38
true, but it's a good habit to write it, or at least that's what I usually do :-)
Victor
@Vicktorius
Jun 26 2016 09:38
@TomAlus where do I put the else part=
?
Tomasz Klekner
@TomAlus
Jun 26 2016 09:39
You don't need to in this exercise.
Mustafijur rahman
@Dinar717
Jun 26 2016 09:39
@Vicktorius no need to put else
Stephen James
@sjames1958gm
Jun 26 2016 09:39
@Krish2704 if you are using chrome - then getCurrentPosition may not be available. The latest chrome's 50+ require https to use that api. There is a website ip-api.com which can provide location based on ip address. Devtools console showed this error
Tomasz Klekner
@TomAlus
Jun 26 2016 09:39
@Vicktorius you've omitted the space in the sentence after the coma
Victor
@Vicktorius
Jun 26 2016 09:39
@Dinar717 so,what am I doing wrong? (
Tomasz Klekner
@TomAlus
Jun 26 2016 09:40

return "Yes,that was true";

return "Yes, that was true";

Norvin Burrus
@ndburrus
Jun 26 2016 09:40
@Vicktorius see previous comment :point_up: June 26, 2016 5:37 AM :sparkles:
Mercedes Smith
@mercedessmith
Jun 26 2016 09:40
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line



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

// Change this value to test
caseInSwitch(1);
Mustafijur rahman
@Dinar717
Jun 26 2016 09:41
@TomAlus is right. @Vicktorius
Mercedes Smith
@mercedessmith
Jun 26 2016 09:41
Hey guys! Can anyone offer me any advice on this challenge switch statements
Mustafijur rahman
@Dinar717
Jun 26 2016 09:41
you are missing space
Norvin Burrus
@ndburrus
Jun 26 2016 09:41
@mercedessmith Which exercise (name) is this? :sparkles:
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:41
@sjames1958gm should I add http:// before my link?
@mercedessmith what's your task?
Mercedes Smith
@mercedessmith
Jun 26 2016 09:41
Selection from many options with switch statements
Jamal
@JamalPolaya
Jun 26 2016 09:41

@mercedessmith
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch(val){
case 1:
return ("alpha");
break;
case 2 :
return("beta");
break;
case 3:
return("gamma");
break;
case 4:
return("delta");
}

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

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

Mercedes Smith
@mercedessmith
Jun 26 2016 09:42
I've tried a few different things but I must be off base
Stephen James
@sjames1958gm
Jun 26 2016 09:42
@Krish2704 yes, before api.openweather
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:42
@mercedessmith try something and post the code
Norvin Burrus
@ndburrus
Jun 26 2016 09:42
@mercedessmith ok, we need to follow the example code switch statement syntax, see it? the data for the conditional is in the table/chart under instructions near the bottom.... find it?
Brian Phillips
@unipheas
Jun 26 2016 09:42
Let’s say I want to target a specific element in the DOM. Can I do document.getElementByID().getElementByClassName().getElementByTagName()?
Jamal
@JamalPolaya
Jun 26 2016 09:42
@ndburrus Yes thanks alot
CamperBot
@camperbot
Jun 26 2016 09:42
jamalpolaya sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 733 | @ndburrus |http://www.freecodecamp.com/ndburrus
Tomasz Klekner
@TomAlus
Jun 26 2016 09:42
I recommend MDN for references
Victor
@Vicktorius
Jun 26 2016 09:42
thanks guys
Stephen James
@sjames1958gm
Jun 26 2016 09:44
@unipheas Some of those names are wrong getElementsByClassName notice Elements - and these return arrays, so you would need [0] if you know it is the only (or first) value.
Mercedes Smith
@mercedessmith
Jun 26 2016 09:44
Yes I saw it, Then I went to the support link given for more info and I think I honestly just overcomplicated it after seeing what @JamalPolaya shared.
I was trying to give the values a name
Stephen James
@sjames1958gm
Jun 26 2016 09:44
document.getElementByID().getElementsByClassName()[0].getElementsByTagName()[0] @unipheas
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:45
@mercedessmith can you try something and post again? It's good to give it a go , even though you don't get it
@sjames1958gm I PMed you
Brian Phillips
@unipheas
Jun 26 2016 09:45
@sjames1958gm so if there is only 1 class and 1 tag under the ID then that should be okay, right?
Jamal
@JamalPolaya
Jun 26 2016 09:45
@mercedessmith Did you solved it ?
Brian Phillips
@unipheas
Jun 26 2016 09:47
@ndburrus @sjames1958gm Thanks
CamperBot
@camperbot
Jun 26 2016 09:47
unipheas sends brownie points to @ndburrus and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 734 | @ndburrus |http://www.freecodecamp.com/ndburrus
:star2: 1653 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Norvin Burrus
@ndburrus
Jun 26 2016 09:47
@JamalPolaya you're welcome! nicely done... :fire:
@unipheas you're welcome! anytime :+1:
Narapureddy Nethaji Reddy
@nethajireddy
Jun 26 2016 09:48
help Smallest Common Multiple
CamperBot
@camperbot
Jun 26 2016 09:48

:point_right: algorithm smallest common multiple [wiki]

Algorithm Smallest Common Multiple

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

:checkered_flag: Problem Explanation:

The smallest common multiple between two numbers is the smallest number that both numbers can divide into. This concept can be extended to more than two numbers as well.

We can first start with just finding the smallest common multiple between two numbers. Naively, you can start writing out multiple of each number until you write a multiple that exists from both numbers.

An example would be the numbers 3 and 4. The multiples of 3 are 3, 6, 9, 12, 15, 18, ... and the multiples of 4 are 4, 8, 12, 16, 20, .... The first smallest number we run into in both lists is 12 so this is the smallest common multiple between 3 and 4.

This problem can be confusing because most people look for the smallest common multiple of just the two numbers but forget the keyword range. However, this means that if you are given [1,5], then you have to check for the smallest common multiple for all the numbers [1,2,3,4,5] that is evenly divisible by all of them.

Relevant Links

:pencil: read more about algorithm smallest common multiple on the FCC Wiki

Edmund To
@edmundtfy
Jun 26 2016 09:48

What does free code camp teach this one:

var Car = function(a,b,c) { code here }

but not this one

function Car(a,b,c) { code here }

doesn't the second one skip creating a useless variable?

Alex T.
@lx-t
Jun 26 2016 09:49
@Krish2704 Use http:// in your link variable. Also you do not have API key in your link. http://openweathermap.org/api (To access the API you need to sign up for an API key if you are on a free or paid plan.
)
Jason Keenan
@raavin
Jun 26 2016 09:49
Mmmmm, is there something going on with ip-api.com??? I just checked my weather app and it was showing the wrong location, went directly to ip-api.com and, sure enough, wrong location????
Brian Phillips
@unipheas
Jun 26 2016 09:49
@ndburrus Ah, that’s jQuery. I can’t use that. I need to stick with actual JS
96street
@96street
Jun 26 2016 09:49
For the Weather App challenge I used getJSON but I saw many other people use ajax. Can someone please explain the different and when to use each method?
Mercedes Smith
@mercedessmith
Jun 26 2016 09:49
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  case 1:
  return "Alpha";
  break;

  case 2:
  return "Beta";
  break;

  case 3:
  return "Gamma";
  break;

  case 4:
  return "Delta"; 
  break;




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

// Change this value to test
caseInSwitch(1);
Norvin Burrus
@ndburrus
Jun 26 2016 09:49
@unipheas hmmmm... moment...
Mercedes Smith
@mercedessmith
Jun 26 2016 09:50
It still didn't work. Not sure what I'm doing wrong.
Alex T.
@lx-t
Jun 26 2016 09:50
@96street $.getJSON actually calls $.ajax
Tomasz Klekner
@TomAlus
Jun 26 2016 09:50
@edmundtfy read about function declaration vs function expression
96street
@96street
Jun 26 2016 09:50
so JSON is basically a shortcut? @lx-t
Norvin Burrus
@ndburrus
Jun 26 2016 09:51
@mercedessmith carefully examine the return values. example, here: Alpha . we need: caseInSwitch(1) should have a value of "alpha" :sparkles: right?
Tomasz Klekner
@TomAlus
Jun 26 2016 09:51
and hoisting in conjunction with that topic
Leonid S. Knyshov
@wiseleo
Jun 26 2016 09:51
@edmundtfy Oh there is a very specific reason for this. It has to do with function hoisting.
Alex T.
@lx-t
Jun 26 2016 09:51
@96street Yes. http://api.jquery.com/jquery.getjson/
The documentation says:
This is a shorthand Ajax function, which is equivalent to:
$.ajax({
  dataType: "json",
  url: url,
  data: data,
  success: success
});
Stephen James
@sjames1958gm
Jun 26 2016 09:51
@96street $.ajax is an interface that provides much more control over the request / response. getJSON is basically a wrapper around $.ajax that handles a lot of that including the parsing of the response from string to json.
Jamal
@JamalPolaya
Jun 26 2016 09:51
@mercedessmith you do not write the switch before case 1
96street
@96street
Jun 26 2016 09:52
what does parsing mean? @sjames1958gm
Stephen James
@sjames1958gm
Jun 26 2016 09:52
@unipheas yes
96street
@96street
Jun 26 2016 09:52
So in many situations you can't use JSON....can you give an example?
Jamal
@JamalPolaya
Jun 26 2016 09:53
@mercedessmith switch(val){
case 1:
return ("alpha");
break;
case 2 :
return("beta");
break;
case 3:
return("gamma");
break;
case 4:
return("delta");
}
Stephen James
@sjames1958gm
Jun 26 2016 09:53
@96street converting a string into a javascript object.
@96street Some apis return XML, or possibly some other format for the data. JSON has become more an more popular that is why there is a getJSON function.
Anush Reddy
@anushreddy
Jun 26 2016 09:54
how to remove all non-alphanumeric characters ?
96street
@96street
Jun 26 2016 09:54
thanks @sjames1958gm @lx-t
CamperBot
@camperbot
Jun 26 2016 09:54
96street sends brownie points to @sjames1958gm and @lx-t :sparkles: :thumbsup: :sparkles:
:cookie: 369 | @lx-t |http://www.freecodecamp.com/lx-t
:star2: 1654 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Norvin Burrus
@ndburrus
Jun 26 2016 09:54
@anush6533 Which exercise (name) is this?
Anush Reddy
@anushreddy
Jun 26 2016 09:54
checking palindrome
Alex T.
@lx-t
Jun 26 2016 09:55
@96street For example you can use .ajax and pass it a parameter saying to not use a cache. Using .getJSON you'd need to use a separate function call to do that.
Anush Reddy
@anushreddy
Jun 26 2016 09:55
@ndburrus
shweta rajput
@ShwetaRajput
Jun 26 2016 09:55
can someone help me with escape squences in strings
96street
@96street
Jun 26 2016 09:55
@lx-t what does not using a cache mean and how would you express that in an ajax function
Jason Keenan
@raavin
Jun 26 2016 09:55
@mercedessmith given that you have a variable 'answer' and it returns answer, it might be worth looking at that rather than returning the string for each case
Stephen James
@sjames1958gm
Jun 26 2016 09:56
@anush6533 read down a bit
Anush Reddy
@anushreddy
Jun 26 2016 09:56
@sjames1958gm okay
Norvin Burrus
@ndburrus
Jun 26 2016 09:56
@mercedessmith see previous comment! :point_up: June 26, 2016 5:51 AM :sparkles:
Brian Phillips
@unipheas
Jun 26 2016 09:56

@sjames1958gm This is what I’m writing but it doesn’t seem to be working.

document.getElementById(“bannerlogopic”).getElementsByClassName("et_pub_lightbox_image")[0].getElementsByTagName("img")[0].href="/wp-content/uploads/2016/06/qrcode.png";

Essentially I’m trying to hack a wp site to display a different image in its lightbox instead of the actual image on the dom.

shweta rajput
@ShwetaRajput
Jun 26 2016 09:56
can someone help me wih escape sequnces in strings
Leonid S. Knyshov
@wiseleo
Jun 26 2016 09:57
@ShwetaRajput That challenge is buggy. Ignore the preview and rely solely on tests.
Stephen James
@sjames1958gm
Jun 26 2016 09:57
@unipheas What I would do, is go to that site, open devtools console and try, from left to right, that command to see what might not be working.
Edmund To
@edmundtfy
Jun 26 2016 09:57
@wiseleo wow that is a deep topic! thanks!
CamperBot
@camperbot
Jun 26 2016 09:57
edmundtfy sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 228 | @wiseleo |http://www.freecodecamp.com/wiseleo
Brian Phillips
@unipheas
Jun 26 2016 09:57
@sjames1958gm alright, thanks
CamperBot
@camperbot
Jun 26 2016 09:57
unipheas sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: unipheas already gave sjames1958gm points
shweta rajput
@ShwetaRajput
Jun 26 2016 09:58
@wiseleo so do i not need to do that task?
Norvin Burrus
@ndburrus
Jun 26 2016 09:58
@ShwetaRajput can you post your code so far?
Leonid S. Knyshov
@wiseleo
Jun 26 2016 09:58
@edmundtfy interestingly, most explanations of it are wrong, including one that sounded authoritative.
Stephen James
@sjames1958gm
Jun 26 2016 09:59
@mercedessmith Not sure where you are now, but the last code I saw was missing the instruction for what variable to test.
switch (val) { at the top and } to close that near the bottom
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:59
@sjames1958gm
Leonid S. Knyshov
@wiseleo
Jun 26 2016 09:59
@ShwetaRajput You can complete the task, just don't rely on the preview in the black box above the tests. That one is broken.
Alex T.
@lx-t
Jun 26 2016 09:59

@96street Well, disabling caching is not a good idea but I had an issue with some API when I needed to disable browser caching the results.

$.ajaxSetup({ cache: false });
$.getJSON(usr, callback);

And using .ajax:

$.ajax({
    url: '#',
    cache: false
}).done(callback);
Krishna Sai Gullapalli
@Krish2704
Jun 26 2016 09:59
i've added apikey too
Norvin Burrus
@ndburrus
Jun 26 2016 09:59
@mercedessmith how are we doing?
shweta rajput
@ShwetaRajput
Jun 26 2016 10:00
@ndburrus "Here is a backslash: backslash.newline tab tab Here is a new line with two tabs."
this is what i have to write in output
Edmund To
@edmundtfy
Jun 26 2016 10:00
@wiseleo really? I learnt that variable hoisting are auto-declared as "undefined" at top of JS, while function definition hoisting only occurs for function declarations, not function expressions. So using function expression can avoid defining the function early?
Leonid S. Knyshov
@wiseleo
Jun 26 2016 10:00
@ShwetaRajput Yep... that one is buggy. It's easy enough to do as long as you only rely on tests and ignore the preview.
96street
@96street
Jun 26 2016 10:00
@lx-t gotcha
shweta rajput
@ShwetaRajput
Jun 26 2016 10:01
@wiseleo can you tell me the code which i have to perform
Leonid S. Knyshov
@wiseleo
Jun 26 2016 10:01
@edmundtfy Right, they get hoisted to the top and then declared as undefined until they get re-initialized.
Alex T.
@lx-t
Jun 26 2016 10:01
@96street .ajax is more configurable and complete function to handle API requests. .getJSON is just simplified and more convenient version of it.
Gary Siu
@GarySiu
Jun 26 2016 10:01
@HTMLNoob It's important to distinguish that it's Object.keys() not object.keys / Object.prototype.keys() You're calling the method on the class not the instance.
Norvin Burrus
@ndburrus
Jun 26 2016 10:01
@ShwetaRajput ok. refer to the Code/Output table and translate the characters that need to be escaped... :sparkles: hint: be very careful with the spacing, and model the sentence precisely...
Leonid S. Knyshov
@wiseleo
Jun 26 2016 10:01
@ShwetaRajput That would not be educational for you. It's important to understand escape strings. :)
Edmund To
@edmundtfy
Jun 26 2016 10:02
@wiseleo awesome language! haha
Mercedes Smith
@mercedessmith
Jun 26 2016 10:02
@ndburrus Lost. I feel like I'm somehow getting myself even more confused.
Leonid S. Knyshov
@wiseleo
Jun 26 2016 10:02
@edmundtfy If I want to torture someone at an interview, I'll ask him about hoisting.
Norvin Burrus
@ndburrus
Jun 26 2016 10:03
@mercedessmith no worries... let's start with identifying the sample code switch statement, see it?
Edmund To
@edmundtfy
Jun 26 2016 10:03
@wiseleo sounds fun!
Gary Siu
@GarySiu
Jun 26 2016 10:03
@wiseleo Ever had anyone fleeing the room screaming "TEMPORAL DEAD ZOOOOOOOOOOOOONE"?
Leonid S. Knyshov
@wiseleo
Jun 26 2016 10:04
@GarySiu Not yet. What have you asked to get someone to that point?
Gary Siu
@GarySiu
Jun 26 2016 10:05
@wiseleo Haven't yet but introducing someone to hoisting when they've started using ES6 before they understood hoisting in ES5 was rocky
Brendan Kinahan
@BKinahan