These are chat archives for FreeCodeCamp/HelpJavaScript

17th
Jun 2017
Jorge Luis Vazquez
@zentech
Jun 17 2017 00:00

ok apparently I got it right this time. but I wonder if someone has a better approach ---> var count = 0;

function cc(card) {
// Only change code below this line
if(card <= 6) {
count += 1;
}
if (card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A') {
count -= 1;
}

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

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

koder3
@koder3
Jun 17 2017 00:00
doesnt work @XLpacman805
Manish Giri
@Manish-Giri
Jun 17 2017 00:01
@zentech you could use a switch instead.
Nothing else to optimize.
Jorge Luis Vazquez
@zentech
Jun 17 2017 00:01
@Manish-Giri thanks... yeah that's what I thought
CamperBot
@camperbot
Jun 17 2017 00:01
zentech sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6010 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 17 2017 00:01
:+1:
koder3
@koder3
Jun 17 2017 00:02
@Manish-Giri can you help me?
Manish Giri
@Manish-Giri
Jun 17 2017 00:03
@koder3 which challenge?
koder3
@koder3
Jun 17 2017 00:03
function pairElement(str) {

var d = str.split("");

var e = [];
for (var i = 0; i < d.length; i++) {
e.push(d.slice(i, i + 1));
}
return e[2] === ["C"]

}
pairElement("ATCGA");
why does this return me false i entered the exact same thing as e[2] and i got false. how do i make it true
Manish Giri
@Manish-Giri
Jun 17 2017 00:04
@koder3 which challenge?
koder3
@koder3
Jun 17 2017 00:04
DNA pairing
Manish Giri
@Manish-Giri
Jun 17 2017 00:05
you need to return an array right?
Take each character, get its pair, and return the results as a 2d array.
BrandonTeso
@BrandonTeso
Jun 17 2017 00:06
How do I complete Stand in Line?
koder3
@koder3
Jun 17 2017 00:06
i know, i have a doubt relating something else
@Manish-Giri
i want it to return true as i entered the same thing that is in e[2]. but it returns false
return e[2] gives me ["C"]
Frank McCroy
@fmccroy
Jun 17 2017 00:07
@koder3 Possibly put in a few console.log ’s to see what is going on, and verify things are happening how you think they should be.
koder3
@koder3
Jun 17 2017 00:08
but return e[2] === ["C"] gives me false
how do i make it true
Nefton
@neftonjin
Jun 17 2017 00:08
hi . how can i make that print screen with the code and post it here ?
Manish Giri
@Manish-Giri
Jun 17 2017 00:08
@koder3 you're comparing two arrays
don't think you can compare them like that
koder3
@koder3
Jun 17 2017 00:08
but the arrays are the same
how do i compare it
Manish Giri
@Manish-Giri
Jun 17 2017 00:09
use a library like underscore
Frank McCroy
@fmccroy
Jun 17 2017 00:09
e2 === “C” would work better, wouldn’t it?
koder3
@koder3
Jun 17 2017 00:10
it returns false @fmccroy
Manish Giri
@Manish-Giri
Jun 17 2017 00:10
without the [ ]
Frank McCroy
@fmccroy
Jun 17 2017 00:10
Even without the [ ] it returns false?
koder3
@koder3
Jun 17 2017 00:10
return e[2] === "C" returns false
Manish Giri
@Manish-Giri
Jun 17 2017 00:10
because one is an array
and one is string
e is a 2d array
[["A"], ["T"], ["C"], ["G"], ["A"]]
koder3
@koder3
Jun 17 2017 00:11
return e[2] === e[2] gives true however
Frank McCroy
@fmccroy
Jun 17 2017 00:11
So using the strict === is messing him up? == would give the answer @koder3 wants?
Manish Giri
@Manish-Giri
Jun 17 2017 00:12
probably
koder3
@koder3
Jun 17 2017 00:12
@fmccroy that gave true for return e[2] == "C"
@fmccroy thanks
CamperBot
@camperbot
Jun 17 2017 00:12
koder3 sends brownie points to @fmccroy :sparkles: :thumbsup: :sparkles:
:cookie: 349 | @fmccroy |http://www.freecodecamp.com/fmccroy
koder3
@koder3
Jun 17 2017 00:12
i think ill use that
whats difference between == and ===
i know === is strict equality
Frank McCroy
@fmccroy
Jun 17 2017 00:13
Cool. It worked because == does not check for types, while === does compare types.
koder3
@koder3
Jun 17 2017 00:13
oh
alright
Frank McCroy
@fmccroy
Jun 17 2017 00:13
Comparing a string to an array made it fail, due to different types.
Manish Giri
@Manish-Giri
Jun 17 2017 00:14
I wouldn't use == over === though
koder3
@koder3
Jun 17 2017 00:14
but then i compared it to an array at start
Manish Giri
@Manish-Giri
Jun 17 2017 00:14
but that's just me
koder3
@koder3
Jun 17 2017 00:14
why is it false
i compared it to what it exactly is
Manish Giri
@Manish-Giri
Jun 17 2017 00:15
you compared the value
not the types
also
koder3
@koder3
Jun 17 2017 00:17
brb
Manish Giri
@Manish-Giri
Jun 17 2017 00:18
var test = ["A"];
var test1 = test;

console.log(test === test1); //true

var test2 = ["A"];
console.log(test === test2); //false
arrays are passed as references
Frank McCroy
@fmccroy
Jun 17 2017 00:20
There are a lot of details to remember! But you are referring to they have different addresses in memory, so we can just compare them like other types of variables?
err.. *can't
Nefton
@neftonjin
Jun 17 2017 00:21
hi guys can someone help my with the Stand in line challange ?
This is my code

function nextInLine(arr, item) {
  // Your code here
            arr.push(1);

  return    arr.shift() ;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr,10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
pahosler
@pahosler
Jun 17 2017 00:22
@moigithub your answer looks incorrect, and it doesn't delay for the time entered, the method call is supposed to be callAfter.sum(5000,8,9) not sum.callAfter(5000,8,9)
Frank McCroy
@fmccroy
Jun 17 2017 00:22
@neftonjin Why are you pushing 1 instead of item?
Manish Giri
@Manish-Giri
Jun 17 2017 00:23
@fmccroy it's kinda like in the first case you are creating just one array object, and storing the reference to that object in the test variable, then you create another reference to the same object. And since that object has one fixed location in memory, those 2 references are the same locations..
in the second case, you have 2 distinct objects at 2 different locations, so comparing their addresses returns false
Nefton
@neftonjin
Jun 17 2017 00:25
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
this are the instructions
Frank McCroy
@fmccroy
Jun 17 2017 00:25
I understand it when reminded, but will probably forget again when I need to use it.
@neftonjin You need to arr.push(item) since the test code is feeding into the item variable when your function is called.
Nefton
@neftonjin
Jun 17 2017 00:28
Thank you :D
Frank McCroy
@fmccroy
Jun 17 2017 00:28
Hmm.. The challenge is called nextInLine? I may be thinking of standInLine.. lemme go look
Jorge Luis Vazquez
@zentech
Jun 17 2017 00:28
is this something that can be done? I have an html page and I would like to execute the code entered by the user on a textarea. The code is javascript. in my page I would like to get the textarea and send it to the console, but I haven't figure out a way to do it. any help appreciated <script>
function jstest() {
var text = document.getElementById("textArea").value;
console.log(text);
}
</script>
</head>
<body>
<h2>Enter your code here!</h2>
<form >
<textarea rows="4" cols="50" id="textArea">
</textarea><br>
<input type="submit" value="Submit" onclick="jstest()">
</form>
Nick Danvers
@Ravenor222
Jun 17 2017 00:28
Hey guys, im just about to start the mad libs javascript assignment
However I'm having some trouble understanding the question
Ravi Kishore Thella
@ravikishorethella
Jun 17 2017 00:30
@Ravenor222 you need to form a sentence using the given words
Nick Danvers
@Ravenor222
Jun 17 2017 00:30
You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.
You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence
Frank McCroy
@fmccroy
Jun 17 2017 00:31
You will make a new string that has hardcoded stuff like “hello” and add variables to it in between.
Nick Danvers
@Ravenor222
Jun 17 2017 00:31
So I must write a string defined as result
Frank McCroy
@fmccroy
Jun 17 2017 00:32
It will end up as one long string of stuff added together
Ravi Kishore Thella
@ravikishorethella
Jun 17 2017 00:32
@Ravenor222 result = you need to work on this part;
Nick Danvers
@Ravenor222
Jun 17 2017 00:33
@ravikishorethella I have result=""; in the area that denotes I shouldn't edit code,
does that matter?
Ravi Kishore Thella
@ravikishorethella
Jun 17 2017 00:34
@Ravenor222 you can edit, with the given myNoun, myVerb etc, you need to form a meaningful sentence and the result should be stored in the result
Nick Danvers
@Ravenor222
Jun 17 2017 00:40
Thanks for the help so far, I guess this is stumping me more than it should
Frank McCroy
@fmccroy
Jun 17 2017 00:41
newString = “hi” + var1 + “my name is “ + var2 etc.
return newString;
Nick Danvers
@Ravenor222
Jun 17 2017 00:44
var 1 being the provided variables like "myNoun"
Frank McCroy
@fmccroy
Jun 17 2017 00:44
Yep!
Nick Danvers
@Ravenor222
Jun 17 2017 00:44
newString="hi" + myNoun + " my name is " + myVerb ; for example
I'm just having trouble getting anything to run on the console
Frank McCroy
@fmccroy
Jun 17 2017 00:46
I’m not sure what you mean by run on the console? I plug the code into what code camp provides and go from there
nsonhouse
@nsonhouse
Jun 17 2017 00:53
Is any one able to help with sequelize?
James
@jnick001
Jun 17 2017 00:54
function lookUpProfile(firstName, prop){
// Only change code below this line
  for(var i = 0; i < contacts.length; i++){
    if(contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)){
      return firstName + ", " + contacts[i].prop;
    } else if (contacts[i].firstName !== firstName){
      return "No such contact";
    } else {
      return "No such property";
    }
  }
// Only change code above this line
}

Any idea why this will only return undefined for the contacts[i].prop section?

it works if I hardcode an item in my array, like contacts[i].likes but not using the prop var

Manish Giri
@Manish-Giri
Jun 17 2017 00:55
@jnick001 contacts[i][prop] to begin with
James
@jnick001
Jun 17 2017 00:57
I see. that did show the array value. Why would that work when you have to put the . when not using the prop var?
for example, I was using the console to test different results. I would type contacts[0].likes and it would show the contents of the list.
Eunice Park
@eunicode
Jun 17 2017 01:00

I have a question about Generate Random Whole Numbers within a Range https://www.freecodecamp.com/challenges/generate-random-whole-numbers-within-a-range

This is the solution

function randomRange(myMin, myMax) {
  return Math.floor(Math.random() * (myMax - myMin + 1)) + myMin;
}

// Change these values to test your function
var myRandom = randomRange(5, 15);

But I when I try to test this by myself, I keep getting 14 as the highest number that can be generated, not 15.
This is my reasoning process, assuming Math.random() generates 0.9:
Math.floor(Math.random() (15 - 5 + 1)) + 5
Math.floor(Math.random()
11) + 5
Math.floor(0.9 * 11) + 5
Math.floor(9.9) + 5
9 + 5 = 14

What's the error in my reasoning process?

Manish Giri
@Manish-Giri
Jun 17 2017 01:02
@jnick001 likes is a direct property on the object
prop is just a variable which holds the property name
Alex
@alexandrupintilei
Jun 17 2017 01:03
Hi
someone here who can give me a hint,to a problem?
Frank McCroy
@fmccroy
Jun 17 2017 01:05
@alexandrupintilei What is your question?
Alex
@alexandrupintilei
Jun 17 2017 01:06

function rot13(str) { // LBH QVQ VG!
  var x = str.charCode ;
  var y = String.fromCharCode(x);  
  return y;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Write a function which takes a ROT13 encoded string as input and returns a decoded string.
Frank McCroy
@fmccroy
Jun 17 2017 01:08
@alexandrupintilei It looks like you are trying to convert a whole string to character codes, and back into a string. You need to break the string into individual characters first, and then shift them 13 units, and convert back to characters again
fdemaa
@fdemaa
Jun 17 2017 01:09
whats wrong with my code ?
var Bike = function() {

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


  this.setGear=function(change){
  gear= gear+change;
  };

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

var myCar = new Car();

var myBike = new Bike();
Alex
@alexandrupintilei
Jun 17 2017 01:09
@fmccroy thank you
CamperBot
@camperbot
Jun 17 2017 01:09
alexandrupintilei sends brownie points to @fmccroy :sparkles: :thumbsup: :sparkles:
:cookie: 350 | @fmccroy |http://www.freecodecamp.com/fmccroy
Manish Giri
@Manish-Giri
Jun 17 2017 01:11
@fdemaa gear should be set to change
not incremented with
fdemaa
@fdemaa
Jun 17 2017 01:11
thanks manish,
Joseph Packham
@JosephPack
Jun 17 2017 01:16
a should be assigned to b with =
I'm not sure how to do this
Moisés Man
@moigithub
Jun 17 2017 01:17

can anyone solve this proplem !!
Write an implementation for a function 'callAfter' that enables any function to be called after some specified duration with certain parameters, with the following mentioned syntax:
Example: Lets say you have a function called 'sum' like so:
function sum(a, b) { console.log('Sum is: ', a + b); }
Now you should be able to execute:
sum.callAfter(5000, 8, 9);

u wrote that above.. @pahosler

@moigithub your answer looks incorrect, and it doesn't delay for the time entered, the method call is supposed to be callAfter.sum(5000,8,9)notsum.callAfter(5000,8,9)

if u console.log the values passed u will see delay is 5000, and arguments is [5000, 8, 9]
soo setTimeout function gets the correct delay value, and sum gets called with 8 and 9

Function.prototype.callAfter=function(delay){
   console.log("delay is ",delay, "argumetns is ",arguments);  /////////////// <<<<<<<<<<
 setTimeout( ()=>this.apply(null,[...arguments].slice(1)), delay); //fixed
}

ok i see the problem is need a wrapper funciton inside setTimeout

Curtis
@CurtisJCamp
Jun 17 2017 01:28

hey everybody i have no idea what I'm doing wrong to not pass this challenge ```
// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup = {
"alpha" : "Adams"
"bravo" : "Boston",
"charlie" : "Chicago",
"delta" : "Denver",
"echo" : "Easy",
"foxtrot" : "Frank"

};

// Only change code above this line
return lookup[val];
}

// Change this value to test
phoneticLookup("charlie");
```

Challenge "Using Objects for Lookups
Brandon Thomas
@hazeion
Jun 17 2017 01:33
you are missing a comma after "Adams" for one.
Curtis
@CurtisJCamp
Jun 17 2017 01:34
oh my goodness that was it thank you very much @hazeion
CamperBot
@camperbot
Jun 17 2017 01:34
curtisjcamp sends brownie points to @hazeion :sparkles: :thumbsup: :sparkles:
:cookie: 204 | @hazeion |http://www.freecodecamp.com/hazeion
Moisés Man
@moigithub
Jun 17 2017 01:34
@CurtisJCamp to format code.. backticks MUST be on its OWN line
Brandon Thomas
@hazeion
Jun 17 2017 01:35
Funny thing.. I am on the exact exercise
Nathaniel Suchy
@nsuchy
Jun 17 2017 01:41
I gotta admit that I found that Javascript escape sequences to be frustrating
I figured out though :)
fdemaa
@fdemaa
Jun 17 2017 01:44
Can anyone help me to understand Make Object Properties Private ? i pass the exercise, but i dont understand it anyway lol
Brian
@BrianCodes33
Jun 17 2017 01:44
can someone help me out w/ this npm error when i run npm start
Ken Haduch
@khaduch
Jun 17 2017 01:45
@BrianCodes33 - I don't know if I can, if you post your error maybe something will ring a bell with me, it's been a while since I played with that.
@fdemaa - can you post your code and explain what part you don't understand?
Brian
@BrianCodes33
Jun 17 2017 01:46
tsc -p src/

src/app/components/user.component.ts(16,5): error TS1005: ',' expected.

npm ERR! Darwin 16.5.0
npm ERR! argv "/Users/brianborin/.nvm/versions/node/v7.2.1/bin/node" "/Users/brianborin/.nvm/versions/node/v7.2.1/bin/npm" "run" "build"
npm ERR! node v7.2.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! angular-quickstart@1.0.0 build: `tsc -p src/`
npm ERR! Exit status 2
fdemaa
@fdemaa
Jun 17 2017 01:47
@CurtisJCamp you have to use result and lookup and val, i dont know how to explain it without giving the answer
pahosler
@pahosler
Jun 17 2017 01:48
@moigithub momentary dyslexia on my part as well, I swapped things around :O probably why I was/am having more trouble than I should have... this has me trying to learn prototyping though :D
fdemaa
@fdemaa
Jun 17 2017 01:48

hi @khaduch !

i have this , i dont understand what is the use of making the var private and the methods publics ?

var Bike = function() {

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


  this.setGear=function(change){
  gear=change;
  };

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

var myCar = new Car();

var myBike = new Bike();
Ken Haduch
@khaduch
Jun 17 2017 01:53
@fdemaa - thiss is a very basic example of an object and methods (and properties). The idea is that you only "expose" the variables through methods so that you have full control over what values are set in the properties at any time. If anyone using your class in their code had free access to the variables, they could put values in there that could cause your object to not behave as it is supposed to. As I said, this simple example only shows that you cannot directly access the properties without using the methods.
@BrianCodes33 - this looks like a compilation error or syntax error in the user.component.ts file. Is that your own file? Check line 16, column 5 to see if it looks like it should have a comma?
Brian
@BrianCodes33
Jun 17 2017 01:56
thanks @khaduch still learning how to understand npm errors
CamperBot
@camperbot
Jun 17 2017 01:56
briancodes33 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3002 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jun 17 2017 01:57
@BrianCodes33 - I cannot say for certain that I gave your the right information, but that's what it appears to be to me. I haven't used npm very much...
Brian
@BrianCodes33
Jun 17 2017 02:00
yea i just fixed that line was missing some syntax thx
interesting how the server doesn’t run with a syntax error
NBTALOS
@NBTALOS
Jun 17 2017 02:04
can a code be wrong but still pass the bonfire challanges ?
Ken Haduch
@khaduch
Jun 17 2017 02:06
@NBTALOS - yes, it can be written to just pass the tests, but if the tests change then the code could be incorrect.
@NBTALOS - do you have a specific question about something?
fdemaa
@fdemaa
Jun 17 2017 02:09
@khaduch thanks ken.
CamperBot
@camperbot
Jun 17 2017 02:09
fdemaa sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3003 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jun 17 2017 02:09
@BrianCodes33 - yeah, a syntax error pretty much stops things dead in its tracks.
NBTALOS
@NBTALOS
Jun 17 2017 02:13
@khaduch thanks , no i was just unsure about my code because it passed the test but still looked like a bit off to me.
CamperBot
@camperbot
Jun 17 2017 02:13
nbtalos sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3004 | @khaduch |http://www.freecodecamp.com/khaduch
Kevin
@kevinwr
Jun 17 2017 02:19

hey, all.

So I just finished the challenge "find the longest word in a string," and not quite sure about a section of the code. Here is my code:


function findLongestWord(str) {
  var array = str.split(' ');

  var array2 = [];

    for (i = 0; i < array.length; i++) {
        array2[i] = array[i].length;
    }

  array2.sort(function(a,b) {
      return b-a;
  });

    return array2[0];
}

findLongestWord("The quick brown fox jumped over the lazy dog");

This code passed, but I had to use code I found on w3Schools, which is the array2.sort(function(a,b) { return b-a; });

What I'm having trouble with us the a and b that are in function in the sort method. Obviously it's taking each element that is stored in array2 and comparing them and sorting them in descending order, but not sure how each element becomes a or b.

Also, I'm curious if anyone else could think of a better way to complete this instead of what I have above?
Manish Giri
@Manish-Giri
Jun 17 2017 02:26
@kevinwr I had this
function findLongestWord(str) {
 return str.split(" ").map(word => word.length).sort((a,b) => b-a)[0];
}
essentially same logic, just shorter.
Kevin
@kevinwr
Jun 17 2017 02:30
ahhh map...I know they brought that up earlier. I never really understood that. What does map do?
Manish Giri
@Manish-Giri
Jun 17 2017 02:31
it iterates over an array and returns a new one based on the logic you put in map.
Kevin
@kevinwr
Jun 17 2017 02:33
what does "words" do? Is that a variable? and what is the 0 at the end? Trying to understand everything after .split(" "), lol
Manish Giri
@Manish-Giri
Jun 17 2017 02:35

what does "words" do? Is that a variable?

yep, words becomes every word in the array of strings one by one

changed it to word if it helps

what is the 0 at the end

same thing as what you have - return array2[0];

Ken Haduch
@khaduch
Jun 17 2017 02:35
@NBTALOS - if you want to post it, we can have a look and see if you have anything that looks strange. I have seen cases where people have implemented code that strictly is written to pass the tests without applying the concept that is being taught - for example, instead of testing an object for a property and returning a value, there is a direct test of the incoming property name, and then returning the value that is expected in the test. As I said, any change in the test data would make the code break.
Kevin
@kevinwr
Jun 17 2017 02:36
god I feel like an idiot. JS is kicking my ass. Not sure how I can ever do any of the lower languages if I can't even do JS well
Manish Giri
@Manish-Giri
Jun 17 2017 02:38
unless you mean something like Assembly language
Brian
@BrianCodes33
Jun 17 2017 02:38
@kevinwr just break it down piece by piece console log everything
Manish Giri
@Manish-Giri
Jun 17 2017 02:38
it's mostly the same everywhere
glitz20
@glitz20
Jun 17 2017 02:41
can anyone help me to find out why my algorithm is not working?https://www.freecodecamp.com/challenges/sorted-union
Kevin
@kevinwr
Jun 17 2017 02:41
@BrianCodes33 I'll give that a shot. One of my issues is figuring out what the hell is going on in each little bit of code (how the computer is "reading" the code).
@Manish-Giri thank you for the help.
CamperBot
@camperbot
Jun 17 2017 02:41
kevinwr sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6013 | @manish-giri |http://www.freecodecamp.com/manish-giri
Cam
@cam-barts
Jun 17 2017 02:41
@sabin20 that just sent me to the same challenge. can you send me your code?
glitz20
@glitz20
Jun 17 2017 02:42

function uniteUnique(arr) {
var landak=[];
landak.push(arr[0][0]);
for(var i=0;i<arr.length;i++){
for(var j=1;j<arr[i].length;j++){
if(arr[i][j]!==landak){
landak.push(arr[i][j]);
}

}

}

return landak;
}

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

Cam
@cam-barts
Jun 17 2017 02:44
if(arr[i][j]!==landak){
If the element that is next in the iteration is equal to the ARRAY landak
glitz20
@glitz20
Jun 17 2017 02:46
@TheKingOfShade so, how should I write code stating elements in the ARRAY landak?
Cam
@cam-barts
Jun 17 2017 02:47
Yea, you should write a test that checks if the next iteration checks each element of landak, instead of landak itself
ohh bad english, checks the element against each element of landak @sabin20
Does that make sense?
glitz20
@glitz20
Jun 17 2017 02:50

function uniteUnique(arr) {
var landak=[];
landak.push(arr[0][0]);
for(var i=0;i<arr.length;i++){
for(var j=1;j<arr[i].length;j++){
for(var k=0;k<landak.length;k++){
if(arr[i][j]!==landak[k]){
landak.push(arr[i][j]);
}
}

}

}

return landak;
}

what about now?
Kelechi Chinaka
@ke1echi
Jun 17 2017 02:53
function bmi(weight, height) {
  const checker = weight / height * height;
  return (checker <= 18.5) ? "Underweight" : (checker <= 25.0) ? "Normal" : (checker <= 30.0) ?  "Overweight" : "Obese";
}
bmi(80, 1.80)
Expected: 'Normal', instead got: 'Obese'
what am i doing wrong
glitz20
@glitz20
Jun 17 2017 02:55
any solution @TheKingOfShade
Cam
@cam-barts
Jun 17 2017 02:55
Well now the logic says that for each element that you check against each element of the landak array, and if it is not equal to that single element, push it onto the array. @sabin20
glitz20
@glitz20
Jun 17 2017 02:58
yup, doesnot that address the problem @TheKingOfShade
Ken Haduch
@khaduch
Jun 17 2017 03:00
@kevinwr - another really neat and useful learning tool is http://pythontutor.com/javascript.html. You can plug your code in there and it will run it step by step, giving you visual indications of changing variables and data, how accesses are being made, etc. Once you get used to how it works, it is really great!
Andrea Mammoliti
@AndreusSH
Jun 17 2017 03:03
Hi everyone, I am trying to figure out this task
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr

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

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

would everyone give me some kind of hint to understand the rationale behind?
Cam
@cam-barts
Jun 17 2017 03:09
@sabin20 I would try to incorporate a boolean in there. Something like "if the value already exists for this iteration, return true" and then later "if value is false, push iteration onto array"
glitz20
@glitz20
Jun 17 2017 03:11
@TheKingOfShade thanks
CamperBot
@camperbot
Jun 17 2017 03:11
sabin20 sends brownie points to @thekingofshade :sparkles: :thumbsup: :sparkles:
:cookie: 243 | @thekingofshade |http://www.freecodecamp.com/thekingofshade
Manish Giri
@Manish-Giri
Jun 17 2017 03:11
@AndreusSH you need to keep multiplying product with every number from the innermost for loop..
that way product will have the product of all elements in the sub arrays.
@AndreusSH for (var i=0;i<9;i++) { - also, why i < 9?
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:12
@Manish-Giri ggggggggggm :smiling_imp: > 6000 :fire:
Manish Giri
@Manish-Giri
Jun 17 2017 03:12
:smiling_imp:
ty ggggggm @Lumexralph
CamperBot
@camperbot
Jun 17 2017 03:12
manish-giri sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1944 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:13
@Manish-Giri good morning, take a look at this, what's the result 8 / 2 * 2 ?
Manish Giri
@Manish-Giri
Jun 17 2017 03:13
@Lumexralph 8?
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:14
@Manish-Giri why? disobeyed order of precedence
or am I missing something ?
Manish Giri
@Manish-Giri
Jun 17 2017 03:14
division and multiplication have same precedence
Kelechi Chinaka
@ke1echi
Jun 17 2017 03:14
2 @Lumexralph
Manish Giri
@Manish-Giri
Jun 17 2017 03:14
and on same prec levels, it goes left to right
@Lumexralph
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:14
@Manish-Giri really ? :worried:
Andrea Mammoliti
@AndreusSH
Jun 17 2017 03:14
that actually was a typo @Manish-Giri thanks for your help
CamperBot
@camperbot
Jun 17 2017 03:14
andreussh sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6014 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 17 2017 03:14
yup
Kelechi Chinaka
@ke1echi
Jun 17 2017 03:14
multiplication b4 division
Coy Sanders
@coymeetsworld
Jun 17 2017 03:14
yeah thats 8
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:14
@kelechichinaka that's your answer
Manish Giri
@Manish-Giri
Jun 17 2017 03:15
multiplication b4 division
Coy Sanders
@coymeetsworld
Jun 17 2017 03:15
multiplication and division happen at same time
Manish Giri
@Manish-Giri
Jun 17 2017 03:15
how come?
Kelechi Chinaka
@ke1echi
Jun 17 2017 03:15
yea
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:15
@coymeetsworld on MDN * before \
Coy Sanders
@coymeetsworld
Jun 17 2017 03:15
@Lumexralph link?
Kelechi Chinaka
@ke1echi
Jun 17 2017 03:15
operator precedence
Manish Giri
@Manish-Giri
Jun 17 2017 03:15
it's all 14
Coy Sanders
@coymeetsworld
Jun 17 2017 03:15
No its just like real math
$ node
> let x = 8 *2 / 2;
undefined
> x
8
Manish Giri
@Manish-Giri
Jun 17 2017 03:15
so same precedence
*, / and % have 14
so L-R
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:16
@coymeetsworld @Manish-Giri ah!
Coy Sanders
@coymeetsworld
Jun 17 2017 03:16
yeah its in the same group
maybe thats a little misleading having them in columns
Manish Giri
@Manish-Giri
Jun 17 2017 03:16
yup
Coy Sanders
@coymeetsworld
Jun 17 2017 03:16
probably better to have rows
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:16
@Manish-Giri @coymeetsworld totally missed that, i was misled
@Manish-Giri @coymeetsworld thanks
CamperBot
@camperbot
Jun 17 2017 03:17
lumexralph sends brownie points to @manish-giri and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2806 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
:star2: 6015 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 17 2017 03:17
wonder how it's written in w3schools
:thought_balloon:
Coy Sanders
@coymeetsworld
Jun 17 2017 03:17
np
its right on w3schools
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:18
but mehn..... how did I miss that
Coy Sanders
@coymeetsworld
Jun 17 2017 03:18

"As in traditional school mathematics, the multiplication is done first.

Multiplication (*) and division (/) have higher precedence than addition (+) and subtraction (-)."

@Lumexralph I remember on social media there would be questions like that
Kelechi Chinaka
@ke1echi
Jun 17 2017 03:18
oh it they are both 14 so its left to right associativity @Lumexralph
Coy Sanders
@coymeetsworld
Jun 17 2017 03:19
and you check the comments and people would go to war on who was right lol
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:19
@coymeetsworld yeah... i'm aware..............all this while I have given * more precedence over /, thanks to how mdn placed it
CamperBot
@camperbot
Jun 17 2017 03:19
lumexralph sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: lumexralph already gave coymeetsworld points
Kelechi Chinaka
@ke1echi
Jun 17 2017 03:19
:smile: @Manish-Giri @coymeetsworld
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:20

and you check the comments and people would go to war on who was right lol

:laughing: :joy:

Coy Sanders
@coymeetsworld
Jun 17 2017 03:20
it was sad
william
@theironcock
Jun 17 2017 03:20
how do i do the thing where the language panels on the chat
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:21
@coymeetsworld people often favour argument over discussion just to satisfy their ego, right or wrong
Manish Giri
@Manish-Giri
Jun 17 2017 03:22
@coymeetsworld how's CTCI going?
I stopped for a bit, reviewing DS before resuming
Coy Sanders
@coymeetsworld
Jun 17 2017 03:22
yeah they do, but also since its not in person they have no shame so they don't back down
@Manish-Giri also stopped for a bit haha, I need to get back on it but I was working on a side project I wanted to finish
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:23
@Manish-Giri what's that?
Coy Sanders
@coymeetsworld
Jun 17 2017 03:23
Cracking the Coding Interview
Manish Giri
@Manish-Giri
Jun 17 2017 03:23
what with D3, Redux, Node/Exp/Mongo and my thesis going on at the same time, I wonder when I'll finish CTCI
Coy Sanders
@coymeetsworld
Jun 17 2017 03:23
its a book that has a lot of common "whiteboard" problems you would get
Manish Giri
@Manish-Giri
Jun 17 2017 03:23
:disappointed:
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:23
@coymeetsworld on FCC?
Coy Sanders
@coymeetsworld
Jun 17 2017 03:23
prioritize thesis I would say
@Lumexralph no its a book
has a few chapters going over interview process, but majority of the book is refresher on algorithms and datastructures with example problems/solutions
like right now I'm on the chapter reviewing Linked Lists and problems that would require solving w/ a linked list
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:25
@coymeetsworld cool, should look it up
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:26
@coymeetsworld is it about job interviews ?
Coy Sanders
@coymeetsworld
Jun 17 2017 03:26
yes its not bad, just for the questions/answers alone its good
Manish Giri
@Manish-Giri
Jun 17 2017 03:26
I had an interview once where they asked how would you write a queue using 2 LLs
had no idea at the time
but you'd just insert to the front of one LL
and remove from the end of the other
Coy Sanders
@coymeetsworld
Jun 17 2017 03:27
@forwebtech yes its to help you on the technical interviews
Kelechi Chinaka
@ke1echi
Jun 17 2017 03:27
link pls @coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 03:27
the questions and content are examples of what top companies have asked in the past
Manish Giri
@Manish-Giri
Jun 17 2017 03:27
scroll up
Coy Sanders
@coymeetsworld
Jun 17 2017 03:28
:point_up:
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:28
@coymeetsworld right !
Augusto
@hackedWifi
Jun 17 2017 03:28
I am really stuck with the exact change algorithm. I dont know how to start
Andrea Mammoliti
@AndreusSH
Jun 17 2017 03:30
I think I got this

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

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

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

Aizaz Shahid
@aizazshahid
Jun 17 2017 03:30
Coy Sanders
@coymeetsworld
Jun 17 2017 03:30
@AndreusSH close
I have that bookmarked @forwebtech but I haven't checked it out
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:31
@AndreusSH don't put space between them arr [i][j]
Andrea Mammoliti
@AndreusSH
Jun 17 2017 03:31
@coymeetsworld it seems like the property length is not defined
Coy Sanders
@coymeetsworld
Jun 17 2017 03:31
nope, its the brackets next to the array as mentioned by @forwebtech
Manish Giri
@Manish-Giri
Jun 17 2017 03:31
it's not very helpful imo
Coy Sanders
@coymeetsworld
Jun 17 2017 03:31
oh and another thing(s)
something wrong w/ both for loops
Manish Giri
@Manish-Giri
Jun 17 2017 03:31
it has some useful topics but not great solutions
jdnelson55
@jdnelson55
Jun 17 2017 03:32

function multiplyAll(arr) {
var product = 1;
// Only change code below this line

for (var i = 0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
product *= arr[i][j];
}
}

return product ;
}

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


My question on that is where are the nested arrays defined to js?

.
Andrea Mammoliti
@AndreusSH
Jun 17 2017 03:32
@coymeetsworld @forwebtech thanks for the brackets
CamperBot
@camperbot
Jun 17 2017 03:32
andreussh sends brownie points to @coymeetsworld and @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 708 | @forwebtech |http://www.freecodecamp.com/forwebtech
:star2: 2807 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Andrea Mammoliti
@AndreusSH
Jun 17 2017 03:32
@coymeetsworld checking the loops!
Coy Sanders
@coymeetsworld
Jun 17 2017 03:32
@jdnelson55 what do you mean?
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:32
@AndreusSH :+1:
jdnelson55
@jdnelson55
Jun 17 2017 03:34
it seems like the nested arrays would need to be defined
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:35
@coymeetsworld instead preparing for interviews, i think we should focus on the excellence of our skill ?
Coy Sanders
@coymeetsworld
Jun 17 2017 03:35
@jdnelson55 no the nested arrays are part of the arr parameter
Kelechi Chinaka
@ke1echi
Jun 17 2017 03:35
true talk @forwebtech
Coy Sanders
@coymeetsworld
Jun 17 2017 03:35
you expect arr to be a 2D array
Bryan Reese
@breese8009
Jun 17 2017 03:35
cant seem to get the closure to work.... anyone??
function addTogether(a,b) {


let validNum= function(arg){
  if(typeof arg !=='number'){
   return false;
  }
  return true;
};

// if no 2nd arg
if(validNum(arguments[0])===false || validNum(arguments[1])===false){
  return undefined;
} 
if(arguments.length===1){
  a=arguments[0];
  return function(arg){
    return arg+a;
  };
} 
else 
return a+b;

}

addTogether(2,3);
Coy Sanders
@coymeetsworld
Jun 17 2017 03:35
@forwebtech both are important
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:36
@coymeetsworld in how many companies did you work ?
Coy Sanders
@coymeetsworld
Jun 17 2017 03:36
unfortunately unless you are a famous programmer you probably need to go through some sort of whiteboard interview or know things.
excluding all the spin-offs and mergers and crap, 3
Manish Giri
@Manish-Giri
Jun 17 2017 03:36
@coymeetsworld Amazon is buying Whole Foods
Bryan Bartley
@pun-isher
Jun 17 2017 03:36
Hey-- can anyone help me with the Palindrome algorithm challenge? I am not sure why palindrome("0_0 (: /-\ :) 0-0") should return true
Coy Sanders
@coymeetsworld
Jun 17 2017 03:37
yep, 13B
Manish Giri
@Manish-Giri
Jun 17 2017 03:37
wonder what kind of merger that would be
$13B
Coy Sanders
@coymeetsworld
Jun 17 2017 03:37
seems like even if Amazon demolished all the stores and setup warehouses they would still make out lol
Manish Giri
@Manish-Giri
Jun 17 2017 03:37
lol
Coy Sanders
@coymeetsworld
Jun 17 2017 03:37
or that was someones thought on the matter at least
jdnelson55
@jdnelson55
Jun 17 2017 03:37
thats a bag of apples at whole foods...13b
Coy Sanders
@coymeetsworld
Jun 17 2017 03:37
@jdnelson55 they don't sell apples at whole foods
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:37
@coymeetsworld what is whiteboard interview ? requires to code in handwriting ?
Coy Sanders
@coymeetsworld
Jun 17 2017 03:37
they sell organic granny smiths
:)
Manish Giri
@Manish-Giri
Jun 17 2017 03:38
anyway, definitely better than Verizon - Yahoo
Adam Ayd
@adamayd
Jun 17 2017 03:38
Hey all, I'm working on the Random Quote Machine and had a question that I'm not quite sure about.
jdnelson55
@jdnelson55
Jun 17 2017 03:38
I only buy fuji
Coy Sanders
@coymeetsworld
Jun 17 2017 03:38
@forwebtech essentially solving a problem with pen and paper
jdnelson55
@jdnelson55
Jun 17 2017 03:38
even better after fukishima
Coy Sanders
@coymeetsworld
Jun 17 2017 03:38
or whiteboard /marker, chalkboard/chalk, the medium doesn't really matter except that its not typically on a computer
so you cant google answers or look up syntax, etc
Bryan Bartley
@pun-isher
Jun 17 2017 03:39
@decaren maybe we can help eachother out
Manish Giri
@Manish-Giri
Jun 17 2017 03:39
some of my friends actually bought huge whiteboards to practice with
:disappointed:
@coymeetsworld
Bryan Bartley
@pun-isher
Jun 17 2017 03:39
@decaren i assume you have already done the Palindrome algorithm challenge?
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:39
@coymeetsworld but what about that person who can do mostly all challenges on his/her own ? is he/she requires to read those books about interviews ?
Coy Sanders
@coymeetsworld
Jun 17 2017 03:39
@Manish-Giri I just do it at work :D
when no one is around
what challenges?
Adam Ayd
@adamayd
Jun 17 2017 03:40
ok @pun-isher I can't figure out if I'm supposed to use a Quote API from somewhere or if I am supposed to create a JSON object in the code itself.
Manish Giri
@Manish-Giri
Jun 17 2017 03:40
lol
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:40
@coymeetsworld any problem regarding problem solving.
Adam Ayd
@adamayd
Jun 17 2017 03:40
yes I have done the palindrome algorithm
Coy Sanders
@coymeetsworld
Jun 17 2017 03:40
well if you can solve any problem then I don't think you need any book really :)
Manish Giri
@Manish-Giri
Jun 17 2017 03:41
@coymeetsworld so something I was curious about
Bryan Bartley
@pun-isher
Jun 17 2017 03:42
@decaren Okay-- based on the challenge- i think the best option is to find an API
Coy Sanders
@coymeetsworld
Jun 17 2017 03:42
@decaren you can create your own JSON object for the quote project
Bryan Bartley
@pun-isher
Jun 17 2017 03:42
@decaren the challenge is more in regards to page functionality, than building a quote machine iteself
Manish Giri
@Manish-Giri
Jun 17 2017 03:42

in a queue, does it matter which end is which?
Like I've always used the left end to insert & right end to delete.

But looks like only the opposite way is true?

@coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 03:42
or an array
you don't need to use an API just because its lumped with other projects that do require an API
Manish Giri
@Manish-Giri
Jun 17 2017 03:43
I remember talking with Claudio over this
Coy Sanders
@coymeetsworld
Jun 17 2017 03:43
up to you if you want to do it that way
Manish Giri
@Manish-Giri
Jun 17 2017 03:43
he mentioned it's always insert at right, delete at left
Coy Sanders
@coymeetsworld
Jun 17 2017 03:43
queue is first-in-first-out
Manish Giri
@Manish-Giri
Jun 17 2017 03:43
as long as you follow FIFO
shouldn't matter
Coy Sanders
@coymeetsworld
Jun 17 2017 03:43
as long as your enqueue and dequeue methods are adding/removing in correct place it shouldn't matter
no I don't see why
Manish Giri
@Manish-Giri
Jun 17 2017 03:44
hm
cool
ty @coymeetsworld
CamperBot
@camperbot
Jun 17 2017 03:44
manish-giri sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2808 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 03:44
if i queue up 1,2,3,4,5, if i dequeue 5 times it should come out 1,2,3,4,5
don't see any performance/memory improvement adding on one side over the other
Adam Ayd
@adamayd
Jun 17 2017 03:44
thanks @coymeetsworld and @pun-isher
CamperBot
@camperbot
Jun 17 2017 03:44
decaren sends brownie points to @coymeetsworld and @pun-isher :sparkles: :thumbsup: :sparkles:
:cookie: 259 | @pun-isher |http://www.freecodecamp.com/pun-isher
:star2: 2809 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 03:45
only thing I would say is do what everyone else would, just so that its more readable
this is assuming you're using linked lists too and all that right @Manish-Giri? not an array?
Manish Giri
@Manish-Giri
Jun 17 2017 03:46
yeah LL
@coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 03:47
ok yeah, as long as you have pointers to the head and tail or whatever then however you want to add it
Manish Giri
@Manish-Giri
Jun 17 2017 03:47
yeah
that DS course had a video on how to implement dynamic arrays manually
Coy Sanders
@coymeetsworld
Jun 17 2017 03:47
bad?
Manish Giri
@Manish-Giri
Jun 17 2017 03:47
spent more than an hour trying to figure out wtf he was doing
...
Coy Sanders
@coymeetsworld
Jun 17 2017 03:48
what language?
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:49
@coymeetsworld how do you rate FCC challenges difficulty ?
Manish Giri
@Manish-Giri
Jun 17 2017 03:49
Java
Coy Sanders
@coymeetsworld
Jun 17 2017 03:49
@forwebtech they can be challenging
esp the adv section
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:51
right !
i found that FCC challenges are also good for experienced programmers.
Coy Sanders
@coymeetsworld
Jun 17 2017 03:53
yeah they werent trivial, some I wrote could be done better too
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:53
@coymeetsworld well may be i am wrong, but more thing is that, does that person solves on his own or not ?
Coy Sanders
@coymeetsworld
Jun 17 2017 03:54
you should yeah, or do like pair programming if both of you are at the same level and haven't done the problem before
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:54
solve a problem on your own code, have gives you great happiness :)
Adam Ayd
@adamayd
Jun 17 2017 03:54
I've noticed that looking at the solutions afterwards, I usually solve them the "basic" way, but some of the intermediate and advanced solutions helped me in later challenges.
Coy Sanders
@coymeetsworld
Jun 17 2017 03:54
can ask for help ofc
yeah its good to look at some solutions later, but usually better when you have more exp
because the more elegant answers youre not going to know right away
Adam Ayd
@adamayd
Jun 17 2017 03:56
that's for sure. I feel great when I finish one then look at how much extra code it took me compared to the others.
Coy Sanders
@coymeetsworld
Jun 17 2017 03:56
but you improve on it later
for find longest word in a string my function at first had 6 lines of code, excluding new lines and lines with just a closing bracket
I got it down to 3 and then eventually now I have it at 1
Adam Ayd
@adamayd
Jun 17 2017 03:57
Yes and if nothing else, I've gotten better a reading documentation.
Manish Giri
@Manish-Giri
Jun 17 2017 03:57
I just redid that today itself
1 line
map, sort
Coy Sanders
@coymeetsworld
Jun 17 2017 03:57
hmm i just have split and sort
Adam Ayd
@adamayd
Jun 17 2017 03:57
Holy crap.
Manish Giri
@Manish-Giri
Jun 17 2017 03:58
@kevinwr I had this
function findLongestWord(str) {
 return str.split(" ").map(word => word.length).sort((a,b) => b-a)[0];
}
Coy Sanders
@coymeetsworld
Jun 17 2017 03:58
return str.split(' ').sort((a,b) => b.length - a.length)[0].length;
Manish Giri
@Manish-Giri
Jun 17 2017 03:58
oh well
Ogundele Olumide
@Lumexralph
Jun 17 2017 03:59
@Manish-Giri check your message :smiling_imp:
Manish Giri
@Manish-Giri
Jun 17 2017 03:59
ooh
hold up
Adam Ayd
@adamayd
Jun 17 2017 03:59
I have six right now. I don't even know what => does
Coy Sanders
@coymeetsworld
Jun 17 2017 03:59
its a fat arrow, its es6 syntax
its not covered in FCC (yet, its in beta)
Aizaz Shahid
@aizazshahid
Jun 17 2017 03:59
@coymeetsworld i did that as:
return Math.max(... str.split(" ").map( val => val.length ) );
Coy Sanders
@coymeetsworld
Jun 17 2017 03:59
yeah I like that a little better @forwebtech
sort method is not as intuitive as math.max imo
Kevin
@kevinwr
Jun 17 2017 04:09

Hey, all.

I don't want the answer to my following question, but rather, I just want some help thinking about how to solve it, and possibly some tips.

Right now, I'm trying to solve a challenge, and the challenge is to take a string, pass it into a function, and return the string with each letter of each word capitalized

Bryan Reese
@breese8009
Jun 17 2017 04:11
anyone good w closures
Adam Ayd
@adamayd
Jun 17 2017 04:11
What's the question @kevinwr
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:11
a quick quiz, What is String(something) ? (a) Primitive string (b) String object
Bryan Reese
@breese8009
Jun 17 2017 04:11
still trying to get help but everyones avoiding helping cause its hard i guess?
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:12
@breese8009 what's the question?
Kevin
@kevinwr
Jun 17 2017 04:12
@decaren how do I go about solving the challenge?
Bryan Reese
@breese8009
Jun 17 2017 04:12
@Lumexralph my closure isnt working on this arguments optional challenge
function addTogether(a,b) {
// check for valid nums function
var args=[];
args.push(arguments[0],arguments[1]);

let validNum=(arg)=>{
return typeof arg === 'number' ? true : false;
};

let check= args.filter((x)=> validNum(x) );

if(check.length!==2){
  return undefined;
} 
else if(args.length===1){
return function(f){
  if(validNum(f)===true){
    return f+args[0];
  } 
    return undefined;
  };
 }  return a+b;
}
addTogether(2,3);
Adam Ayd
@adamayd
Jun 17 2017 04:13
@kevinwr using the .toUpperCase method.
Kevin
@kevinwr
Jun 17 2017 04:15
@decaren I applied that to my string, but it capitalizes each and every word in the string. I only need the first word. They also provide a tip to use split(). Not sure if that's the right way to go about it.
Karthigesudilani
@Karthigesudilani
Jun 17 2017 04:15
hai

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

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

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

what is the wrong my code
Kevin
@kevinwr
Jun 17 2017 04:16
@decaren is it possible to apply regular expressions in the toUpperCase method?
@Karthigesudilani use ```
Kevin
@kevinwr
Jun 17 2017 04:17
*code gets copied here*
image.png
Karthigesudilani
@Karthigesudilani
Jun 17 2017 04:18
plzz help me
Manish Giri
@Manish-Giri
Jun 17 2017 04:18
@kevinwr I thought they meant to capitalize every word, first letter?
Bryan Reese
@breese8009
Jun 17 2017 04:19
@Lumexralph its hard hu?
Kevin
@kevinwr
Jun 17 2017 04:20
@Manish-Giri yeah, every first letter. I've been racking my brain trying to solve it. I did try splitting it to an array, and using bracket notation to get the first latter of each element, but that was throwing errors all over.
Manish Giri
@Manish-Giri
Jun 17 2017 04:20
@kevinwr let's have your code..
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:21
@breese8009 sorry was away, would inspect now
Kevin
@kevinwr
Jun 17 2017 04:21
and I wasn't sure if I could apply toUpperCase method within the array and while using bracket notation
I don't have any code right now. I deleted it all @Manish-Giri
Bryan Reese
@breese8009
Jun 17 2017 04:21
@Lumexralph all good ,an
man*
i suck w closues
need to work on it
Kevin
@kevinwr
Jun 17 2017 04:22
@Manish-Giri oh wait...I was doing something like this:

function titleCase(str) {
  return str.split(" ").map(word => word[0].toUppercase());
}

titleCase("I'm a little tea pot");
Coy Sanders
@coymeetsworld
Jun 17 2017 04:22
yeah I wasn't sure what the issue was @breese8009, what is the challenge name?
Kevin
@kevinwr
Jun 17 2017 04:22
it wasn't finished...I was just messing around trying to get crap to work. lol
Manish Giri
@Manish-Giri
Jun 17 2017 04:22
@kevinwr try not to use map at this stage
Coy Sanders
@coymeetsworld
Jun 17 2017 04:22
nvm
Bryan Reese
@breese8009
Jun 17 2017 04:22
@coymeetsworld arguments optional
Karthigesudilani
@Karthigesudilani
Jun 17 2017 04:22
how do this
Manish Giri
@Manish-Giri
Jun 17 2017 04:22
use a regular for loop
will be easier to debug
Kevin
@kevinwr
Jun 17 2017 04:23
JS is going to be the death of me @Manish-Giri
Karthigesudilani
@Karthigesudilani
Jun 17 2017 04:23
how do this
Manish Giri
@Manish-Giri
Jun 17 2017 04:23
@kevinwr also that code will give you back only an array of the first letters
not the rest of each word
Bryan Reese
@breese8009
Jun 17 2017 04:23
no JS is life :heart:
Coy Sanders
@coymeetsworld
Jun 17 2017 04:23
think the first thing to note is you're not always going to get 2 arguments @breese8009
Bryan Reese
@breese8009
Jun 17 2017 04:23
@coymeetsworld i handled that tho..
Coy Sanders
@coymeetsworld
Jun 17 2017 04:24
args.push(arguments[0],arguments[1]); ?
Kevin
@kevinwr
Jun 17 2017 04:24
@breese8009 It's fun....but I feel like an absolute idiot. For some reason, I feel like I'm just not understanding it like I should be.
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:24
@breese8009 think @coymeetsworld has a point
Bryan Reese
@breese8009
Jun 17 2017 04:24
@coymeetsworld but never more then 2
Manish Giri
@Manish-Giri
Jun 17 2017 04:24
@kevinwr it's okay
it takes practice
Coy Sanders
@coymeetsworld
Jun 17 2017 04:24
could be 1, then what's arguments[1]?
Manish Giri
@Manish-Giri
Jun 17 2017 04:24
I'm banging my head with d3 too
Coy Sanders
@coymeetsworld
Jun 17 2017 04:25
@Manish-Giri I got my chart to render, but its still not right yet
Manish Giri
@Manish-Giri
Jun 17 2017 04:25
:worried:
Coy Sanders
@coymeetsworld
Jun 17 2017 04:25
trying to do a stacked bar chart
Manish Giri
@Manish-Giri
Jun 17 2017 04:25
feels the pain
Bryan Reese
@breese8009
Jun 17 2017 04:25
else if(args.length===1){
return function(f){
  if(validNum(f)===true){
    return f+args[0];
  } 
    return undefined;
  };
??
no?
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:25
@breese8009 why don't you just check the length of the arguments array-like object
Kevin
@kevinwr
Jun 17 2017 04:25
@Manish-Giri I'm hoping things start to click for both of us soon.
Coy Sanders
@coymeetsworld
Jun 17 2017 04:25
both args have to numbers right?
Manish Giri
@Manish-Giri
Jun 17 2017 04:25
@kevinwr amen to that
Bryan Reese
@breese8009
Jun 17 2017 04:26
@Lumexralph arguments.length?
Coy Sanders
@coymeetsworld
Jun 17 2017 04:26
that looks better, but think you need to check args[0] too
Bryan Reese
@breese8009
Jun 17 2017 04:27
but if there only 1 arg in there args[0] will still be something
right?
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:27
@breese8009 yes
Coy Sanders
@coymeetsworld
Jun 17 2017 04:27
yeah
well I mean you're checking if f is a number
but not args[0]
Bryan Reese
@breese8009
Jun 17 2017 04:27
and then if thats the case im thinking i need to return closure function
Coy Sanders
@coymeetsworld
Jun 17 2017 04:27
both need to be numbers
unless you're doing that somewhere else
Bryan Reese
@breese8009
Jun 17 2017 04:28
yea in validNum and check
i see what u guys are sayin now i think...hang on...brb...
Coy Sanders
@coymeetsworld
Jun 17 2017 04:31
yeah reading up on it too @breese8009
Vicky Lai
@vickylai
Jun 17 2017 04:34
function pairwise(arr, arg) {
  console.log(arr);
  var remainders = arr.map((arg, curr) => arg-arr[curr]);
  console.log(remainders);
  return arg;
}

console.log(pairwise([1,4,2,3,0,5], 7));
This gives me a remainders array of zeroes. Why?
Coy Sanders
@coymeetsworld
Jun 17 2017 04:34
and looking at my answer, one thing you should also look at is currying @breese8009
map should only have one param I believe @vickylaiio
arg would be each item in the array, i don't think curr is anything
Vicky Lai
@vickylai
Jun 17 2017 04:36
@coymeetsworld
var remainders = arr.map((curr) => arg-curr);
Yep. You're right, I got mixed up. Thanks!
CamperBot
@camperbot
Jun 17 2017 04:36
vickylaiio sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2810 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 04:37
np
I need to revisit that challenge my soln is not great
Vicky Lai
@vickylai
Jun 17 2017 04:43
Sigh. I hate it when I solve the mini-problem I was working on and then forget where I was going with the solution overall :/ Especially when my notes don't help.
Kamal
@kpbro
Jun 17 2017 04:44
function destroyer(arr) {
  // Remove all the values
var args = []; //array of other arguments
  for(var i=1;i<arguments.length;i++){ args.push(arguments[i]); }
//--------------------------------------------------------------------  
  for(var k=0;k<args.length;k++){
    arr = arr.filter(function(x){ //iterate through main arr and filter out the elements-
      return x != args[k];      // given in arguments which are stored in -
    });                         // args array one by one.

  }
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
this code is working perfectly. but is there any other way of doing this thing?
Coy Sanders
@coymeetsworld
Jun 17 2017 04:44
you don't need that first for loop @kpbro
could just remove the array from the arguments array, and iterate through it that way
Kamal
@kpbro
Jun 17 2017 04:45
@coymeetsworld i created it to get other arguments in a seperate array
Coy Sanders
@coymeetsworld
Jun 17 2017 04:45
yeah thats fine but you could just shift off the array
Bryan Reese
@breese8009
Jun 17 2017 04:45
@coymeetsworld mannn fuck that challenge lol
Coy Sanders
@coymeetsworld
Jun 17 2017 04:45
then the arguments array would just be the numbers you need to remove
@breese8009 lol it is a more adv topic
i don't fully understand it either tbh
Kamal
@kpbro
Jun 17 2017 04:46
@coymeetsworld yup..
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:46
@coymeetsworld so many of my solutions in the early stages are awful :smile:
Kamal
@kpbro
Jun 17 2017 04:46
i created separate array so that i can easily iterate through it @coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 04:47
@breese8009 but basically what it seems like to me is if the addTogether function has one param, you're returning a function (currying?). if it has 2 you're adding together
Bryan Reese
@breese8009
Jun 17 2017 04:47
yo yo, if anyone can fix this code to work...i give u a cookie
function addTogether(a,b) {
// check for valid nums function
var args=[];
args.push(arguments[0],arguments[1]);

let validNum=(arg)=>{
return typeof arg === 'number' ? true : false;
};

let check= args.filter((x)=> validNum(x) );

if(args.length===2){
  if(validNum(args[0])===true && validNum(args[1])===true){
    return a+b;
  }
  return undefined;
} 

else if(args.length===1){

  return function(arg){
    if(validNum(args[0])===true){ 
    return arg+args[0];
    }
    else{
  return undefined;
    }
  };
 }
}
addTogether(2,3);
Coy Sanders
@coymeetsworld
Jun 17 2017 04:47
in both situations you check if your parameters are numbers and if they're not then you return undefined
@Lumexralph mine as well
Bryan Reese
@breese8009
Jun 17 2017 04:47
@coymeetsworld thats what i am doing w my code i feel but its not :(
Coy Sanders
@coymeetsworld
Jun 17 2017 04:48
using es6 helped
you still got this args.push(arguments[0],arguments[1]);
you're not always going to have 2 arguments
i.e. addTogether(2)(3)
Bryan Reese
@breese8009
Jun 17 2017 04:48
@coymeetsworld but i take care of it
dont i?
if its 1 arg then i have a return
if its both args
i have a return
Coy Sanders
@coymeetsworld
Jun 17 2017 04:48
eh i guess w/ the filter
Bryan Reese
@breese8009
Jun 17 2017 04:49
not the filter, i can get rid that now
w the code i have
decided to just use the function i made to check if there numbers
no need for that filter
Coy Sanders
@coymeetsworld
Jun 17 2017 04:50
@breese8009 so the problem I think is when youre pushing 2 values to args, args is always going to be length 2
regardless if one of the arguments is undefined
Bryan Reese
@breese8009
Jun 17 2017 04:50
lol im done w it for now...but if someone wants to solve what i have with out completely re constructing it...feel free to post answer
@coymeetsworld ahhh ha!
now its a problem
i see
Coy Sanders
@coymeetsworld
Jun 17 2017 04:51
$ node
> let x = 5;
undefined
> let y;
undefined
> let arr = [];
undefined
> arr.push(x,y);
2
> arr
[ 5, undefined ]
> arr.length;
2
>
Bryan Reese
@breese8009
Jun 17 2017 04:51
ok so now how can i catch both args
?
ur right
ur right
lol
Coy Sanders
@coymeetsworld
Jun 17 2017 04:51
so don't push anything, just check how many args are there
Bryan Reese
@breese8009
Jun 17 2017 04:51
use this.... var args = Array.from(arguments);
Coy Sanders
@coymeetsworld
Jun 17 2017 04:51
if theres 1 you're going to be returning a function, if 2 you're going to add the values together
Bryan Reese
@breese8009
Jun 17 2017 04:51
??
Coy Sanders
@coymeetsworld
Jun 17 2017 04:51
I have Array.prototype.slice.call(arguments);
Aizaz Shahid
@aizazshahid
Jun 17 2017 04:51
var test = "my sentence";
console.log([...test]);
// Array [ "m", "y", " ", "s", "e", "n", "t", ... ]
wondering how to get like test.split(" ") array using spread ?
Coy Sanders
@coymeetsworld
Jun 17 2017 04:51
not sure if Array.from will work
but try
Bryan Reese
@breese8009
Jun 17 2017 04:52
@coymeetsworld dude i think u earned the cookie brb
@coymeetsworld HAHAHAHA TY
CamperBot
@camperbot
Jun 17 2017 04:52
breese8009 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2811 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 04:52
helped?
Bryan Reese
@breese8009
Jun 17 2017 04:52
this whole time u been sayin that..im an idiot
yea now i just need to take care of one thing which is ezpz
Coy Sanders
@coymeetsworld
Jun 17 2017 04:53
not whole time :), I didn't know right away had to look at what I was doing
rlgerman25
@rlgerman25
Jun 17 2017 04:53
Hi, guys. Can anyone help me with the Wikipedia viewer challenge?
Bryan Reese
@breese8009
Jun 17 2017 04:53
@Lumexralph ty too sir!
CamperBot
@camperbot
Jun 17 2017 04:53
breese8009 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1945 | @lumexralph |http://www.freecodecamp.com/lumexralph
Bryan Reese
@breese8009
Jun 17 2017 04:53
@coymeetsworld That was fun
Coy Sanders
@coymeetsworld
Jun 17 2017 04:53
what part @rlgerman25 ? figuring out api wasn't fun
@breese8009 its always fun!
Bryan Reese
@breese8009
Jun 17 2017 04:54
with out htat issue id of solved it in less then 5 minutes
rlgerman25
@rlgerman25
Jun 17 2017 04:54
I dont know how to link the google engine to the page.
Coy Sanders
@coymeetsworld
Jun 17 2017 04:54
if you're wondering wtf why is this important @breese8009, this looks promising http://engineering.cerner.com/blog/closures-and-currying-in-javascript/
rlgerman25
@rlgerman25
Jun 17 2017 04:54
so far I have only the html and CSS parts done @coymeetsworld
Coy Sanders
@coymeetsworld
Jun 17 2017 04:54
at least for practical use
google engine @rlgerman25 ?
rlgerman25
@rlgerman25
Jun 17 2017 04:55
sorry, Wikipedia
Coy Sanders
@coymeetsworld
Jun 17 2017 04:56
I would look at the documentation
Kevin
@kevinwr
Jun 17 2017 04:56

@Manish-Giri AHHHHH

This isn't working:

function titleCase(str) {
  var array = str.split(" ");
  for (i = 0; i < array.length; i++) {
      array[i][0].toUpperCase;
  }
  var capStr = array.join(" ")
  return capStr;
}

titleCase("I'm a little tea pot");

i imagine because .toUpperCase isn't available to arrays, but not sure how to capitalize anything in an array

Coy Sanders
@coymeetsworld
Jun 17 2017 04:56
its on the challenge page, they also provide a link where you can test api calls
Aizaz Shahid
@aizazshahid
Jun 17 2017 04:58
@kevinwr .toUpperCase() is a method you missed ()
Manish Giri
@Manish-Giri
Jun 17 2017 04:58
@kevinwr array[i][0].toUpperCase;
1 - this is a function, so ()
2 - you need to save the return value
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:58
@Manish-Giri got a way around it
Manish Giri
@Manish-Giri
Jun 17 2017 04:58
once you do 2, you should -
  1. join the capitalized first letter with the rest of the word
  2. put it back in it's position in the array
@kevinwr
@Lumexralph :scream:
how?
Ogundele Olumide
@Lumexralph
Jun 17 2017 04:59
@Manish-Giri and you won't believe it....just 2 characters I used in the Replace Avengers War
Manish Giri
@Manish-Giri
Jun 17 2017 04:59
wow
Hemakshi Sachdev
@hemakshis
Jun 17 2017 05:00
Hey Guys! I am finally done with my Random Quote Machine Challenge...
I would really love to hear your views/feedback... please do visit it :grinning:
@cmccormack @SkyC0der thanks a lot guys!! for helping me so much :)
https://codepen.io/hemakshis/full/GEjbGb/
CamperBot
@camperbot
Jun 17 2017 05:00
hemakshis sends brownie points to @cmccormack and @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 1748 | @skyc0der |http://www.freecodecamp.com/skyc0der
:cookie: 930 | @cmccormack |http://www.freecodecamp.com/cmccormack
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:00
@Manish-Giri template literals and String.raw method
Kevin
@kevinwr
Jun 17 2017 05:00
@Manish-Giri should I save the returned capitalized characters in another array, then join the arrays?
Manish Giri
@Manish-Giri
Jun 17 2017 05:01
@kevinwr no you can modify the same array over which you're looping
it saves space
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:01
@Manish-Giri
const replaceSlash = (str) => str.replace(/\\/g, "/");

//create a raw string so no characters are escaped
//using template literals

let rawString = String.raw`C:\Users\Lenovo admin\Desktop\Projects\module.js`;

replaceSlash(rawString);
Manish Giri
@Manish-Giri
Jun 17 2017 05:02
@Lumexralph niice
well done :clap:
Coy Sanders
@coymeetsworld
Jun 17 2017 05:02
what's that?
Manish Giri
@Manish-Giri
Jun 17 2017 05:02
just read up on String.raw
i didn't even know it exists
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:02
@Manish-Giri Avengers War complete, victory!
Manish Giri
@Manish-Giri
Jun 17 2017 05:03
@coymeetsworld C:\Users\Lenovo admin\Desktop\Projects\module.js
you can't attempt to replace the \ in this string input directly
it fails
so .raw
@Lumexralph :congratulations:
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:04
@coymeetsworld i was playing around with modules and using the ES 6 built-in method, on importing my module I had to use the require function which will take a string (the file path), I can't be replacing backslash \ all the time with / manually, so created a function, discussed with @Manish-Giri on the challenge till it just got solved
Kevin
@kevinwr
Jun 17 2017 05:06
@Manish-Giri not quite sure what you mean. the .toUpperCase() doesn't work on an array element from what I'm discoverying.
Manish Giri
@Manish-Giri
Jun 17 2017 05:06
@kevinwr right, it works on a string, but aren't you doing that?
@kevinwr array[i][0].toUpperCase - here, array[i] should give you the word in the current iteration, and [0] should give you the first letter
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:07
const callback = word => word.charAt(0).toUpperCase() + word.substr(1).toLowerCase();
    return str.split(" ").map( callback ).join(" ");
thinking, the replace is better here ?
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:07
@Manish-Giri can we ever get to the edge of this thick programming wilderness?
Manish Giri
@Manish-Giri
Jun 17 2017 05:07
never :smiling_imp:
@Lumexralph
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:08
are we damned ?
Manish Giri
@Manish-Giri
Jun 17 2017 05:08
so damned
:disappointed:
Kevin
@kevinwr
Jun 17 2017 05:08
@Manish-Giri no clue? All I know is that I took the string, that was passed through to a function, then took that variable (str) and applied the .split() method to put each word into an array. I'm not sure if each element is a string now, or what.
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:08
damn! :disappointed:
Coy Sanders
@coymeetsworld
Jun 17 2017 05:08
@Lumexralph ah I see
Manish Giri
@Manish-Giri
Jun 17 2017 05:09
@kevinwr hold up
Kevin
@kevinwr
Jun 17 2017 05:09
@forwebtech eek. a lot of stuff in there I haven't even learned yet. lol
Manish Giri
@Manish-Giri
Jun 17 2017 05:09
@kevinwr it's okay, let's just focus on your code for now..
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:10
@coymeetsworld it looked like an easy stuff at first till \ started it's magic
Revanth Dasari
@Evan171
Jun 17 2017 05:10
How is the counting cards problem be done?
go through this
this has your code so far, with a console log statement
try to understand the output on the right
then we'll proceed
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:10
@Evan171 some use switch statement, while some use if statement
Manish Giri
@Manish-Giri
Jun 17 2017 05:10
@kevinwr ignore the undefined for now.
shameelrauf
@shameelrauf
Jun 17 2017 05:11
hi i need help in Assignment with a Returned Value
Manish Giri
@Manish-Giri
Jun 17 2017 05:11
@Lumexralph I think in Python(or Java), you can do it directly..
perhaps.
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:12
@Evan171 check the values and increment or decrement count based on that, then you use a conditional statement to check if count is positive ( > 0) or negative then you return count + string (" Hold or Bet")
@shameelrauf ask your question
@Manish-Giri really? that's life made easy
Manish Giri
@Manish-Giri
Jun 17 2017 05:13
@Lumexralph I don't know for sure, it appeared that way in the SO answers..
Bryan Reese
@breese8009
Jun 17 2017 05:13
here was my final solution...
function addTogether(a,b) {

let args= Array.prototype.slice.call(arguments);

let test=args.filter((x)=> typeof x !== 'number');

let validNum=(arg)=>{
return typeof arg === 'number' ? true : false;
};

if(test.length!==0) return undefined;

else if(args.length===2){
    return a+b;
  }

else if(args.length===1){
  return function(arg){
    if(validNum(args[0])===true && validNum(arg)===true){ 
    return arg+args[0];
    }
    else{
  return undefined;
    }
  };
 } 
}
addTogether(2,3);
shameelrauf
@shameelrauf
Jun 17 2017 05:13

im stuck with the below code var processed = 2;

function processArg(num) {
var sum =0;
var ourSum = sum(5, 12);

}
processed = processArg(7);

Ogundele Olumide
@Lumexralph
Jun 17 2017 05:13
@Manish-Giri but are they not same characters in all string in all programming languages?
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:13
@kevinwr actually i didn't mean to give you that i want some others to look at that, wondering for better approach.
Manish Giri
@Manish-Giri
Jun 17 2017 05:14
@Lumexralph I think so yeah, maybe it's just how the characters are processed by different engines/compilers?
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:14
@Manish-Giri I think so too, maybe JS interpreter
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:14
@shameelrauf sum(5 , 12 ) ?? where you define that funciton
shameelrauf
@shameelrauf
Jun 17 2017 05:14
it sys Assume we have pre-defined a function sum which adds two numbers together, then:
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:14
@shameelrauf what should be the output? and you need to return a value from your function too
shameelrauf
@shameelrauf
Jun 17 2017 05:15

Assume we have pre-defined a function sum which adds two numbers together, then:

ourSum = sum(5, 12);

will call sum function, which returns a value of 17 and assigns it to ourSum variable.

Kevin
@kevinwr
Jun 17 2017 05:16

@Manish-Giri Not understanding why you just get the first letter capitalized since you're using a loop to capitalize only the first letter of each element.

Because at the beginning you have ["I'm", "a", "little", "tea", "pot"], then when you run the loop through, it should become ["I'm", "A", "Little", "Tea", "Pot"]

Coy Sanders
@coymeetsworld
Jun 17 2017 05:16
does that work @breese8009 ?
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:16
@shameelrauf your function will take 2 arguments i.e it'll have 2 parameters say a and b and what your function will do is return a + b; which is the sum
Manish Giri
@Manish-Giri
Jun 17 2017 05:16
@kevinwr that's not my code, that was the code you wrote
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:16
@shameelrauf yes your approach is good but you have to make that function first :)
Manish Giri
@Manish-Giri
Jun 17 2017 05:17
:point_up: June 17, 2017 12:56 AM@kevinwr
Coy Sanders
@coymeetsworld
Jun 17 2017 05:17
oh wait, I see
Manish Giri
@Manish-Giri
Jun 17 2017 05:17
but to answer your question
array[i][0] - what will this give you? @kevinwr
shameelrauf
@shameelrauf
Jun 17 2017 05:17
@forwebtech let me try
Manish Giri
@Manish-Giri
Jun 17 2017 05:18
@kevinwr let's say array[i] is "little"
Bryan Reese
@breese8009
Jun 17 2017 05:18
@coymeetsworld yea
Kevin
@kevinwr
Jun 17 2017 05:19
@Manish-Giri it selects the element with index i, and then selects the first character in the element
Manish Giri
@Manish-Giri
Jun 17 2017 05:19
@kevinwr yes, and you're doing .upperCase() on that, so it capitalizes just that first letter
mayoorika
@mayoorika
Jun 17 2017 05:19

guys i need help....how to Use the + operator to build myStr // Example
var myStr = "This is the start. " + "This is the end.";

// Only change code below this line

var myStr;

Ogundele Olumide
@Lumexralph
Jun 17 2017 05:20
@mayoorika you mean += operator ?
Kevin
@kevinwr
Jun 17 2017 05:20
right. So it should turn out to be ["I'm", "A", "Little", "Tea", "Pot"]
Manish Giri
@Manish-Giri
Jun 17 2017 05:21
@kevinwr why?
Kevin
@kevinwr
Jun 17 2017 05:21
because you're only selecting the first character
Manish Giri
@Manish-Giri
Jun 17 2017 05:21
.upperCase() will return you a value, but it won't modify the existing string in place
you need to do that yourself
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:21
@mayoorika what's the instruction?
Manish Giri
@Manish-Giri
Jun 17 2017 05:21
so in your code
for (i = 0; i < array.length; i++) {
      array[i][0].toUpperCase;
  }
mayoorika
@mayoorika
Jun 17 2017 05:21
no only use + @Lumexralph
Kevin
@kevinwr
Jun 17 2017 05:22
So what is it doing when it goes through the loop? What gets spit ouch eat iteration?
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:22
@mayoorika you already have what you want to do in your code
Manish Giri
@Manish-Giri
Jun 17 2017 05:22
array[i][0].toUpperCase(); - to JS this line is like, okay I capitalized the first letter but since you didn't tell me what do with it, I'll just throw it away
@kevinwr
Kevin
@kevinwr
Jun 17 2017 05:23
I just figured it modified the existing array by running it through the loop
Manish Giri
@Manish-Giri
Jun 17 2017 05:23
nope
it won't
Kevin
@kevinwr
Jun 17 2017 05:23
So does running it through the loop create a new array?
Manish Giri
@Manish-Giri
Jun 17 2017 05:23

nope, it won't. That's what I said here -

once you do 2, you should -

  1. join the capitalized first letter with the rest of the word
  2. put it back in it's position in the array
Kevin
@kevinwr
Jun 17 2017 05:24
or when I run it, it's just spitting out a capitalized first letter?
mayoorika
@mayoorika
Jun 17 2017 05:24
yes but i can not going to next step /use the + operator to build myStr/ @Lumexralph
Manish Giri
@Manish-Giri
Jun 17 2017 05:24
as of now yes
just spitting out
nothing more
you need to tell it what more to do
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:24
@mayoorika what should be your output?
Kevin
@kevinwr
Jun 17 2017 05:24
ok. hmmmmm
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:25
@kevinwr strings are immutable in JS you can't change the part of them directly you need to remake a new string and then you need to store your new one, either in pervious array or make a new one. there are some builtin methods that can do that for you.
mayoorika
@mayoorika
Jun 17 2017 05:25
Build myStr from the strings "This is the start. " and "This is the end." using the + operator. @Lumexralph
Kevin
@kevinwr
Jun 17 2017 05:26
@forwebtech why am I not getting this!? :(
Manish Giri
@Manish-Giri
Jun 17 2017 05:26
@kevinwr HINT - you should use string concatenation
that was one of the challenges in the exercises
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:27
@mayoorika so what is the FCC test expecting ? I'm asking because their test checks the output
@mayoorika or if you have a link
Kevin
@kevinwr
Jun 17 2017 05:28
It's so confusing because I don't know when to use one thing over something else. I also don't seem to know how loops, methods, functions, or anything else works. It's like everything I've done thus far has taught me nothing.
Manish Giri
@Manish-Giri
Jun 17 2017 05:28
@kevinwr check out the JS lessons on codeacademy
might be helpful
Kevin
@kevinwr
Jun 17 2017 05:31
I don't know if I should go back and redo all my javascript challenges or not, or what I should be doing.
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:32
@kevinwr
var str = "test";
str[0] = "b";   // wrong way: can't change the part of string
str =  "B" + str.substr(1); // correct way
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:32
@mayoorika var myStr = "This is the start. " + "This is the end."; you did it earlier and it's correct, remove the additional var myStr; you have below
Kevin
@kevinwr
Jun 17 2017 05:33
@forwebtech how am I expected to know how to do this if they haven't even taught us .substr?
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:33
@kevinwr but they gave you the link in many challenges
Kevin
@kevinwr
Jun 17 2017 05:34
not to that
Lhats0
@stahloliver
Jun 17 2017 05:34
Hi guys, anyone to help with Twitter API? Trying to complete the Random quote generator challenge
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:34
@kevinwr ok see mdn.io/substr
@kevinwr if they don't tell you then it doesn't mean you can't search it. so try to learn some builtin functions.
Paul Christian L. Catoera
@poncatoera
Jun 17 2017 05:36
can anybody give a hint on how to approach the title case a sentence task>
?
mayoorika
@mayoorika
Jun 17 2017 05:36
@Lumexralph already i did it but i can not next step
Manish Giri
@Manish-Giri
Jun 17 2017 05:36
@poncatoera there are many hints being discussed here
if you scroll up
mayoorika
@mayoorika
Jun 17 2017 05:36
@Lumexralph my output this var myStr = "This is the start. " + "This is the end."; you did it earlier and it's correct, remove the additional var myStr; you have below
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:37
@poncatoera split your string into words array before that first lowercase it and then try to use loop / iterator that will go to each word, then in that you can make a new string with many ways.
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:38
@mayoorika can you show the whole code again?
mayoorika
@mayoorika
Jun 17 2017 05:39

@Lumexralph yeah here..
// Example
var myStr = "This is the start. " + "This is the end.";

// Only change code below this line

Paul Christian L. Catoera
@poncatoera
Jun 17 2017 05:41
@forwebtech why is it needed to lowercase the strings?
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:41

@mayoorika

// Example
var ourStr = "I come first. " + "I come second.";

// Only change code below this line

var myStr;

don't know if FCC checks it all, use this initial code given and put your solution below as commented

Aizaz Shahid
@aizazshahid
Jun 17 2017 05:41
@poncatoera because it may be possible like, teXt ? in that case, it should changed as Text
Paul Christian L. Catoera
@poncatoera
Jun 17 2017 05:42
@forwebtech what method should i use to capitalize the first letter in the word? i tried a replace but it doesnt work
mayoorika
@mayoorika
Jun 17 2017 05:42
@Lumexralph this is my output
myStr = "This is the start. This is the end.";
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:43
@poncatoera replace also can be used, you did it wrongly i think. but you can use substr() to make a new one. And .charAt().
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:43
@mayoorika you're missing out the var keyword before the myStr
Varun kumar
@varunkmr19
Jun 17 2017 05:43
Need help in Word Blanks challenge
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:44
@poncatoera mdn.io/substr and mdn.io/charAt
Manish Giri
@Manish-Giri
Jun 17 2017 05:44
@Lumexralph are you on codewars?
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:44
@mayoorika
// Example
var ourStr = "I come first. " + "I come second.";

// Only change code below this line

var myStr = "This is the start. " + "This is the end.";
@Manish-Giri I'm but been a prodigal son
Manish Giri
@Manish-Giri
Jun 17 2017 05:45
lol
Paul Christian L. Catoera
@poncatoera
Jun 17 2017 05:45
array[i].replace(array[i].charAt(0), array[i].charAt(0).toUpperCase())
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:45
sometimes I don't like their hidden tests
mayoorika
@mayoorika
Jun 17 2017 05:46
no i put var keyword but this is only output
@Lumexralph
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:47
some are just minor bugs and they won't say, I had to use JSON.stringify for one of my solutions at some point, I got angry and wandered off @Manish-Giri
Manish Giri
@Manish-Giri
Jun 17 2017 05:47
lol
I'm trying to understand how it works
like what divisions/groupings are there, etc
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:48
@poncatoera seems right but assign it also, because it returns a new string.
Varun kumar
@varunkmr19
Jun 17 2017 05:48
what should be the output of Word Blanks Challenge?
Paul Christian L. Catoera
@poncatoera
Jun 17 2017 05:48
ohh okay thanksill try
@forwebtech ty
CamperBot
@camperbot
Jun 17 2017 05:48
poncatoera sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 709 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:49
@poncatoera :+1:
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:49
@mayoorika that's the answer above
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:49
@varunkmr19 a proper sentence, which used all the parameters but remember to separate them with space.
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:49
@Manish-Giri you mean me?
Manish Giri
@Manish-Giri
Jun 17 2017 05:50
@Lumexralph yea
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:51
@Manish-Giri just solving problems , they are ranked according to difficulties and you get to see other people's solutions after you've solved it, that's the little I know about it
Manish Giri
@Manish-Giri
Jun 17 2017 05:52
@Lumexralph all I could understand is there's this "kata" thing
Aizaz Shahid
@aizazshahid
Jun 17 2017 05:52
still doing some challenges of codeWars.
Manish Giri
@Manish-Giri
Jun 17 2017 05:52
it brings up a long list of problems
but other than that there's no grouping
like other websites have sub sections - algorithms, implementation, dynamic programming, etc
@Lumexralph
brb
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:54
@Manish-Giri nah..... just picks problems for you at random, i don't know really maybe you study the site more?
okay
mayoorika
@mayoorika
Jun 17 2017 05:55
@Lumexralph i done thq so much
Ogundele Olumide
@Lumexralph
Jun 17 2017 05:56
@mayoorika you're welcome
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:01
@Lumexralph did you notice, FCC removes the parameters from url that is a really good thing.
madankumar sm
@madanamigo
Jun 17 2017 06:01
help me fix this one
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:01
@madanamigo code ?
madankumar sm
@madanamigo
Jun 17 2017 06:02

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

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

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

Ogundele Olumide
@Lumexralph
Jun 17 2017 06:02
@forwebtech not until you brought my awreness to it
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:02
:)
Nikolas Pinon
@NikolasP98
Jun 17 2017 06:02
guys! I'm in the profile lookup challenge
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:02
that's cool
Nikolas Pinon
@NikolasP98
Jun 17 2017 06:02
I need help
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:03
@madanamigo if you are accessing global array then what use of arr ? use parameters instead global ones. a
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:03
@madanamigo push item into arr, use shift then return the removed element
@NikolasP98 what have you tried?
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:03
@madanamigo also shift() don't take arguments. mdn.io/shift
Nikolas Pinon
@NikolasP98
Jun 17 2017 06:04
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];

//MY CODE STARTS HERE
function lookUpProfile(firstName, prop){
// Only change code below this line
  //for (var i = 0; i < contacts.length; i++) 
  var i = 0;
  var j = contacts.length - 1;
  while (i < contacts.length){

    if (contacts[i].firstName === firstName) {
    return contacts[i][prop];

    } else if (contacts[i].firstName !== firstName) {
      i++;
    }

  }
  if (contacts[j].firstName !== firstName){
      return "No such contact";
    } else if (contacts[j].prop !== prop) {
               return "No such property";
               }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
I need to verify the existence of the proposed property ('prop')
and if it doesn't exist, "No such property" should be returned
I don't know how to access a property name
I also want to change the whole logic behind:
var j = contacts.length - 1
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:07
@NikolasP98 use for loop instead and also you don't need so much conditional statements.
Nikolas Pinon
@NikolasP98
Jun 17 2017 06:08
what can I accomplish with loop
how do I apply it to this excersize
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:08
@NikolasP98 that will iterate through all the contacts
@NikolasP98
for( var i=0; i< contacts.length; i++ ) {
...
}
@NikolasP98 if you are using parameter to look for the property then you need to use [] bracket notation.
@NikolasP98 because contacts[i].prop will becomes contacts[i]."some value" and that will throw an exception, so to avoid it we use [] brackets, that accepts strings.
. dot operator will only good where you have direct access to the object.
Nikolas Pinon
@NikolasP98
Jun 17 2017 06:11
so if I want to check of the property "Kittens" exists, then I'd state contacts[i][Kittens]
mackyking
@mackyking
Jun 17 2017 06:11
Help...
Help...
I need help guys...
Nikolas Pinon
@NikolasP98
Jun 17 2017 06:11
wuddup
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:11
@NikolasP98 no, it should be contacts[i]["Kittens"] because you are directly accessing the property, and if you put contacts[i][Kittens] then Kittens act like a variable .
Nikolas Pinon
@NikolasP98
Jun 17 2017 06:11
great
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:12
@NikolasP98 contacts[i].hasOwnProperty("kittens")
Nikolas Pinon
@NikolasP98
Jun 17 2017 06:12
@forwebtech @Lumexralph thanks
CamperBot
@camperbot
Jun 17 2017 06:12
nikolasp98 sends brownie points to @forwebtech and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 710 | @forwebtech |http://www.freecodecamp.com/forwebtech
:star2: 1946 | @lumexralph |http://www.freecodecamp.com/lumexralph
mackyking
@mackyking
Jun 17 2017 06:13
@Lumexralph I need help
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:14
@mackyking I can try, ask
That's the challenge i cant solve...
Markus Ivancsics
@ivancsicsmarkus
Jun 17 2017 06:16
@mackyking You just have to switch for the variable val.
@mackyking If it is one the answer is "alpha".
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:17

@Lumexralph what approach is good ?

const toTruncate = len => str.slice(0, len).concat("...");
return (str.length > num) ? (num > 3) ? toTruncate(num-3) : toTruncate(num) : str;

or

const toTruncate = len => str.slice(0, len).concat("...");

  if(str.length > num) {  
    return (num > 3) ? toTruncate(num-3) : toTruncate(num);
  } else {
    return str;
  }
Markus Ivancsics
@ivancsicsmarkus
Jun 17 2017 06:17
@mackyking So change the variable answer to "alpha"!
madankumar sm
@madanamigo
Jun 17 2017 06:18
guys i m not getting @forwebtech @Lumexralph
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:18
@madanamigo code ?
Markus Ivancsics
@ivancsicsmarkus
Jun 17 2017 06:18
@forwebtech I think the second is more readable.
NSS534
@NSS534
Jun 17 2017 06:18

PLease help me with this.....................
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
celsius= fahrenheit*9/5+32;

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

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

Ogundele Olumide
@Lumexralph
Jun 17 2017 06:19
@forwebtech i personally like the second, for my own readability, and you can do away with the else stuff since you're returning a value
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:19
@NSS534 that formula is for fahrenheit not for celsius, you need to change the given celsius to fahrenheit.
@Lumexralph point :+1:
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:20
@madanamigo what issue is that?
@NSS534 it should be interchanged, fahrenheit and celsius
NSS534
@NSS534
Jun 17 2017 06:21
@forwebtech Thank tou
CamperBot
@camperbot
Jun 17 2017 06:21
nss534 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 711 | @forwebtech |http://www.freecodecamp.com/forwebtech
mackyking
@mackyking
Jun 17 2017 06:21
@ivancsicsmarkus Can we talk in private?
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:21
@NSS534 :+1:
mackyking
@mackyking
Jun 17 2017 06:22
@ivancsicsmarkus Can you give the complete syntax or code structure?
madankumar sm
@madanamigo
Jun 17 2017 06:23

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

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

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

Aizaz Shahid
@aizazshahid
Jun 17 2017 06:23
@madanamigo do you know what are parameters ?
mackyking
@mackyking
Jun 17 2017 06:23
@Lumexralph Can you help me?
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:24
@mackyking what are the instructions?
Markus Ivancsics
@ivancsicsmarkus
Jun 17 2017 06:24

@mackyking

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

...

Aizaz Shahid
@aizazshahid
Jun 17 2017 06:25
@madanamigo you are passing the reference of your array as argument, which will go to your parameter arr now you have to use that reference (arr) to access the global array in your function,
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:25
@mackyking do you understand how switch statement works?
mackyking
@mackyking
Jun 17 2017 06:29
@ivancsicsmarkus Thanks
CamperBot
@camperbot
Jun 17 2017 06:29
mackyking sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 622 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
mackyking
@mackyking
Jun 17 2017 06:30
@Lumexralph Thanks too...
CamperBot
@camperbot
Jun 17 2017 06:30
mackyking sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1947 | @lumexralph |http://www.freecodecamp.com/lumexralph
mackyking
@mackyking
Jun 17 2017 06:38
By the way guys... What is the use of many brownies point here?
Ayush Mahajan
@ay2306
Jun 17 2017 06:39
blob
what does this mean?
anyone?
madankumar sm
@madanamigo
Jun 17 2017 06:42
tq @forwebtech . i got it ..
CamperBot
@camperbot
Jun 17 2017 06:42
madanamigo sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 712 | @forwebtech |http://www.freecodecamp.com/forwebtech
Akash Kandpal
@harrypotter0
Jun 17 2017 06:42
@Lumexralph Which editor should I use for html,css and js in ubuntu 16.04 ?
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:44
@mackyking nothing, they are just numbers that can be gained by doing challenges and helping others.
jdnelson55
@jdnelson55
Jun 17 2017 06:49
brackets
@harrypotter0 brackets is my favorite
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:51
@harrypotter0 i use sublimetext, should try out visual Studio code too...
@harrypotter0 there're so many it's about what you want
Lauwed
@Lauwed
Jun 17 2017 06:53

```
// Setup
function abTest(a, b) {
// Only change code below this line

if(a < 0) {
a -= b;
}

if(b < 0) {
b -= a;
}

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,-2);
```

Ogundele Olumide
@Lumexralph
Jun 17 2017 06:53
@Manish-Giri did you enjoy it :smile:
Lauwed
@Lauwed
Jun 17 2017 06:53
Oops
How can I return an undefined?
Please :---D
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:54
@Lauwed return a < b; should give you a boolean
Lauwed
@Lauwed
Jun 17 2017 06:54
Wow okay I get the comments wrong! Thanks and sorry! :----D
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:55
@Lauwed use condition statement to check if a < 0 or b < 0 then you return undefined
Lauwed
@Lauwed
Jun 17 2017 06:55
Ow no in fact I can't touch te return..
Manish Giri
@Manish-Giri
Jun 17 2017 06:55
@Lumexralph eh it was okay
not a very difficult one
Lauwed
@Lauwed
Jun 17 2017 06:55
Ah yes like that! Thank you @Lumexralph
CamperBot
@camperbot
Jun 17 2017 06:55
lauwed sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1948 | @lumexralph |http://www.freecodecamp.com/lumexralph
Manish Giri
@Manish-Giri
Jun 17 2017 06:55
function arr2bin(arr){
  // show me the code
    return arr.filter(char => typeof char === "number").reduce((a,b) => a+b, 0).toString(2);
}
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:55
@Manish-Giri I'm on shift today :disappointed:
Manish Giri
@Manish-Giri
Jun 17 2017 06:56
haha
enjoy!
Akash Kandpal
@harrypotter0
Jun 17 2017 06:56
@Manish-Giri @Lumexralph Can we integrate html, css ,and different files and make a working project on local host ? If so how ?
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:56
@Manish-Giri my colleagues enjoying their weekend..... must we even work
Manish Giri
@Manish-Giri
Jun 17 2017 06:56
I know
:sob:
so sad
heidisdad2
@heidisdad2
Jun 17 2017 06:57
having a little trouble guys. I think it is with my for loop
been working on this one for an hour or 2
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:57
@harrypotter0 your text editor and browser should do
Akash Kandpal
@harrypotter0
Jun 17 2017 06:58
I have functions in js and scipts too how will they integrate with code in html and css ?
NSS534
@NSS534
Jun 17 2017 06:58

Only remove the backslashes \ used to escape quotes.

var myStr =\ 'This string has \"double quotes\" in it.And \"probably\" lots of them.\';

Ogundele Olumide
@Lumexralph
Jun 17 2017 06:58
@harrypotter0 just link your css and js files to your html and use your browser to view the html file
heidisdad2
@heidisdad2
Jun 17 2017 06:59
function titleCase(str) {
  //make whole string lowercase
   var lowerCase = str.toLowerCase();
  //split sting into array by word
  var lowerSplit = lowerCase.split(" ");
  //reference i for each string inside the variable 
//change each words first letter to capital
for(i=0; i<str.length; i++){
  var arr =[];
 arr= lowerSplit;
 return arr[i].toUpperCase();
}
} 
titleCase("I'm a little tea pot");
Aizaz Shahid
@aizazshahid
Jun 17 2017 06:59
is that solution is complex ? mutation
    const unique = index => [...new Set( arr[index].toLowerCase() )],
          regex = new RegExp(`[${arr[1].toLowerCase()}]`, 'gi');

    return unique(0).join("").match(regex).length === unique(1).length;
Ogundele Olumide
@Lumexralph
Jun 17 2017 06:59
@harrypotter0 you target the DOM element from the css and js scripts
heidisdad2
@heidisdad2
Jun 17 2017 07:00
the i keeps referenceing 0
no matter what, it references 0
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:00
@heidisdad2 why don't you short it :
  var lowerSplit = str.toLowerCase().split(" ");
Ayush Mahajan
@ay2306
Jun 17 2017 07:00
I am having problem with twitch api. I am not even understand it.. what should I do?
Dave Guymon
@daveguymon
Jun 17 2017 07:00
Help please . . . I am trying to sort the array and return the lowest index where the num parameter could be inserted. My code isn't working for the array and num in the function call here.
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.

  arr.sort();

  for (var i = 0; i < arr.length; i++) {
    if (num <= arr[i]) {
      return arr.indexOf(arr[i]);
    } 

  }

}

getIndexToIns([5, 3, 20, 3], 5);
heidisdad2
@heidisdad2
Jun 17 2017 07:01
@forwebtech not sure why i didn't do that...great idea. but that isn't where my problem is i dont think.
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:01
@heidisdad2 and also you need to run your loop on the splitted array length not on str length.
@heidisdad2 just giving you tip :) i know that's not the problem.
heidisdad2
@heidisdad2
Jun 17 2017 07:02
@forwebtech ohhhh that makes sense..thank you man.
CamperBot
@camperbot
Jun 17 2017 07:02
heidisdad2 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 713 | @forwebtech |http://www.freecodecamp.com/forwebtech
Akash Kandpal
@harrypotter0
Jun 17 2017 07:02
@Lumexralph Ok I will do it . thanks for your time.
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:02
@heidisdad2 and also why are you creating new array at every time in your loop:
var arr =[];
@heidisdad2 and also return statement stops the function immediately by returning the statement.
@daveguymon you need to insert that num to your array and then just returns its index number, you don't need a loop for that. and also remember to sort it after inserting.
NSS534
@NSS534
Jun 17 2017 07:09
how can i have encoded text with the proper escape sequences and no spacing.
var myStr="\FirstLine\nSecondLine\rThirdLine\";
heidisdad2
@heidisdad2
Jun 17 2017 07:09
@forwebtech wow im really not that good at this, thanks for the tips, im gonna get better
CamperBot
@camperbot
Jun 17 2017 07:09
heidisdad2 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:warning: heidisdad2 already gave forwebtech points
NSS534
@NSS534
Jun 17 2017 07:09
how can i have encoded text with the proper escape sequences and no spacing.
var myStr="\FirstLine\nSecondLine\rThirdLine\";
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:10
@NSS534 FirstLine\n\\SecondLine\\\rThirdLine you just need that remove the slashes from start and end.
heidisdad2
@heidisdad2
Jun 17 2017 07:14
@forwebtech i created the array because i wasn't getting my for loop back in array form. thought i had to put it in array form .
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:15
@heidisdad2 actually you don't need a new array you can assign a new string to the existing once.
word[i] = new word having first letter uppercase
heidisdad2
@heidisdad2
Jun 17 2017 07:25
hmm
back to the drawing board i guess
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:27
@heidisdad2 you have lowerSplit to get the words, use it as above said.
NSS534
@NSS534
Jun 17 2017 07:30

how to replace J with H
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H";

Aizaz Shahid
@aizazshahid
Jun 17 2017 07:30
@NSS534 you can't change the part of String, you need to reassign it with new value.
@NSS534 there are some builtin methods that you can use like replace or substr mdn.io/replace mdn.io/substr but that challenge is not needed those methods, so just directly assign the new value by self.
Tiago Malheiro
@Azzrah
Jun 17 2017 07:42
how can I make this if statement work for all contacts, and not just 0?
´´´
function lookUpProfile(firstName, prop){
// Only change code below this line
if (firstName == contacts[0].firstName && contacts[0].hasOwnProperty(prop)){
return contacts[0][prop];
}
// Only change code above this line
}
´´´
NSS534
@NSS534
Jun 17 2017 07:43

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

// Your code above this line
return result;
}

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

Tiago Malheiro
@Azzrah
Jun 17 2017 07:43
the code didn't paste correctly, I think I did something wrong with the ```
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:45
@NSS534 you need to use the parameters to make a new sentence but remember to separate them with space and also you can put any text to make it proper, use result for your sentence.
Aakash Bhusal
@aakashbhusal7
Jun 17 2017 07:50
In chunky monkey, i am getting correct output for cases like these:
chunkArrayInGroups(["a", "b", "c", "d"], 2) should return [["a", "b"], ["c", "d"]].
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3) should return [[0, 1, 2], [3, 4, 5]].
but for case like this:
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4) should return [[0, 1, 2, 3], [4, 5]]
i am only getting [[0,1,2,3]] as output
Any hints guys??
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:53
@Azzrah how you will search all the contacts as you are just searching in the first contact ?
@aakashbhusal7 paste the code as formatted.
Aakash Bhusal
@aakashbhusal7
Jun 17 2017 07:54
@forwebtech how to format it
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:55
```
put code between backticks
```
Aakash Bhusal
@aakashbhusal7
Jun 17 2017 07:55
function chunkArrayInGroups(arr, size) {
  var arr1=[];
  var arr2=[];
  var a=0;
  for(var i=1;i<=arr.length;i++){
    if(i% size !==0){
      continue;
    }
    arr1= arr.slice(a,i);
    a=a+size;
    arr2.push(arr1);
    arr1=[];      
  }
  return arr2;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4);
Aizaz Shahid
@aizazshahid
Jun 17 2017 07:55
@Azzrah and your code is not formatted because you used the frontticks not backticks
@aakashbhusal7 why do you run your loop from 1 ?
@aakashbhusal7 and don't you think ? only one array is required.
Aakash Bhusal
@aakashbhusal7
Jun 17 2017 08:00
@forwebtech yes one array is required.
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:02
@aakashbhusal7 you need to do those steps into your loops, suppose we get [1, 2, 3, 4, 5, 6], 3 so our loop should do that:
> first Iteration:
arr.slice(0,  3);

> second iteration
 arr.slice(3, 6);
now you have to increment your i as per condition, not i++
Aakash Bhusal
@aakashbhusal7
Jun 17 2017 08:08
@forwebtech :+1: thanks
solved it this way
function chunkArrayInGroups(arr, size) {
  var arr1=[];
  var arr2=[];
  for(var i=0;i<arr.length;i+=size){
    arr1=arr.slice(i,size+i);
    arr2.push(arr1);
}
  return arr2;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4);
CamperBot
@camperbot
Jun 17 2017 08:08
aakashbhusal7 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 714 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:08
@aakashbhusal7
arr1.push( arr.slice(i,size+i) );
you don't need the other array.
bisherwalankit
@bisherwalankit
Jun 17 2017 08:19
Correct the assignment to myStr to achieve the desired effect

// Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me

can anybody tell what to do?
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:20
@bisherwalankit you can't change the part of the string, but you can reassign it with new value.
bisherwalankit
@bisherwalankit
Jun 17 2017 08:21
how to reaasign with new value?
Tiago Malheiro
@Azzrah
Jun 17 2017 08:22
just myStr again i think
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:22
@bisherwalankit just put the value with = but don't use []
Tiago Malheiro
@Azzrah
Jun 17 2017 08:22
var myStr**
bisherwalankit
@bisherwalankit
Jun 17 2017 08:24
@forwebtech Thanks buddy
CamperBot
@camperbot
Jun 17 2017 08:24
bisherwalankit sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 715 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:24
@bisherwalankit :+1:
Jen
@jenniredfield
Jun 17 2017 08:34
hiya anyone did the truncate a string challenge

'''

function truncateString(str, num) {
// Clear out that junk in your trunk
var trun;
var strNum = str.length;

if (strNum > num) {
num -= 3;
trun = str.slice(0, num);
trun = trun + "...";

} else if (strNum <= 3) {

trun = str.slice(0, str.length - num);
trun = trun + "...";

}

return trun;
}

truncateString("A-", 1);

'''

CamperBot
@camperbot
Jun 17 2017 08:34
:bulb: to format code use backticks! ``` more info
Jen
@jenniredfield
Jun 17 2017 08:34

function truncateString(str, num) {
  // Clear out that junk in your trunk
  var trun;
  var strNum = str.length;

  if (strNum > num) {
   num -= 3;
   trun = str.slice(0, num);
   trun = trun + "...";

  } else if (strNum <= 3) {

    trun = str.slice(0, str.length - num);
    trun = trun + "...";
  }


  return trun;
}

truncateString("A-", 1);
Vicky Lai
@vickylai
Jun 17 2017 08:38
@jenniredfield What's your question?
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:38
Hello, need help. I am on Roman Numeral Converter. Below is my code. It is working but my method is not right. Look at console.log statements. I incremented x to make it number. It does that without actually adding 1. But want to know what is the better way.

function convertToRoman(num) {
  var x = 0;
  numR = "";
  num = num.toString();
  romanStr = "IVXLCDM";

  function C2R(val, dig) {
    if (val === "") {
      return "";
    }

    switch(val) {
      case(0):
        return "";
      case(1):
        return dig;
      case(2):
        return dig + dig;
      case(3):
        return dig + dig + dig;
      case(4):
        return dig + romanStr[romanStr.indexOf(dig) + 1];
      case(5):
        return romanStr[romanStr.indexOf(dig) + 1];
      case(6):
        return romanStr[romanStr.indexOf(dig) + 1] + dig;
      case(7):
        return romanStr[romanStr.indexOf(dig) + 1] + dig + dig;
      case(8):
        return romanStr[romanStr.indexOf(dig) + 1] + dig + dig + dig;
      case(9):
        return dig + romanStr[romanStr.indexOf(dig) + 2];       
    }


  }

  for (i=0; i<num.length; i++) {
    switch(i) {
      case 0:
        x = num[num.length-1];
        console.log("yyyyyyy " +x);
        x = x++;
        console.log("xxxxxxx " +x);
        numR = C2R(x, "I");        
        break;
      case 1:
        x = num[num.length-2];
        x = x++;
        numR = C2R(x, "X") + numR;        
        break;
      case 2:
        x = num[num.length-3];
        x = x++;
        numR = C2R(x, "C") + numR;              
        break;
      case 3:
        x = num[num.length-4];
        x = x++;
        numR = C2R(x, "M") + numR;        
        break;
    }
  }


 return numR;
}

convertToRoman(50);
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:39
@VinayVijayJoshi did you pass with that ?
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:40
doh! i am mixing things here. x++ is not the right syntax, still my code is working. :worried:
yes
Jen
@jenniredfield
Jun 17 2017 08:41
@vickylaiio hmm am I going the right diretion
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:41
@VinayVijayJoshi x++ is a right syntax, you are incrementing your x to 1
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:41
@forwebtech yes, and I am not sure why
Jen
@jenniredfield
Jun 17 2017 08:41
Been on that challenge for sometime
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:41
its equal to x = x+1
Vicky Lai
@vickylai
Jun 17 2017 08:41
@jenniredfield You'll have to get more specific than that if you want a helpful answer :)
cryptonoobbg
@cryptonoobbg
Jun 17 2017 08:41
var myStr="FirstLine\nSecondLine\rThirdLine"; // What's the problem here?
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:41
ok, then back to my previous question. why x did not get incremented
@forwebtech ok, then back to my previous question. why x did not get incremented
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:42
@VinayVijayJoshi did you console it after incrementing ?
cryptonoobbg
@cryptonoobbg
Jun 17 2017 08:42
'''
CamperBot
@camperbot
Jun 17 2017 08:42
:bulb: to format code use backticks! ``` more info
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:42
yes, it is in code. It is the same..
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:42
@cryptonoobbg you also need a backslash before and after SecondLine
Michael Baxter
@baxt01
Jun 17 2017 08:42
to increment by 1 dont do x = x+1 this is wrong
the correct formatt is x+=1 or x++
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:43
@baxt01 what's wrong witht that ?
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:43
@forwebtech
      case 0:
        x = num[num.length-1];
        console.log("yyyyyyy " +x);
        x = x++;
        console.log("xxxxxxx " +x);
        numR = C2R(x, "I");        
        break;
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:43
@baxt01 actually that is more efficient but the syntax is right !
Michael Baxter
@baxt01
Jun 17 2017 08:44
if you say so
alpox
@alpox
Jun 17 2017 08:44
@forwebtech @baxt01 x = x + 1 works as well as the others - and none of them is more efficient than the others
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:44
x = x + 1;
x += 1;
x++;
all are correct syntax
TANVIR AHMED KHAN
@khancom
Jun 17 2017 08:44
hello everyone
alpox
@alpox
Jun 17 2017 08:44
@forwebtech More "efficient" would be ++x
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:45
@alpox post increment and pre increment matters where we storing but its depends.
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:45
@forwebtech I converted num to string at top, but then I was getting undefined error, so I did x++. It converted x to number but did not increment it.
alpox
@alpox
Jun 17 2017 08:45
@forwebtech Yes sure, but if you just want an increment without direct expression context, ++x is more performant
TANVIR AHMED KHAN
@khancom
Jun 17 2017 08:45
im stuck at javascript polindromes problem. do i need replace() method along with two other methods given to check
Jen
@jenniredfield
Jun 17 2017 08:45
@vickylaiio its ok, Think part of it works, think I just need to go back to it in a bit
Rawikitua Isherwood
@rawiki
Jun 17 2017 08:45
Hi I'm having trouble with the 'Truncate a string' challenge in Basic Algorithm scripting. I must be missing something because I don't understand this error: 'truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length) should return "A-tisket a-tasket A green and yellow basket"'. Why doesn't this string need a '...' ending?
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:46
@khancom yes to remove the non alphanumerics and space.
Jen
@jenniredfield
Jun 17 2017 08:46
@rawiki do you know what, think I'm stuck on the same thing
@rawiki my code seems to work for some posibilites but not those .length ones
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:47
@VinayVijayJoshi here it is check https://repl.it/IpfW/0 you don't need too much coding.
Michael Baxter
@baxt01
Jun 17 2017 08:47
hold on let me pull up a copy of that leasson
Rawikitua Isherwood
@rawiki
Jun 17 2017 08:48
@jenniredfield yea it might be a bug because this first .length one and the second .length +2 are suppose to return the same result.
Michael Baxter
@baxt01
Jun 17 2017 08:49
1st thing if you think your code is right and it's not working refresh your browser and try again
its a deffo bug
alpox
@alpox
Jun 17 2017 08:49
@forwebtech Correction: actually x = x + 1 and x += 1 should theoretically be more performant than x++ :-/ didn't think right ^^
VinayVijayJoshi
@VinayVijayJoshi
Jun 17 2017 08:50
@forwebtech very nice. But I still want to bang my head and come up with solutions and then ask from you pros. I get the right way from your inputs and in the former I learn a lot...
Michael Baxter
@baxt01
Jun 17 2017 08:50
is the leasson your stuck on called "Check for Palindromes"
Jen
@jenniredfield
Jun 17 2017 08:50
@rawiki so maybe add another else if str.lenght = num .. return str
Omair Shahid
@Omair133
Jun 17 2017 08:51
This code is returning the correct output, but not being accepted as a solution.
function titleCase(str) {
  var array=[];
  str=str.toLowerCase();
  array=str.split(' ');
  var ans="";
  for(var i=0;i<array.length;i++)
    {
      ans=ans+(array[i].charAt(0)).toUpperCase()+array[i].substring(1)+" ";
    }
  return ans.substring(0,ans.length-1)+".";

}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Michael Baxter
@baxt01
Jun 17 2017 08:51
@rawiki which leasson name are you on please
Rawikitua Isherwood
@rawiki
Jun 17 2017 08:53
@baxt01 'Truncate a string' under Basic Algorithm scripting
Michael Baxter
@baxt01
Jun 17 2017 08:54
ok thought it was an earlyer one i am just looking at your problem now see if i can help and complette it for me to lol
Rawikitua Isherwood
@rawiki
Jun 17 2017 08:54
@baxt01 Thanks
CamperBot
@camperbot
Jun 17 2017 08:54
rawiki sends brownie points to @baxt01 :sparkles: :thumbsup: :sparkles:
:cookie: 245 | @baxt01 |http://www.freecodecamp.com/baxt01
Aizaz Shahid
@aizazshahid
Jun 17 2017 08:55
@Omair133 why are you putting . dot ?
you just need to return the exact same string but with Title casing.
Omair Shahid
@Omair133
Jun 17 2017 08:57
Ohk..Done. Thank you.
Kevin Holmes
@codersc
Jun 17 2017 08:57
@Omair133 i think the problem is function is adding a period which in some cases is not correct
Rawikitua Isherwood
@rawiki
Jun 17 2017 08:59
@jenniredfield Unless I'm overlooking something the problem is probably in their testing script. The first .length test should return "A-tisket a-tasket A green and yellow bas..." and the second "A-tisket a-tasket A green and yellow baske..."

@jenniredfield actually I just hacked it to make it pass by adding following.

if (num === "A-tisket a-tasket A green and yellow basket".length)
{return "A-tisket a-tasket A green and yellow basket";}
if (num === "A-tisket a-tasket A green and yellow basket".length + 2)
{return "A-tisket a-tasket A green and yellow basket";}

Rawikitua Isherwood
@rawiki
Jun 17 2017 09:07
Unless there are any objections I'm opening a Github issue.
Manish Giri
@Manish-Giri
Jun 17 2017 09:07
@rawiki there's no problem in their testing script.
Ogundele Olumide
@Lumexralph
Jun 17 2017 09:10
@Manish-Giri you need to sleep :smirk:
Rawikitua Isherwood
@rawiki
Jun 17 2017 09:11
@Manish-Giri what am I overlooking in this question that's causing it to fail?
Manish Giri
@Manish-Giri
Jun 17 2017 09:11
truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length) should return "A-tisket a-tasket A green and yellow basket"'. Why doesn't this string need a '...' ending?
you truncate if the length of the string is longer than the given argument
Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.
in that case, the two are equal, so no truncate, no ....
Rawikitua Isherwood
@rawiki
Jun 17 2017 09:11
ok I just didn't read the question properly
Manish Giri
@Manish-Giri
Jun 17 2017 09:12
@Lumexralph I'm trying to :sob:
Rawikitua Isherwood
@rawiki
Jun 17 2017 09:12
@Manish-Giri cheers
Manish Giri
@Manish-Giri
Jun 17 2017 09:12
this d3 is taking longer than expected
@rawiki :+1:
Ogundele Olumide
@Lumexralph
Jun 17 2017 09:13
@Manish-Giri you're reminding me of demons i', yet to face
Manish Giri
@Manish-Giri
Jun 17 2017 09:13
lol
Ogundele Olumide
@Lumexralph
Jun 17 2017 09:15
quiet office, just my breakfast and I @Manish-Giri
Manish Giri
@Manish-Giri
Jun 17 2017 09:15
@Lumexralph lucky you
how's the weather out there
TANVIR AHMED KHAN
@khancom
Jun 17 2017 09:15
polindromes problem: do i need split, reverse methods?
Ogundele Olumide
@Lumexralph
Jun 17 2017 09:16
@Manish-Giri Nigeria weather === Africa weather but flunctuations
@Manish-Giri but it's cool so far
@Manish-Giri how's the thesis looking?
Chrille2903
@Chrille2903
Jun 17 2017 09:19
Can anyone help me? I can't remove the non-alphanumeric signs. My code is

function palindrome(str) {
// Good luck!
var oldArr = [];
var strReverse = '';

function trim(str) {
str.toString();
str.toLowerCase();
str.replace(/[\W_]/g, '');
}
trim(str);

function reverseString(strStart) {
oldArr = strStart.split('');
oldArr.reverse();
strReverse = oldArr.join('');
}
reverseString(strStart);

return str;
}

palindrome("2_A3*3#A2");

Rawikitua Isherwood
@rawiki
Jun 17 2017 09:23
@Chrille2903 try /[a-z0-9]/gi
Chrille2903
@Chrille2903