These are chat archives for FreeCodeCamp/HelpJavaScript

28th
May 2017
john94
@lpy1994
May 28 2017 00:00
@abohannon just one line.
Adam Bohannon
@abohannon
May 28 2017 00:01
@lpy1994 playing around with it now... i see i assigned two new variables.
john94
@lpy1994
May 28 2017 00:02
@abohannon split() change string to array, join() does the opposite way.
Adam Bohannon
@abohannon
May 28 2017 00:03
dont i need to split into an array, then reverse the array, and join back into a string?
john94
@lpy1994
May 28 2017 00:03
but you dont have to assign it around in your case. it could simpler.
it could be simpler
JohnGalt
@osirisseye
May 28 2017 00:04
hello awesome people
if I want to replace & (ampersand) with regular expression how does this expression look like ? (convert HTML entities challenge)
JohnGalt
@osirisseye
May 28 2017 00:08
@lpy1994 yeah, already clicked there and str.replace(/\&/g, '&');
doesn't seem to work
Adam Bohannon
@abohannon
May 28 2017 00:08
@lpy1994 how about this.
function reverseString(str) {
 newStr = str.split('').reverse().join(""); 
  return newStr;
}

reverseString("hello");
Lanre Afolayan
@michaelflourish
May 28 2017 00:08
@abohannon
var newStr = str.split('').reverse().join(''); return newStr;
Aakriti
@Aakriti94
May 28 2017 00:09
Good morning world!!
Adam Bohannon
@abohannon
May 28 2017 00:09
@michaelflourish haha nice timing!
john94
@lpy1994
May 28 2017 00:09
@abohannon return str.split('').reverse().join("");
Lanre Afolayan
@michaelflourish
May 28 2017 00:09
@abohannon that make more sense
Adam Bohannon
@abohannon
May 28 2017 00:09
@lpy1994 ah so i dont even need to assign a variable there either
john94
@lpy1994
May 28 2017 00:10
@abohannon yeah, there is no need.
Lanre Afolayan
@michaelflourish
May 28 2017 00:10
yeah!
it's allowed
Adam Bohannon
@abohannon
May 28 2017 00:10
very very cool, @lpy1994 @michaelflourish thank you!
CamperBot
@camperbot
May 28 2017 00:10
abohannon sends brownie points to @lpy1994 and @michaelflourish :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @lpy1994 |http://www.freecodecamp.com/lpy1994
:cookie: 248 | @michaelflourish |http://www.freecodecamp.com/michaelflourish
john94
@lpy1994
May 28 2017 00:10
@osirisseye which challenge ?
JohnGalt
@osirisseye
May 28 2017 00:11
Convert HTML Entities
Joseph Price
@josephprice
May 28 2017 00:11

Hello, I was wondering if anyone was a wizard when it comes to comparing values in arrays...

Let's say I had an array like this:
let array = [one banana, one coconut, one coconut, one coconut, one watermelon]

I'd like to detect whether the array has any duplicate values and then take action... does anyone know where to start?

JohnGalt
@osirisseye
May 28 2017 00:11
str.replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
Ben Line
@Benwebdev
May 28 2017 00:12
Good Morning, I'll be off to bed soon it's 1am here
JohnGalt
@osirisseye
May 28 2017 00:12
@lpy1994 changed apostrophe into double quotes and worked for ampersand but wrecked apostrophe :D
@lpy1994 ok I think i got this :)
john94
@lpy1994
May 28 2017 00:12
+
@josephprice if the element is string, you need ""
Joseph Price
@josephprice
May 28 2017 00:13
oops
yes, it would all be strings, yes
let array = ["one banana", "one coconut", "one coconut", "one coconut", "one watermelon"]
JunJPang
@JunJPang
May 28 2017 00:16
@lpy1994
john94
@lpy1994
May 28 2017 00:16
@josephprice working on FCC challenge ?
@JunJPang what ?
Joseph Price
@josephprice
May 28 2017 00:16
Was inspired to work on something more homebrew!
JunJPang
@JunJPang
May 28 2017 00:16

@lpy1994 here is my new code for the same problem:
function palindrome(str) {
var newStr;
newStr=str.toLowerCase();
newStr=newStr.replace(/[^\w]\s|_/g,'');
newStr=newStr.split('');
newStr=newStr.reverse();
newStr=newStr.join('');

if (newStr===str){

// Good luck!

return true;
}
else {
return false;}

}

palindrome("eye");

still not working
john94
@lpy1994
May 28 2017 00:18
@JunJPang you might need to change your reg exp.
first
Ben Line
@Benwebdev
May 28 2017 00:18

@josephprice "Smart" but naïve way

uniqueArray = a.filter(function(item, pos) {
return a.indexOf(item) == pos;
})
Basically, we iterate over the array and, for each element, check if the first position of this element in the array is equal to the current position. Obviously, these two positions are different for duplicate elements.

Using the 3rd ("this array") parameter of the filter callback we can avoid a closure of the array variable:

uniqueArray = a.filter(function(item, pos, self) {
return self.indexOf(item) == pos;
})
Although concise, this algorithm is not particularly efficient for large arrays (quadratic time).

JunJPang
@JunJPang
May 28 2017 00:19
@lpy1994 you mean this line newStr=newStr.replace(/[^\w]\s|_/g,'');??
Joseph Price
@josephprice
May 28 2017 00:19
Thanks @Benwebdev, I would never be getting an array larger than 6 items anyways...
CamperBot
@camperbot
May 28 2017 00:19
josephprice sends brownie points to @benwebdev :sparkles: :thumbsup: :sparkles:
:cookie: 345 | @benwebdev |http://www.freecodecamp.com/benwebdev
SAMNANG KHUT
@samnangkhut
May 28 2017 00:20
guys help, what i am do wrong here
var count = 0;

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
john94
@lpy1994
May 28 2017 00:20
@JunJPang yeah, yours only applied for words, it need to be applied for anything including number
SAMNANG KHUT
@samnangkhut
May 28 2017 00:20

task : You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.

Example Output
"-3 Hold"
"5 Bet"

Hint
Do NOT reset count to 0 when value is 7, 8, or 9.

john94
@lpy1994
May 28 2017 00:20
@JunJPang /[^A-Za-z0-9]/g use this one
JunJPang
@JunJPang
May 28 2017 00:23
@lpy1994 I just did it, not working either.
john94
@lpy1994
May 28 2017 00:23
@JunJPang I know it won't lol, that is just first issue
JunJPang
@JunJPang
May 28 2017 00:24
@lpy1994 what is another issue?
Austin
@werewolfred
May 28 2017 00:24
hi everybody, when an error comes up and says Error: Out of stack space, what exactly does that mean?
Ravi Kishore Thella
@ravikishorethella
May 28 2017 00:24
@JunJPang use this /[\W_]/g
JunJPang
@JunJPang
May 28 2017 00:26
@ravikishorethella what else did I do wrong on my coding? I use yrs, still not working.
Stephen James
@sjames1958gm
May 28 2017 00:27
@samnangkhut Hole? or Hold - and you need a space " Bet"
@werewolfred You are likely calling a function from within the same function
Ravi Kishore Thella
@ravikishorethella
May 28 2017 00:28
@JunJPang see str.replace()
Stephen James
@sjames1958gm
May 28 2017 00:29
@JunJPang You don't save the string before the reverse. so you are comparing the reversed / cleaned string with the original
@JunJPang After the replace use a new variable for split reverse join
JunJPang
@JunJPang
May 28 2017 00:30
@sjames1958gm Thanks Stephen, Let me try it.
CamperBot
@camperbot
May 28 2017 00:30
junjpang sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7516 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 28 2017 00:36
@JunJPang :+1:
Rohan Saha
@simpleParadox
May 28 2017 00:39
Hey, what's up guys. Could anyone explain to me what is this cross-domain policy and what is this 'JSONP' all about. I have checked Stack Overflow but could not understand.
I know what JSON is used it to make the Random Quote Machine. But after working around with some jQuery, I stumbled upon JSONP and I am not able to understand it.
Thanks
Adam Bohannon
@abohannon
May 28 2017 00:40
So I entered this for the "Factorialize a Number" challenge and all the numbers return correctly, but it's not showing I completed the challenge. I imagine this code is ugly as hell, which could be why?
function factorialize(num) {
  for (var i = 1; i <= num; i++) {
    myArray.push(i);
  }
  myFactor = myArray.reduce(function(a, b){
    return a * b;
  });

  return myFactor;
}

var myArray = [1];
var myFactor = 0;

factorialize(20);
Manish Giri
@Manish-Giri
May 28 2017 00:40
@abohannon to begin with, make your variables local.
Tresean Adam
@adamtre9115
May 28 2017 00:40
Can anyone help out with this? I'm on the truncate string algorithm and I have all tests passing except if num is undefined
function truncateString(str, num){
    if (num === undefined){
        return string;
    } else if (num <= 3){
        var string = str.slice(0, num);
        string += "..."
        return string;
    } else {
        var string = str.slice(0, num -3);
        string += "..."
        return string;
    }
}
Manish Giri
@Manish-Giri
May 28 2017 00:40
myArray and myFactor
@abohannon
4sipita
@4sipita
May 28 2017 00:40
hello guys, the code below doesn't work..... why pls?
Adam Bohannon
@abohannon
May 28 2017 00:40
ok
4sipita
@4sipita
May 28 2017 00:41

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

for(var i = 0; i < arr.length; i++){
if(arr[i].length > arr[i+1].length){
result = arr[i].length;
}
else{
result = arr[i+1].length;
}
}
return result;
}

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

Ravi Kishore Thella
@ravikishorethella
May 28 2017 00:41
@4sipita your if loop logic is wrong
Manish Giri
@Manish-Giri
May 28 2017 00:42
@4sipita set result to 0 at the start, and then check length of each word against result's length
4sipita
@4sipita
May 28 2017 00:42
@ravikishorethella expatiate pls
Manish Giri
@Manish-Giri
May 28 2017 00:42
if it's greater, assign that length to result
@4sipita
Ravi Kishore Thella
@ravikishorethella
May 28 2017 00:43
create a var max to 0 and compare your arr[i].length to max, if that is greater then store that in max and repeat this
@4sipita create a var max to 0 and compare your arr[i].length to max, if that is greater then store that in max and repeat this
Adam Bohannon
@abohannon
May 28 2017 00:44
@Manish-Giri hmm i moved them inside the function but it's telling me it cant read the property of push
4sipita
@4sipita
May 28 2017 00:44
@Manish-Giri thanks man thanks thanks thanks
CamperBot
@camperbot
May 28 2017 00:44
4sipita sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5682 | @manish-giri |http://www.freecodecamp.com/manish-giri
Rohan Saha
@simpleParadox
May 28 2017 00:44
You can also set the initial value of result to the length of of the first word
Guderian Raborg
@hypercuber
May 28 2017 00:44
Hi, yall. I have a question. I know how to use js by itself like algorithms, arrays, etc but I am starting learning DOM and using API. I find it difficult because the code looks like spaghetti code just to do few things. I was wondering if I can skip that part of vanilla js and go to a framework like react. Is that okay to do? I have use p5js but it is not popular.
Rohan Saha
@simpleParadox
May 28 2017 00:44
and then run the loop from the second word to the end...comparing on the way
Manish Giri
@Manish-Giri
May 28 2017 00:44
@abohannon show code
Adam Bohannon
@abohannon
May 28 2017 00:45
@Manish-Giri
function factorialize(num) {
  for (var i = 1; i <= num; i++) {
    myArray.push(i);
  }
  myFactor = myArray.reduce(function(a, b){
    return a * b;
  });

  var myArray = [1];
  var myFactor = 0;

  return myFactor;
}


factorialize(20);
Manish Giri
@Manish-Giri
May 28 2017 00:45
move the declarations assignments to the top @abohannon
Guderian Raborg
@hypercuber
May 28 2017 00:45
I am looking into making things more simple.
Adam Bohannon
@abohannon
May 28 2017 00:46
@Manish-Giri that worked. Like this:
function factorialize(num) {
  var myArray = [1];
  var myFactor = 0;

  for (var i = 1; i <= num; i++) {
    myArray.push(i);
  }
  myFactor = myArray.reduce(function(a, b){
    return a * b;
  });

  return myFactor;
}


factorialize(20);
Brett Burtson
@bburtson
May 28 2017 00:46
@Manish-Giri Did you get it?
Manish Giri
@Manish-Giri
May 28 2017 00:46
@abohannon yeah
Brett Burtson
@bburtson
May 28 2017 00:46
Great
Adam Bohannon
@abohannon
May 28 2017 00:46
@Manish-Giri great thank you for the help
CamperBot
@camperbot
May 28 2017 00:46
abohannon sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
Brett Burtson
@bburtson
May 28 2017 00:46
Nice job!
CamperBot
@camperbot
May 28 2017 00:46
:star2: 5683 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
May 28 2017 00:46
@bburtson get what?
Brett Burtson
@bburtson
May 28 2017 00:47
@Manish-Giri did you see your hiccup in your "Truncate" challenge?
Manish Giri
@Manish-Giri
May 28 2017 00:47
@bburtson wrong person.
Brett Burtson
@bburtson
May 28 2017 00:48
goodness lol ... thanks
Manish Giri
@Manish-Giri
May 28 2017 00:48
:+1:
Amy Bedinghaus
@amyngb
May 28 2017 00:48
Hi all, I am on the Profile Lookup challenge, and I'm having trouble iterating through all of my for loop. Individually, each if statement returns the correct answer, but they don't iterate together. Any pointeres?

var answer;
for(var i = 0; i < contacts.length; i++){
if((firstName == contacts[i].firstName) && (contacts[i].hasOwnProperty(prop))){
answer = contacts[i][prop];
}

else if (firstName != contacts[i].firstName) {
answer = "No such contact";
}

else if (prop != contacts[i].prop) {
answer = "No such property";
}
return answer;
}

Ravi Kishore Thella
@ravikishorethella
May 28 2017 00:50
@amyngb (contacts[i].firstName === firstName
Manish Giri
@Manish-Giri
May 28 2017 00:50
@amyngb if you have 10 cards, and I ask you to look for the name "Sam"
if the first card is not "sam", would you say that the name doesn't exist at all in the 10 cards?
Amy Bedinghaus
@amyngb
May 28 2017 00:52
No. I think that I need to get my first if statement outside of the for loop, but then I don't know how to iterate through the rest of the objects in the array.
Manish Giri
@Manish-Giri
May 28 2017 00:52
not the first if
just this
answer = "No such contact";
and you don't need to check for this outside the loop
Amy Bedinghaus
@amyngb
May 28 2017 00:53
@ravikishorethella thanks
CamperBot
@camperbot
May 28 2017 00:53
amyngb sends brownie points to @ravikishorethella :sparkles: :thumbsup: :sparkles:
:cookie: 243 | @ravikishorethella |http://www.freecodecamp.com/ravikishorethella
Amy Bedinghaus
@amyngb
May 28 2017 00:53
@Manish-Giri Thank you. I'll experiment some mroe.
CamperBot
@camperbot
May 28 2017 00:53
amyngb sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5684 | @manish-giri |http://www.freecodecamp.com/manish-giri
Aakriti
@Aakriti94
May 28 2017 00:58

whats is wrong with this code snippet


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


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

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

i cant get right value for switchOfStuff("a")

Manish Giri
@Manish-Giri
May 28 2017 00:59
@Aakriti94 switch (answer) {
you should switch on val instead
Aakriti
@Aakriti94
May 28 2017 00:59
okay
@Manish-Giri thank u
CamperBot
@camperbot
May 28 2017 01:00
aakriti94 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5685 | @manish-giri |http://www.freecodecamp.com/manish-giri
Aakriti
@Aakriti94
May 28 2017 01:01
@Manish-Giri what an awesome profile u have
Manish Giri
@Manish-Giri
May 28 2017 01:01
lol
it's barely anything.
but ty @Aakriti94
CamperBot
@camperbot
May 28 2017 01:01
manish-giri sends brownie points to @aakriti94 :sparkles: :thumbsup: :sparkles:
:cookie: 201 | @aakriti94 |http://www.freecodecamp.com/aakriti94
Jean Saint-Hilaire
@Wisestjean
May 28 2017 01:13
@amyngb you can use the if and else to make it work perfectly.
Amy Bedinghaus
@amyngb
May 28 2017 01:15
Thank you @Wisestjean .
CamperBot
@camperbot
May 28 2017 01:15
:cookie: 107 | @wisestjean |http://www.freecodecamp.com/wisestjean
amyngb sends brownie points to @wisestjean :sparkles: :thumbsup: :sparkles:
Jean Saint-Hilaire
@Wisestjean
May 28 2017 01:16

@amyngb function lookUpProfile(firstName, prop){
// Only change code below this line
var jean = contacts.find(function(l){
return l.firstName === firstName;
});
if(!jean) {
return "No such contact"
} else {
if(prop in jean) {
return jean[prop];
} else {
return "No such property";
}
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Jean", "lastName");

Amy Bedinghaus
@amyngb
May 28 2017 01:20
I’m not sure I’ve learned the .find method yet. That’s cool!
Jean Saint-Hilaire
@Wisestjean
May 28 2017 01:20
Timothy Bui
@timothyqbui
May 28 2017 01:22
anyone free to help? im stuck...

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

myNoun = "dog";
myAdjective = "big";
myVerb = "ran";
myAdverb = "quickly";

var myStr = "The";

myStr = myNoun + myAdjective + myVerb + myAdverb;

// Your code above this line
return result;
}

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

Manish Giri
@Manish-Giri
May 28 2017 01:23
@timothyqbui delete this
myNoun = "dog";
myAdjective = "big";
myVerb = "ran";
myAdverb = "quickly";
var myStr = "The";
and add spaces in the final string
myStr = myNoun + myAdjective + myVerb + myAdverb;
cordovad88
@cordovad88
May 28 2017 01:24
Hi all... Banging my head against a wall on the profile lookup...

//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"]
    }
];


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

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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
CamperBot
@camperbot
May 28 2017 01:25
:bulb: to format code use backticks! ``` more info
cordovad88
@cordovad88
May 28 2017 01:26
Can someone please help?
Ravi Kishore Thella
@ravikishorethella
May 28 2017 01:26
@cordovad88 ??
cordovad88
@cordovad88
May 28 2017 01:26
sorry. was figuring out formatting
Ravi Kishore Thella
@ravikishorethella
May 28 2017 01:27
@cordovad88 check your first if loop condition
Timothy Bui
@timothyqbui
May 28 2017 01:27
hmm..didnt work
Baibhav Gautam
@baibhavx
May 28 2017 01:28
@timothyqbui can you send me the instruction?
Adam Bohannon
@abohannon
May 28 2017 01:28
Running into same issue as before. Console is coming back with correct values, but challenge won't say I've completed it (Palindrome challenge).
function palindrome(str) {
  newStr = str.toLowerCase().replace(/[\W_]+/g, '');
  reverseStr = newStr.split('').reverse().join('');
  if (newStr == reverseStr) {
    return "true";
  } else {
    return "false";
  }
}



palindrome("A man, a plan, a canal. Panama");
Manish Giri
@Manish-Giri
May 28 2017 01:28
if you have 10 cards, and I ask you to look for the name "Sam".. if the first card is not "sam", would you say that the name doesn't exist at all in the 10 cards?
@cordovad88
Baibhav Gautam
@baibhavx
May 28 2017 01:29
what section is that from @timothyqbui
Manish Giri
@Manish-Giri
May 28 2017 01:29
@abohannon "true" is a string
Timothy Bui
@timothyqbui
May 28 2017 01:29

@Manish-Giri We will now use our knowledge of strings to build a "Mad Libs" style word game we're calling "Word Blanks". You will create an (optionally humorous) "Fill in the Blanks" style sentence.

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.

We have provided a framework for testing your results with different words. The tests will run your function with several different inputs to make sure all of the provided words appear in the output, as well as your extra strings.

wordBlanks("","","","") should return a string.
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).

Manish Giri
@Manish-Giri
May 28 2017 01:29
true is boolean
cordovad88
@cordovad88
May 28 2017 01:29
@ravikishorethella @Manish-Giri so its not iterating through each? its just reporting a false after the first run?
Adam Bohannon
@abohannon
May 28 2017 01:29
@Manish-Giri thank you again - that worked. gahhh
CamperBot
@camperbot
May 28 2017 01:29
abohannon sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: abohannon already gave manish-giri points
Manish Giri
@Manish-Giri
May 28 2017 01:29
@cordovad88 yes
Ravi Kishore Thella
@ravikishorethella
May 28 2017 01:30
@cordovad88 yeah
cordovad88
@cordovad88
May 28 2017 01:31
@ravikishorethella @Manish-Giri what is preventing it from running the "if" again?
Manish Giri
@Manish-Giri
May 28 2017 01:31
@cordovad88 return "No such contact";
the return keyword.
Timothy Bui
@timothyqbui
May 28 2017 01:32
155, word blanks in javaschipt seciton
Manish Giri
@Manish-Giri
May 28 2017 01:32
it terminates the function..
cordovad88
@cordovad88
May 28 2017 01:32
oooooooooh
Manish Giri
@Manish-Giri
May 28 2017 01:32
@timothyqbui what's your question
I already told you what you need to do
Timothy Bui
@timothyqbui
May 28 2017 01:32
*basic java script
Csaba Balogh
@JasonCorp84
May 28 2017 01:32
good evening !
I am working on cipher text
cordovad88
@cordovad88
May 28 2017 01:33
@Manish-Giri Thank you so much. Will try and take it from there. Seriously. Thanks.
CamperBot
@camperbot
May 28 2017 01:33
cordovad88 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5687 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
May 28 2017 01:33
@cordovad88 :+1:
Timothy Bui
@timothyqbui
May 28 2017 01:33
@Manish-Giri yeah i deleted and put spacese..but didnt solve it
Manish Giri
@Manish-Giri
May 28 2017 01:33
@timothyqbui show the code
Baibhav Gautam
@baibhavx
May 28 2017 01:34

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

  // Your code above this line
  return result;
}
@timothyqbui should look something like this
Manish Giri
@Manish-Giri
May 28 2017 01:34
@baibhavx pls don't post answers.
Baibhav Gautam
@baibhavx
May 28 2017 01:35
well timothy has been stuck for a long time and sometimes it helps to see the solution and do it yourself
Timothy Bui
@timothyqbui
May 28 2017 01:35
thanks
Manish Giri
@Manish-Giri
May 28 2017 01:36
sometimes it helps to see the solution and do it yourself
sure
FlashHero
@FlashHero
May 28 2017 01:36
can someone help me on Roman Numeral Converter I don't even know how to get started
Baibhav Gautam
@baibhavx
May 28 2017 01:41
@FlashHero Thats a tricky one. I'd suggest start by solving for 1 - 10 first then build your way up
you can always refactor later to make it super pretty
Mohammed Boudad
@matrixersp
May 28 2017 01:41
A better way to put this?
function repeatStringNumTimes(str, num) {
  // repeat after me
  if(num > 0) {
    var str2 = "";
    for(var i = 0; i < num; i++) {
      str2 = str2 + str;
    }
    return str2;
  }
  return "";
}
repeatStringNumTimes("abc", 3);
Kyle Holm
@thekholm80
May 28 2017 01:41
any d3 experts here?
Manish Giri
@Manish-Giri
May 28 2017 01:42
@thekholm80 is one
Baibhav Gautam
@baibhavx
May 28 2017 01:42
@Tekkie just return str2 in the end no need to return from with in the if statement
Manish Giri
@Manish-Giri
May 28 2017 01:42
:smiling_imp:
Kyle Holm
@thekholm80
May 28 2017 01:42
i wish lol
just one more thing to figure out and I'm done with D3
Timothy Bui
@timothyqbui
May 28 2017 01:43
@baibhavx is the star symbol just a "non-word-char"
Kyle Holm
@thekholm80
May 28 2017 01:43
hopefully forever
Baibhav Gautam
@baibhavx
May 28 2017 01:43
Yes! they basically mean non alphabets
FlashHero
@FlashHero
May 28 2017 01:44
@baibhavx if i create an object and assign its corresponding character then it wouldn't work that's all i can think of right now i don't have any other ideas
Baibhav Gautam
@baibhavx
May 28 2017 01:45
@FlashHero Yes that is how I started, you will have to hard code some values in the beggining
Timothy Bui
@timothyqbui
May 28 2017 01:45
@baibhavx thanks a bunch!
CamperBot
@camperbot
May 28 2017 01:45
timothyqbui sends brownie points to @baibhavx :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @baibhavx |http://www.freecodecamp.com/baibhavx
FlashHero
@FlashHero
May 28 2017 01:47
@baibhavx well, thanks
CamperBot
@camperbot
May 28 2017 01:47
flashhero sends brownie points to @baibhavx :sparkles: :thumbsup: :sparkles:
:cookie: 309 | @baibhavx |http://www.freecodecamp.com/baibhavx
Baibhav Gautam
@baibhavx
May 28 2017 01:50
@FlashHero I am sure there are better ways to do it but I'd suggest writing smaller function for ranges of numbers and using that. For example, function for converting numbers between 1 and 99, then 99 to 999 then 999 to 9999. Then you can break a number such as 7543 to 7000 500 40 3 and find it
FlashHero
@FlashHero
May 28 2017 01:51
@baibhavx yes that's what i was thinking of but i don't know how to break numbers like that
Baibhav Gautam
@baibhavx
May 28 2017 01:53
One approach you can take is to convert the number to a string so number 7543 => stringNum '7543' now stringNum[0] = 7 , string[1] = 5 and so on.. use length of the string to find places value
Long Nguyen
@longnt80
May 28 2017 01:54
@FlashHero easiest way is to use the switch statement
Keon Samuel
@keonsam
May 28 2017 01:54
@alpox thanks for all the help bro.
CamperBot
@camperbot
May 28 2017 01:54
keonsam sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1086 | @alpox |http://www.freecodecamp.com/alpox
Baibhav Gautam
@baibhavx
May 28 2017 01:55
Another approach is to use modulus 7543 % 10 === 3 7543 / 10 === 754. use this mechanism to extract numbers and add 0's accordingly @FlashHero
FlashHero
@FlashHero
May 28 2017 01:57
@baibhavx ok thanks I'll try to solve it
CamperBot
@camperbot
May 28 2017 01:57
flashhero sends brownie points to @baibhavx :sparkles: :thumbsup: :sparkles:
:warning: flashhero already gave baibhavx points
FlashHero
@FlashHero
May 28 2017 01:57
@longnt80 thanks i sure will use switch statement
CamperBot
@camperbot
May 28 2017 01:57
flashhero sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @longnt80 |http://www.freecodecamp.com/longnt80
Austin
@werewolfred
May 28 2017 01:58
hi I need help I'm stuck on switch statements, it seems I cant get anything to proceed because I keep pulling up an error "Out of stack space", I don't know if I'm writing the program incorrectly or if I'm misreading the instructions
Kelechi Chinaka
@ke1echi
May 28 2017 01:59
hi guys, pls where can i test out my regex
Baibhav Gautam
@baibhavx
May 28 2017 02:00
@werewolfred can you please post your code
Austin
@werewolfred
May 28 2017 02:01
i don't actually know how to do that I'm sorry
Baibhav Gautam
@baibhavx
May 28 2017 02:03
ok copy paste your code into the chat box but surround it with ```
Kelechi Chinaka
@ke1echi
May 28 2017 02:03
hi guys, pls where can i test out my regex
Baibhav Gautam
@baibhavx
May 28 2017 02:04
try that one
not 100% sure what you are looking for
you can test it using JS too
Pete Givens
@petegivens
May 28 2017 02:09
@genacatharine type then Shift +Enter. Past your code then Shift+Enter and another
TaraBryn
@TaraBryn
May 28 2017 02:10

Hey all, just a quest: I had a problem, and now I know the resolution to it, but the logic doesn't make sense to more. In the following code, the for loop running through the elements in pageids[] is running before the json api call that's before it. Does anyone know why that is?

$("#search").keydown(function(event){

if(event.keyCode == 13){     

  var strQuery = $("#search").val().replace(/\s/g,"%20");

  var strUrl = "https://en.wikipedia.org/w/api.php?action=query&format=json&generator=search&gsrprop=snippet&list=search&prop=info&inprop=url&callback=?&srsearch=" + strQuery + "&gsrsearch=" + strQuery;

  var pageids = [];

  //console.log(strUrl);

  $.getJSON(strUrl,function(json){

    var arrPages = json.query.pages;
    var arrSearch = json.query.search;
    var html = "";

    //alert(JSON.stringify(arrPages));
    //console.log("test");
    //console.log(arrPages);
    //console.log(arrSearch[0].title);

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

      var title = arrSearch[i].title;
      var pageid = 0;
      var url = "";

      for (var key in arrPages){

        if (arrPages.hasOwnProperty(key)) {

          if (arrPages[key].title == title){

            pageid = arrPages[key].pageid;
            url = arrPages[key].fullurl;
            break;

          }

        };

      };

      if(pageid != 0){

        html += "<button id = '" + pageid + "' class = 'result-btn btn btn-block'><h3>" + title + "</h3><span id = '" + pageid + "-url' class = 'html-div'>" + url + "</span><p>" + arrSearch[i].snippet + "</p></button>";

        pageids.push(pageid);
        console.log(pageid);
        console.log(pageids.length);
        console.log(pageids[i]);

      };

    };

    $("#results").html(html);

    $("#content").animate({"margin-top":"0px","margin-bottom":"0px"});

  });

  console.log("final length: " + pageids.length);


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

      console.log(pageids[i]);

      $("#" + pageids[i]).animate({"margin-top":"20px"});

    };

};
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:17
my solution to a challenge is passing all of the conditions but the website is refusing to accept my answer
has this happened to anyone else
Ravi Kishore Thella
@ravikishorethella
May 28 2017 02:18
@f1ux1uxday yes it happened to me today
TaraBryn
@TaraBryn
May 28 2017 02:18
@f1ux1uxday try reloading freecodecamp?
Long Nguyen
@longnt80
May 28 2017 02:19
@TaraBryn you need to add your loop inside .done() call back of getJSON to make sure the api is loaded before running your loop
@TaraBryn see the part about The jqXHR Object
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:21
i've tried reloading it but without success
Ravi Kishore Thella
@ravikishorethella
May 28 2017 02:22
@f1ux1uxday what is the challenge?
TaraBryn
@TaraBryn
May 28 2017 02:22
@longnt80 yeah, I see that, thanks! I guess it's a good idea then to put any code that relies ont he results of the query call inside done()...
CamperBot
@camperbot
May 28 2017 02:22
tarabryn sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 309 | @longnt80 |http://www.freecodecamp.com/longnt80
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:22
the challenge is the roman numeral converter
Baibhav Gautam
@baibhavx
May 28 2017 02:24
can you post your code?
and what do you mean by passing all the tests but 'refusing' to accept your answer?
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:25
yeah, gimme a sec
Ravi Kishore Thella
@ravikishorethella
May 28 2017 02:25
@f1ux1uxday check your inbox
can anyone help me with this
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:26
i mean it says convertToRoman(2) should return "II"
my code returns II, but it still gives me the red X
Baibhav Gautam
@baibhavx
May 28 2017 02:26
thats interesting
post you code lets see whats going on
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:27
how do i post code correctly
Baibhav Gautam
@baibhavx
May 28 2017 02:27
sorround it with ```
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:28

'var romArr = [];

function convertToRoman(num) {

function checkAndPush(letter, remnant){
romArr.push(letter);
num -= remnant;
}

while (num - 1000 >= 0) {
checkAndPush('M', 1000);
}

if (num - 900 >= 0) {
checkAndPush('CM', 900);
}

if (num - 500 >= 0) {
checkAndPush('D', 500);
}

if (num - 400 >= 0) {
checkAndPush('CD', 400);
}

while (num - 100 >= 0) {
checkAndPush('C', 100);
}

if (num - 90 >= 0) {
checkAndPush('XC', 90);
}

if (num - 50 >= 0) {
checkAndPush('L', 50);
}

if (num - 40 >= 0) {
checkAndPush('XL', 40);
}

while (num - 10 >= 0) {
checkAndPush('X', 10);
}

if (num - 9 >= 0) {
checkAndPush('IX', 9);
}

if (num - 5 >= 0) {
checkAndPush('V', 5);
}

if (num - 4 >= 0) {
checkAndPush('IV', 4);
}

while (num - 1 >= 0) {
checkAndPush('I', 1);
}

romNum = romArr.join("");
return romNum.toString();
}

convertToRoman(2014);'

Baibhav Gautam
@baibhavx
May 28 2017 02:28
its the key before the number 1 on the keyboard
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:28
ha that didnt wor
k
Baibhav Gautam
@baibhavx
May 28 2017 02:28
lol
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:28

` var romArr = [];

function convertToRoman(num) {

function checkAndPush(letter, remnant){
romArr.push(letter);
num -= remnant;
}

while (num - 1000 >= 0) {
checkAndPush('M', 1000);
}

if (num - 900 >= 0) {
checkAndPush('CM', 900);
}

if (num - 500 >= 0) {
checkAndPush('D', 500);
}

if (num - 400 >= 0) {
checkAndPush('CD', 400);
}

while (num - 100 >= 0) {
checkAndPush('C', 100);
}

if (num - 90 >= 0) {
checkAndPush('XC', 90);
}

if (num - 50 >= 0) {
checkAndPush('L', 50);
}

if (num - 40 >= 0) {
checkAndPush('XL', 40);
}

while (num - 10 >= 0) {
checkAndPush('X', 10);
}

if (num - 9 >= 0) {
checkAndPush('IX', 9);
}

if (num - 5 >= 0) {
checkAndPush('V', 5);
}

if (num - 4 >= 0) {
checkAndPush('IV', 4);
}

while (num - 1 >= 0) {
checkAndPush('I', 1);
}

romNum = romArr.join("");
return romNum.toString();
}

convertToRoman(2014); `

Baibhav Gautam
@baibhavx
May 28 2017 02:28
no prob
you gotta use 3 ticks

```
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:28
gotcha
Baibhav Gautam
@baibhavx
May 28 2017 02:28
and ``` again
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:28
jesus, this just isn't my day

``` var romArr = [];

function convertToRoman(num) {

function checkAndPush(letter, remnant){
romArr.push(letter);
num -= remnant;
}

while (num - 1000 >= 0) {
checkAndPush('M', 1000);
}

if (num - 900 >= 0) {
checkAndPush('CM', 900);
}

if (num - 500 >= 0) {
checkAndPush('D', 500);
}

if (num - 400 >= 0) {
checkAndPush('CD', 400);
}

while (num - 100 >= 0) {
checkAndPush('C', 100);
}

if (num - 90 >= 0) {
checkAndPush('XC', 90);
}

if (num - 50 >= 0) {
checkAndPush('L', 50);
}

if (num - 40 >= 0) {
checkAndPush('XL', 40);
}

while (num - 10 >= 0) {
checkAndPush('X', 10);
}

if (num - 9 >= 0) {
checkAndPush('IX', 9);
}

if (num - 5 >= 0) {
checkAndPush('V', 5);
}

if (num - 4 >= 0) {
checkAndPush('IV', 4);
}

while (num - 1 >= 0) {
checkAndPush('I', 1);
}

romNum = romArr.join("");
return romNum.toString();
}

convertToRoman(2014); ```

WTF
Baibhav Gautam
@baibhavx
May 28 2017 02:30
haha
i know wtf
just post a link to the problem
copy paste it from the browser
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:31
its gonna be another eyesore
https://www.freecodecamp.com/challenges/roman-numeral-converter#?solution=var romArr %3D []%3B%0A%0Afunction convertToRoman(num) {%0A%0A function checkAndPush(letter%2C remnant){%0A romArr.push(letter)%3B%0A num -%3D remnant%3B%0A }%0A %0A while (num - 1000 >%3D 0) {%0A checkAndPush('M'%2C 1000)%3B%0A } %0A %0A if (num - 900 >%3D 0) {%0A checkAndPush('CM'%2C 900)%3B%0A }%0A %0A if (num - 500 >%3D 0) {%0A checkAndPush('D'%2C 500)%3B%0A }%0A %0A if (num - 400 >%3D 0) {%0A checkAndPush('CD'%2C 400)%3B%0A }%0A %0A while (num - 100 >%3D 0) {%0A checkAndPush('C'%2C 100)%3B%0A }%0A %0A if (num - 90 >%3D 0) {%0A checkAndPush('XC'%2C 90)%3B%0A }%0A %0A if (num - 50 >%3D 0) {%0A checkAndPush('L'%2C 50)%3B%0A }%0A %0A if (num - 40 >%3D 0) {%0A checkAndPush('XL'%2C 40)%3B%0A }%0A %0A while (num - 10 >%3D 0) {%0A checkAndPush('X'%2C 10)%3B%0A }%0A %0A if (num - 9 >%3D 0) {%0A checkAndPush('IX'%2C 9)%3B%0A }%0A %0A if (num - 5 >%3D 0) {%0A checkAndPush('V'%2C 5)%3B%0A }%0A %0A if (num - 4 >%3D 0) {%0A checkAndPush('IV'%2C 4)%3B%0A }%0A %0A while (num - 1 >%3D 0) {%0A checkAndPush('I'%2C 1)%3B%0A }%0A %0A romNum %3D romArr.join("")%3B%0A return romNum.toString()%3B %0A}%0A%0AconvertToRoman(68)%3B
put me out of my misery
Baibhav Gautam
@baibhavx
May 28 2017 02:32
lol
Cesar Fernandez
@Diamond713
May 28 2017 02:32
Is this "$("button").addClass("animated bounce");" for jquery?
Mohammed Boudad
@matrixersp
May 28 2017 02:32
@f1ux1uxday write between ticks Capture.PNG
Cesar Fernandez
@Diamond713
May 28 2017 02:32
Right?
Baibhav Gautam
@baibhavx
May 28 2017 02:33
@f1ux1uxday dude there is no code in your editor. It looks like your code was not producing the intended resilts
results, I would copy paste into atom and run it there so see what it prints
for convert(2)
Ravi Kishore Thella
@ravikishorethella
May 28 2017 02:34
@Diamond713 yes
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:35
there's definitely code in my editor
how do i run it in atom?
Baibhav Gautam
@baibhavx
May 28 2017 02:36
you can install a pugin called script
to run it
or install node to your machine and run it from the terminal
I almost always write and test my code in atom before copy/pasting to FCC
click on that link and lemme know if you're on there by typing something there
Name Name, Jr.
@f1ux1uxday
May 28 2017 02:40
atom isn't able to run the script
Baibhav Gautam
@baibhavx
May 28 2017 02:40
click the above link man
that a shared text editor
Aakriti
@Aakriti94
May 28 2017 02:46
what am i exactly missing?

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

  // Only change code below this line  

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

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

// Change this value to test
phoneticLookup("charlie");
Ogundele Olumide
@Lumexralph
May 28 2017 02:48
@Aakriti94 you need to use val parameter holding the respective property name to access the lookup object and assign the value to result
Manuel Pérez V.
@manuepeva
May 28 2017 02:50
Hello there I need some help with JavaScritp testing objects for properties
this is my code : function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty("checkProp"));
{return myObj[checkProp];}
return "Not Found" ; }
}
Ogundele Olumide
@Lumexralph
May 28 2017 02:51
@manuepeva you should check checkProp parameter not string as you did here myObj.hasOwnProperty("checkProp")
Baibhav Gautam
@baibhavx
May 28 2017 02:52
Yes! you can also check by checking for undefined.
```
var obj = { 'a': 1, 'b': 2 };
console.log(obj['c']); // =>  undefined
console.log(obj['a']);// => a
Kelechi Chinaka
@ke1echi
May 28 2017 02:54
:wave: @Lumexralph
Ogundele Olumide
@Lumexralph
May 28 2017 02:56
@kelechichinaka Bro! Good Morning
cumibulat
@cumibulat
May 28 2017 02:56
Thanks @renelis @abhisekp @Rafase282 for your help with Algorithm: Falsy Bouncer
CamperBot
@camperbot
May 28 2017 02:56
cumibulat sends brownie points to @renelis and @abhisekp and @rafase282 :sparkles: :thumbsup: :sparkles:
:star2: 3348 | @abhisekp |http://www.freecodecamp.com/abhisekp
:cookie: 411 | @renelis |http://www.freecodecamp.com/renelis
:star2: 1556 | @rafase282 |http://www.freecodecamp.com/rafase282
Joseph
@revisualize
May 28 2017 02:56
image.png
Ogundele Olumide
@Lumexralph
May 28 2017 02:56
@xyedabz you can post your code here
Kelechi Chinaka
@ke1echi
May 28 2017 02:57
morning bro @Lumexralph
Manish Giri
@Manish-Giri
May 28 2017 02:57
@Lumexralph :wave:
Kelechi Chinaka
@ke1echi
May 28 2017 02:57
:wave: @Manish-Giri
Manish Giri
@Manish-Giri
May 28 2017 02:58
@kelechichinaka :wave:
Ogundele Olumide
@Lumexralph
May 28 2017 02:58
@Manish-Giri Good Morning :smile:
Kelechi Chinaka
@ke1echi
May 28 2017 02:58
i have an error msg i dont understand..take a look @Lumexralph @Manish-Giri
var repeatIt = function (str, n) {
  return str.repeat(n);
}
passes all test except 1
JustCodeItBen
@JustCodeItBen
May 28 2017 02:59

https://beta.freecodecamp.com/en/challenges/basic-javascript/divide-one-decimal-by-another-with-javascript

var quotient = 4.4 / 2.0;
// Error: The quotient variable should only be assigned once

Not sure what I'm doing wrong for the challenge not to pass.

Ogundele Olumide
@Lumexralph
May 28 2017 02:59
@kelechichinaka which test?
Kelechi Chinaka
@ke1echi
May 28 2017 02:59
TypeError: str.repeat is not a function
Manish Giri
@Manish-Giri
May 28 2017 03:00
@kelechichinaka how's it being called?
Ogundele Olumide
@Lumexralph
May 28 2017 03:00
@kelechichinaka for what test?
Baibhav Gautam
@baibhavx
May 28 2017 03:00
@JustCodeItBen That should pass its 4.4 / 2.0
Kelechi Chinaka
@ke1echi
May 28 2017 03:00
tryna repeat a string n times
tryna repeat a string n times
Ogundele Olumide
@Lumexralph
May 28 2017 03:01
@kelechichinaka what test is your function failing?
Baibhav Gautam
@baibhavx
May 28 2017 03:01
repeat is not a string function thats why
unless you write your own implementation of repeat
Wisdom Peters
@blackcytographer
May 28 2017 03:02
please i dont know what seems to be wrong with my code i need help!!!!!!!!!!!!!!!!!!!!!var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
},
// Add record here
{
"artist": "Wisdom",
"title": "sucker",
"release_year": 1988,
"format": [
"CS",
"8T",
"LP"]
}
];
Manish Giri
@Manish-Giri
May 28 2017 03:02
@baibhavx repeat is not a string function?
JustCodeItBen
@JustCodeItBen
May 28 2017 03:03
@baibhavx I figured it should, but the challenge thinks otherwise. All other tests pass.
Baibhav Gautam
@baibhavx
May 28 2017 03:03
@Manish-Giri Cool thanks good to know I wasnt aware of that
CamperBot
@camperbot
May 28 2017 03:03
baibhavx sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5689 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
May 28 2017 03:03
Screenshot 2017-05-27 23.03.07.png
np
Kelechi Chinaka
@ke1echi
May 28 2017 03:04
pls take a look @Manish-Giri @Lumexralph https://www.codewars.com/kata/repeatit/train/javascript
Ravi Kishore Thella
@ravikishorethella
May 28 2017 03:04
@blackcytographer that should be "formats" not "format"
Manish Giri
@Manish-Giri
May 28 2017 03:04

@kelechichinaka

If anything other than a string is passed in you should return "Not a string"

maybe because of this
you don't have the code to handle non-string values
Wisdom Peters
@blackcytographer
May 28 2017 03:05
@ravikishorethella OHHHHHH THANKS SO SO SIMPLE
CamperBot
@camperbot
May 28 2017 03:05
blackcytographer sends brownie points to @ravikishorethella :sparkles: :thumbsup: :sparkles:
:cookie: 256 | @ravikishorethella |http://www.freecodecamp.com/ravikishorethella
Ravi Kishore Thella
@ravikishorethella
May 28 2017 03:05
@blackcytographer you are welcome
Kelechi Chinaka
@ke1echi
May 28 2017 03:07
that check further breaks the code @Manish-Giri
Ogundele Olumide
@Lumexralph
May 28 2017 03:08
@kelechichinaka you can add a ternary operator
Manish Giri
@Manish-Giri
May 28 2017 03:09
@kelechichinaka I tried it just now
worked for me
Ogundele Olumide
@Lumexralph
May 28 2017 03:09
@kelechichinaka to check for non-string
Kelechi Chinaka
@ke1echi
May 28 2017 03:10
 if (str !== String) {
    return "Not a string";
  }
this is check correct @Manish-Giri @Lumexralph
Manish Giri
@Manish-Giri
May 28 2017 03:10
"string"
return typeof str !== "string" ? ...
Ogundele Olumide
@Lumexralph
May 28 2017 03:11
@kelechichinaka typeof as @Manish-Giri showed will save you here
Manish Giri
@Manish-Giri
May 28 2017 03:11
ooh I didn't even notice he was missing typeof
yeah this will fail
if (str !== String)
@Lumexralph :bow:
:smiling_imp:
Kelechi Chinaka
@ke1echi
May 28 2017 03:12
oh typeof
Ogundele Olumide
@Lumexralph
May 28 2017 03:13
@Manish-Giri gggggggggm :smiling_imp:
@Manish-Giri how's your thesis coming up?
Manish Giri
@Manish-Giri
May 28 2017 03:14
@Lumexralph ugh it's killing me
Ogundele Olumide
@Lumexralph
May 28 2017 03:15
@Manish-Giri :joy: what's it about?
Manish Giri
@Manish-Giri
May 28 2017 03:15
@Lumexralph https://neo4j.com/
this DB
like Mongo, No SQL
Long Nguyen
@longnt80
May 28 2017 03:18
:moneybag: for anyone can break my calculator:
https://codepen.io/longnt80/full/Kmeoaq/
Ogundele Olumide
@Lumexralph
May 28 2017 03:19
@Manish-Giri hmm... cool
Manish Giri
@Manish-Giri
May 28 2017 03:20
@longnt80 I broke it already
9-6
x2
shows -3
Long Nguyen
@longnt80
May 28 2017 03:22
@Manish-Giri no, -3 is correct
multiply before subtract
@Manish-Giri sorry, no :moneybag: for you, yet
Baibhav Gautam
@baibhavx
May 28 2017 03:22
@longnt80 good job linking to "you cant divide by 0" ;)
Manish Giri
@Manish-Giri
May 28 2017 03:22
@longnt80 really?
open up the calculator in your computer
and try it out
Long Nguyen
@longnt80
May 28 2017 03:23
@baibhavx thanks, I just leanr about it so I want to share
CamperBot
@camperbot
May 28 2017 03:23
longnt80 sends brownie points to @baibhavx :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @baibhavx |http://www.freecodecamp.com/baibhavx
Lionel
@Lionl-N
May 28 2017 03:23
Hello campers !
Long Nguyen
@longnt80
May 28 2017 03:23
@Manish-Giri it's math basic
Manish Giri
@Manish-Giri
May 28 2017 03:23
nope
Baibhav Gautam
@baibhavx
May 28 2017 03:23
yeah @Manish-Giri Mac calculater results in -3 too
Long Nguyen
@longnt80
May 28 2017 03:24
@Manish-Giri if you chain it up, then it should do multiply first
otherwise, you have to solve 9-6 first
Manish Giri
@Manish-Giri
May 28 2017 03:24
I'm not talking about chaining
first do 9 -6
then hit x
then do 2
Baibhav Gautam
@baibhavx
May 28 2017 03:25
did you try it on your computer yet?
Long Nguyen
@longnt80
May 28 2017 03:25
@Manish-Giri I got 6
Manish Giri
@Manish-Giri
May 28 2017 03:26
Screenshot 2017-05-27 23.26.06.png
Lionel
@Lionl-N
May 28 2017 03:26
Can someone tell me with my code does not work ? No matter what I input it always return 1. The var product is not multiplied at all

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++){
       console.log(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]]);
Long Nguyen
@longnt80
May 28 2017 03:26
@Manish-Giri you're chaining it right there
Manish Giri
@Manish-Giri
May 28 2017 03:26
dude
I'm not
your expressions show up that way
Long Nguyen
@longnt80
May 28 2017 03:27
@Manish-Giri 9-6x2 should be -3, it's correct
Baibhav Gautam
@baibhavx
May 28 2017 03:27
@Manish-Giri enter the same thing in the mac calculator and you get the same result
I second that @longnt80
@Lionl-N because you are never updating product
you are only printing inside the loop
Long Nguyen
@longnt80
May 28 2017 03:28
@baibhavx my PC calculator doesn't let me do chaining
Baibhav Gautam
@baibhavx
May 28 2017 03:30
I see are you on windows? I did it in my mac and iphone and it produced -3
Phuc Hoang
@spideyinf
May 28 2017 03:30
Hmm, I stuck in this, what did I misunderstand about arguments:

function destroyer(arr) {

  // Remove all the values

   return arr.filter(function(value) {
    for (var i = 0; i < arguments.length; i ++) {
   if (value !== arguments[i]) {
      return value;
     } //end of if
  }   //end of for
  }); //end of function(value)
}     //end of fuction destroyer(arr)


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
// --> Nothing has been changed
Long Nguyen
@longnt80
May 28 2017 03:30
@Manish-Giri @baibhavx
in my PC calculator, it doesn't let user do chaining
so if you type 9-6 then hit * to chain, it will calcualte 9-6 first
Ogundele Olumide
@Lumexralph
May 28 2017 03:30
@Lionl-N use product to keep track of the multiplication of the elements not logging it to the console
Manish Giri
@Manish-Giri
May 28 2017 03:31
ab.png
@longnt80 as I was saying earlier
Long Nguyen
@longnt80
May 28 2017 03:31
@Manish-Giri but that's not the case in my calculator because mine can chain
Manish Giri
@Manish-Giri
May 28 2017 03:31
if you hit an operator, like + or -
it should evaluate the expression until then
then continue onwards
Baibhav Gautam
@baibhavx
May 28 2017 03:32
@Manish-Giri do you own a mac or an iphone?
Long Nguyen
@longnt80
May 28 2017 03:32
@Manish-Giri
9-6x2 should be -3
it's math basic
Baibhav Gautam
@baibhavx
May 28 2017 03:32
its calculator specific and I think its cool to take order of operation into account
Long Nguyen
@longnt80
May 28 2017 03:32
@Manish-Giri in my calculator, if you do 9-6 then click = then x then 2, you will get 6
Phuc Hoang
@spideyinf
May 28 2017 03:34
Please take a look and give me pieces of advice
Baibhav Gautam
@baibhavx
May 28 2017 03:36
@spideyinf you need to accept arbitrary number of arguments in the function
ok i see that you are doing that
but using the filter like that is not gonna work
Ogundele Olumide
@Lumexralph
May 28 2017 03:37
@spideyinf using indexOf will be of good help here
@spideyinf remember your filter method callback should return true or false
Baibhav Gautam
@baibhavx
May 28 2017 03:38
yes! when you are returning from filter, you want to return a boolean
Long Nguyen
@longnt80
May 28 2017 03:38
@Manish-Giri thank you anyway for testing it!
CamperBot
@camperbot
May 28 2017 03:38
longnt80 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5690 | @manish-giri |http://www.freecodecamp.com/manish-giri
Baibhav Gautam
@baibhavx
May 28 2017 03:39
when you return a number, all numbers except 0 will result in true
Kelechi Chinaka
@ke1echi
May 28 2017 03:47
am tryna learn regex @Lumexralph
Frank McCroy
@fmccroy
May 28 2017 03:47
Can someone help with my regular expression? I need to remove all non-alphanumeric characters, and turn to lowercase, but when I view the output the only thing that works is the lowercase part.

function palindrome(str) {
// Good luck!
var newStr;
console.log("Before stripping: " + str);
newStr = str.replace('/\S\D\w/gi');
console.log("After stripping " + newStr);
lowerStr = newStr.toLowerCase();
console.log("After lowercasing: "+ lowerStr);
if (lowerStr === newStr) return true;
else return false;
}

palindrome("eye");

Kelechi Chinaka
@ke1echi
May 28 2017 03:48
what do u think @Lumexralph
Frank McCroy
@fmccroy
May 28 2017 03:49
I haven’t put in the reverse part yet, the comparison at the end is worthless right now.
Ogundele Olumide
@Lumexralph
May 28 2017 03:52
@kelechichinaka you have to learn that beast, I'm just okay in it, need to study more too
Kelechi Chinaka
@ke1echi
May 28 2017 03:53
beast :smile:
Ogundele Olumide
@Lumexralph
May 28 2017 03:54
@fmccroy you can do that replacing the matched character with empty string newStr = str.replace('/\W/gi', "") \W takes non-alphanumeric characters
@kelechichinaka yes, beast
@kelechichinaka I already have a plum account for the Andela application
@kelechichinaka so can't retake the test
@kelechichinaka only got a message saying congratulations, if you're applying to an organization your result has been submitted, what do you think?
Frank McCroy
@fmccroy
May 28 2017 03:58
@Lumexralph I tried changing it to newStr = str.replace('/\W/gi', “") but it still didn’t change anything.
Ogundele Olumide
@Lumexralph
May 28 2017 03:58
@fmccroy ""
Frank McCroy
@fmccroy
May 28 2017 04:00
hmm.. it swapped the quotes when I pasted here. The editor shows “” ?
straight up and down quotes
Kelechi Chinaka
@ke1echi
May 28 2017 04:00
yes..that plum test would be submitted to Andela @Lumexralph
Ogundele Olumide
@Lumexralph
May 28 2017 04:00
@fmccroy don't make your regEXp a string it's an object just
newStr = str.replace(/\W/gi, "")
@kelechichinaka with the previous profile I had ? without retaking the test?
Kelechi Chinaka
@ke1echi
May 28 2017 04:02
yes with the previous profile
Ogundele Olumide
@Lumexralph
May 28 2017 04:02
@kelechichinaka hmmm, already sent them a mail.... thanks bro
CamperBot
@camperbot
May 28 2017 04:02
lumexralph sends brownie points to @kelechichinaka :sparkles: :thumbsup: :sparkles:
:cookie: 281 | @kelechichinaka |http://www.freecodecamp.com/kelechichinaka
Kelechi Chinaka
@ke1echi
May 28 2017 04:02
but if u r not satisfied wit that u could get a new one and redo the test @Lumexralph
Ogundele Olumide
@Lumexralph
May 28 2017 04:02
@kelechichinaka how?
@kelechichinaka a new email?
Kelechi Chinaka
@ke1echi
May 28 2017 04:03
yes @Lumexralph
Ogundele Olumide
@Lumexralph
May 28 2017 04:03
@kelechichinaka means I have to register with Andela using the new email too
Frank McCroy
@fmccroy
May 28 2017 04:04
@Lumexralph Getting rid of the quotes around the expression made a HUGE difference! Thanks! Do I need to remove underscores as well?
CamperBot
@camperbot
May 28 2017 04:04
fmccroy sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1824 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
May 28 2017 04:04
@fmccroy check your tests
Kelechi Chinaka
@ke1echi
May 28 2017 04:04
i think so
Ogundele Olumide
@Lumexralph
May 28 2017 04:04
i think so
Kelechi Chinaka
@ke1echi
May 28 2017 04:05
i think u should just let the submitted one except if u r ready for another @Lumexralph
Frank McCroy
@fmccroy
May 28 2017 04:06
@Lumexralph _eye is supposed to return true as a palindrome, so it looks like it. Any ideas on which regex gets rid of that?
Ogundele Olumide
@Lumexralph
May 28 2017 04:06
@kelechichinaka and I'm not :smile:
@fmccroy then you have to remove underscores too
Kelechi Chinaka
@ke1echi
May 28 2017 04:06
lol @Lumexralph
i would be happy to join by jan :smile: @Lumexralph
Ogundele Olumide
@Lumexralph
May 28 2017 04:11
@fmccroy /[\W\_]/g should
Nazar Maksymchuk
@MANTENN
May 28 2017 04:11
Hit rock bottom - don't feel like doing these algorithms.
Ogundele Olumide
@Lumexralph
May 28 2017 04:11
@kelechichinaka and hopefully, will be there to accept you :smile:
@MANTENN your choice :wink:
Nazar Maksymchuk
@MANTENN
May 28 2017 04:12
@Lumexralph then ill want to do it next week lol
Ogundele Olumide
@Lumexralph
May 28 2017 04:12
@kelechichinaka what do they expect me to have known prior to coming
@MANTENN that's not a bad plan
Nazar Maksymchuk
@MANTENN
May 28 2017 04:13
@Lumexralph these algorithm challenges are really challenging -
Ogundele Olumide
@Lumexralph
May 28 2017 04:14
@MANTENN just take your time out with it, break the problem solution down into steps a pseudocode, then create it using JS language
Kelechi Chinaka
@ke1echi
May 28 2017 04:14
code :smile: @Lumexralph
Ogundele Olumide
@Lumexralph
May 28 2017 04:15
@kelechichinaka that's too generic
Kelechi Chinaka
@ke1echi
May 28 2017 04:16
basic programming concepts @Lumexralph
Frank McCroy
@fmccroy
May 28 2017 04:17
@Lumexralph hmm../[\W]/g worked for me, but I was trying /\W[] which ended up not working. I thought only the underscore would need to be in the square brackets. :(
and FCC thinks I’m using HTML code and screwed up what I was trying to type
Ogundele Olumide
@Lumexralph
May 28 2017 04:18
@fmccroy :smile:
John McLaurin
@JohnnyArenal
May 28 2017 04:20
how do I assign the value 7 to variable a and assign the contents of a to variable b???????

// Setup
var a;
var b = 2;

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

Ogundele Olumide
@Lumexralph
May 28 2017 04:22

@JohnnyArenal

var a; 7;
var b = var a;

assign 7 to a without var cos it's already declared above, then asign a to b which is also created above

John McLaurin
@JohnnyArenal
May 28 2017 04:24
so it would look like
a; 7;
a = b ?
Tatwamsiddha
@Tatwamsiddha-Nanda
May 28 2017 04:25
need help on challenge 167
i couldnt satisfy the first condition
Ogundele Olumide
@Lumexralph
May 28 2017 04:26
@JohnnyArenal assign 7 to a, using the assignment operator, then it has a right - left association, what's on the right is assigned to left, assign a to b
Tatwamsiddha
@Tatwamsiddha-Nanda
May 28 2017 04:26
nextInLine([], 1) should return 1
John McLaurin
@JohnnyArenal
May 28 2017 04:26

// Setup
var a;
var b = 2;

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

Manish Giri
@Manish-Giri
May 28 2017 04:26
@Tatwamsiddha-Nanda code?
John McLaurin
@JohnnyArenal
May 28 2017 04:26
is that right?
Ogundele Olumide
@Lumexralph
May 28 2017 04:26
@Tatwamsiddha-Nanda you should push before shift
Tatwamsiddha
@Tatwamsiddha-Nanda
May 28 2017 04:26

function nextInLine(arr, item) {
// Your code here
var k=arr[0];
arr[arr.length-1]=item;
if(arr.length>1)
{
arr[0]=0;
}
if(arr.lenght===0) return item;
return k; // 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));

Ogundele Olumide
@Lumexralph
May 28 2017 04:26
@JohnnyArenal i think so
Manish Giri
@Manish-Giri
May 28 2017 04:27
that
looks complicated
John McLaurin
@JohnnyArenal
May 28 2017 04:27
okay, thanks for your help ogundele
Ogundele Olumide
@Lumexralph
May 28 2017 04:27
@Tatwamsiddha-Nanda you're to use 2 array methods, push, shift
@Manish-Giri very
Manish Giri
@Manish-Giri
May 28 2017 04:27
lol
Tatwamsiddha
@Tatwamsiddha-Nanda
May 28 2017 04:27
noob code i know @Manish-Giri
k
Ogundele Olumide
@Lumexralph
May 28 2017 04:28
@Tatwamsiddha-Nanda you need to do 2 things
Tatwamsiddha
@Tatwamsiddha-Nanda
May 28 2017 04:29
i got it. thanks @Lumexralph
CamperBot
@camperbot
May 28 2017 04:29
tatwamsiddha-nanda sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1825 | @lumexralph |http://www.freecodecamp.com/lumexralph
Kelechi Chinaka
@ke1echi
May 28 2017 04:29
are there any playgrounds to test and see my regex
Ogundele Olumide
@Lumexralph
May 28 2017 04:29
@Tatwamsiddha-Nanda you need to add item to the end of arr holding the array you need to use push method for that, then you need to remove the first element which you have to return with shift
@kelechichinaka sure
Manish Giri
@Manish-Giri
May 28 2017 04:29
@kelechichinaka regexr
Ogundele Olumide
@Lumexralph
May 28 2017 04:30
@Tatwamsiddha-Nanda :+1:
Nick Gray
@nicholasnbg
May 28 2017 04:31
Kelechi Chinaka
@ke1echi
May 28 2017 04:31
:+1: @Manish-Giri @Lumexralph
Nick Gray
@nicholasnbg
May 28 2017 04:34

in the example it gives
const profileUpdate = ({ name, age, nationality, location }) => { /* do something with these fields */ }

Where is pointing to the object that contains the properties name, age etc?

Moisés Man
@moigithub
May 28 2017 04:35
es6 destructuring
Nick Gray
@nicholasnbg
May 28 2017 04:37
So the initial code that it asks us to change is:
const half = (stats) => ((stats.max + stats.min) / 2.0);
Here I can clearly see it passes in the stats object as an arguement.
In the example using profile update above, where would I point to the stats object though
Moisés Man
@moigithub
May 28 2017 04:38
half is a function.. which accept 1 argument stats
this stats have 2 properties.. max and min
soo.. stats = {max: 134, min: 44}; <-- an object
then u can call the function like
half(stats);
or directly without any extra variable half({max: 134, min: 44})
Nasridean
@Nasridean
May 28 2017 04:39

Hello, can anyone explain me this code, please?


function titleCase(str) {
  return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});  

}

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

What does (txt) do there? What is it referred to?

Joseph
@revisualize
May 28 2017 04:40
@Nasridean It is a parameter
Ogundele Olumide
@Lumexralph
May 28 2017 04:40
@Nasridean it's the parameter for the replace method callback
Joseph
@revisualize
May 28 2017 04:40
@Nasridean @Nasridean
function(txt){
      return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
}
Nasridean
@Nasridean
May 28 2017 04:43
@revisualize but how does it refer to the words?
And this function doesn't work alone.
Joseph
@revisualize
May 28 2017 04:43
@Nasridean So, the replace method has some regex.
Each value that the regex determines gets passed to the function.
An-mode
@an-mode
May 28 2017 04:44
hi I am new to JS was trying to work with return sequences for the following output:
FirstLine
\SecondLine\
ThirdLine
Nick Gray
@nicholasnbg
May 28 2017 04:44

@moigithub ok, so you would be passing min and max as arguments everytime you called the half function, instead of passing an object, yes?

is that not the same as just defining half as
const half = function(a,b){ (a+b)/2; };

An-mode
@an-mode
May 28 2017 04:44
why do I need a carriage return for the ThirdLine output?
wont /n do?
Ogundele Olumide
@Lumexralph
May 28 2017 04:45
@an-mode FirstLinenewline backslashSecondLinebackslash carriage-returnThirdLine
Joseph
@revisualize
May 28 2017 04:45
@an-mode You have to assign 'FirstLine newline backslash SecondLine backslash carriage-return ThirdLine' to the variable myStr.
But, You have to replace the escape words with the proper escape sequences. (And per the instructions: remove all spaces.)
How do you escape a newline?
How do you escape a backslash?
How do you escape a carriage-return?
@an-mode newline and carriage-return are different values.
In modern web browsers.. They basically do the same thing.
Nasridean
@Nasridean
May 28 2017 04:47
@revisualize Hmm, now it made some sense for me.
@revisualize @Lumexralph Thank you both!
CamperBot
@camperbot
May 28 2017 04:47
nasridean sends brownie points to @revisualize and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1826 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 4030 | @revisualize |http://www.freecodecamp.com/revisualize
Ogundele Olumide
@Lumexralph
May 28 2017 04:47
@Nasridean :+1:
Dave Reichert
@davidreichert
May 28 2017 04:48
Working on Return Early Pattern for Functions. Totally stuck
Ogundele Olumide
@Lumexralph
May 28 2017 04:48
@davidreichert what have you tried?
Dave Reichert
@davidreichert
May 28 2017 04:50

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

// 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);

Manish Giri
@Manish-Giri
May 28 2017 04:50
@davidreichert you need an if
Dave Reichert
@davidreichert
May 28 2017 04:50
ok...
Ogundele Olumide
@Lumexralph
May 28 2017 04:50
@davidreichert you need conditional statement to check that
Frank McCroy
@fmccroy
May 28 2017 04:50
@davidreichert and the return statement
"if a or b are less than 0 the function will immediately exit with a value of undefined."
Nick Gray
@nicholasnbg
May 28 2017 04:52
@moigithub ok so tell me if i've got this right:
const half = ({max : a, min = b}) => ((a + b) / 2.0);
Dave Reichert
@davidreichert
May 28 2017 04:53

// Setup
function abTest(a, b) {
// Only change code below this line
if (a < 0) {
return "undefined";
} else if (b < 0) {
return "undefined";
} else
// 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);

so i know that's not right...
because of the part about the "undefined" not being a string
Ogundele Olumide
@Lumexralph
May 28 2017 04:53
@davidreichert undefined not string and you can combine your if statements into 1
Frank McCroy
@fmccroy
May 28 2017 04:53
Get rid of the final else that doesn’t do anything
Dave Reichert
@davidreichert
May 28 2017 04:54
@fmccroy got that now
but WHAT is undefined? a<0 is just a negative number. NOT undefined. I don't get it
Frank McCroy
@fmccroy
May 28 2017 04:55
@davidreichert and take the quotes off of “undefined” like @Lumexralph mentioned above. :)
Dave Reichert
@davidreichert
May 28 2017 04:55
no way
THAT was it?!
Manish Giri
@Manish-Giri
May 28 2017 04:55
well yeah
it's just js
no vodoo!
Dave Reichert
@davidreichert
May 28 2017 04:56
YES voodoo. ;-)
Ogundele Olumide
@Lumexralph
May 28 2017 04:56
@Manish-Giri maybe there's :smile:
Frank McCroy
@fmccroy
May 28 2017 04:56
Quotes and brackets have been killing me all night long, sooner or later I will learn the rules.
Dave Reichert
@davidreichert
May 28 2017 04:58
thanks @fmccroy @Manish-Giri @Lumexralph
CamperBot
@camperbot
May 28 2017 04:58
davidreichert sends brownie points to @fmccroy and @manish-giri and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 317 | @fmccroy |http://www.freecodecamp.com/fmccroy
:star2: 1827 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 5691 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
May 28 2017 04:59
:+1:
An-mode
@an-mode
May 28 2017 05:09
@revisualize Thanks for the input.. I am clear about the syntax but not the functionality. to me it seemed that to print the third linke all I had to do was introduce a \n before printing it. However, the program expects a \r.
CamperBot
@camperbot
May 28 2017 05:09
an-mode sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4032 | @revisualize |http://www.freecodecamp.com/revisualize
Lionel
@Lionl-N
May 28 2017 05:19
@baibhavx I finally got it. Thanks for your help !
CamperBot
@camperbot
May 28 2017 05:19
lionl-n sends brownie points to @baibhavx :sparkles: :thumbsup: :sparkles:
:cookie: 311 | @baibhavx |http://www.freecodecamp.com/baibhavx
Dave Reichert
@davidreichert
May 28 2017 05:21
need help with counting cards

var count = 0;

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

// Only change code above this line
}

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

Ogundele Olumide
@Lumexralph
May 28 2017 05:23
@davidreichert your switch statement cases should increment or decrement count where applicable not return
Nick Gray
@nicholasnbg
May 28 2017 05:24
also, on line count = count + cc,
Should cc not have (card) as an argument?
Ogundele Olumide
@Lumexralph
May 28 2017 05:24
@davidreichert then you check if count is greater than 0 or not then you return count + string (" Bet" or " Hold")
Adam Bohannon
@abohannon
May 28 2017 05:24
Can someone explain why this isn't returning anything? I'm attempting to find the longest word in a string. My thinking is to split the string into an array, then sort the array from smallest to largest, then popping the largest word off the end, applying .length, and return that number. However, my sort doesn't seem to be working, but the syntax is correct?
function findLongestWord(str) {
  var myArray = str.split(' ');
  myArray.sort(function(a, b){
    return a - b;
  });


}

findLongestWord("The quick brown fox jumped over the lazy dog");
Ogundele Olumide
@Lumexralph
May 28 2017 05:25
@abohannon cos your function is not returning anything
Aakriti
@Aakriti94
May 28 2017 05:25
do we get streak if u do the same challenges again?
Ogundele Olumide
@Lumexralph
May 28 2017 05:25
@abohannon you only used callback for the sort method
@Aakriti94 streak is per day you're active without pause
Nick Gray
@nicholasnbg
May 28 2017 05:26
@abohannon yeah, your function sorts the array then does nothing else afterwards
Dave Reichert
@davidreichert
May 28 2017 05:26
@abohannon how did you share your code like that?
Ogundele Olumide
@Lumexralph
May 28 2017 05:26
@davidreichert '''
CamperBot
@camperbot
May 28 2017 05:26
:bulb: to format code use backticks! ``` more info
Ogundele Olumide
@Lumexralph
May 28 2017 05:26
@davidreichert click on the more info link
Adam Bohannon
@abohannon
May 28 2017 05:26
@davidreichert do ```
then paste
then ``` again
Nick Gray
@nicholasnbg
May 28 2017 05:27
@davidreichert @Lumexralph back ticks, not speech marks
Dave Reichert
@davidreichert
May 28 2017 05:27
var count = 0;

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


  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
gnarly! but i'm still messed up
@abohannon thanks
CamperBot
@camperbot
May 28 2017 05:29
davidreichert sends brownie points to @abohannon :sparkles: :thumbsup: :sparkles:
:cookie: 242 | @abohannon |http://www.freecodecamp.com/abohannon
Dave Reichert
@davidreichert
May 28 2017 05:29
@nicholasnbg thanks
I'm still not getting the Counting Cards
Adam Bohannon
@abohannon
May 28 2017 05:29
@Lumexralph so this is what I tried, but the array is still in the same order
function findLongestWord(str) {
  var myArray = str.split(' ');
  var sortedArray = myArray.sort(function(a, b){
    return a - b;
  });
 return sortedArray;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Ogundele Olumide
@Lumexralph
May 28 2017 05:30
@abohannon you want arrange from highest to lowest, right?
Adam Bohannon
@abohannon
May 28 2017 05:30
lowest to highest
so i can pop
Ogundele Olumide
@Lumexralph
May 28 2017 05:31
@abohannon remember, sort does not return a new array, it works on the pre-existing array, myArray
@abohannon use the length property of string
Dave Reichert
@davidreichert
May 28 2017 05:31
any hints for me?
Manish Giri
@Manish-Giri
May 28 2017 05:32
@davidreichert return "count Hold";
change this
jibin2706
@jibin2706
May 28 2017 05:32

function palindrome(str) {
var a=str.replace(/[-!$%^&*()_+|~=`{}[]:" ;'<>?,.\/]/gi,'');
var b=a.toLowerCase();
var c=b.split('');
var d=c;
c.reverse();
if(c==d){
return true;
}
return false;
}

palindrome("never odd or even");

Manish Giri
@Manish-Giri
May 28 2017 05:32
count and " Hold" separately
same for Bet
@davidreichert
jibin2706
@jibin2706
May 28 2017 05:32
why this code isnt working
Ogundele Olumide
@Lumexralph
May 28 2017 05:33
@abohannon this can do in your sort callback b.length - a.length;, that'll sort from longest word to the shortest
Adam Bohannon
@abohannon
May 28 2017 05:34
oh snap that worked!
thank you @Lumexralph
CamperBot
@camperbot
May 28 2017 05:34
abohannon sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1828 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
May 28 2017 05:34
@abohannon :wink:
jibin2706
@jibin2706
May 28 2017 05:34

//Palindrome
function palindrome(str) {
var a=str.replace(/[-!$%^&*()_+|~=`{}[]:" ;'<>?,.\/]/gi,'');
var b=a.toLowerCase();
var c=b.split('');
var d=c;
c.reverse();
if(c==d){
return true;
}
return false;
}

palindrome("never odd or even");

the false condition isnt working
anyone?
Adam Bohannon
@abohannon
May 28 2017 05:37
@Lumexralph how ugly is this? Another thought I had was using a for loop, but this ended up working.
function findLongestWord(str) {
  var myArray = str.split(' ');
  var sortedArray = myArray.sort(function(a, b){
    return a.length - b.length;
  });
  var longestWord = sortedArray.pop().length;
   return longestWord;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Dave Reichert
@davidreichert
May 28 2017 05:38
var count = 0;

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


  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
still having trouble with counting cards
Nick Gray
@nicholasnbg
May 28 2017 05:38
@davidreichert can you post the html to that exercise for me
Dave Reichert
@davidreichert
May 28 2017 05:39
var count = 0;

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

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
sorry, here is the current code...
Nick Gray
@nicholasnbg
May 28 2017 05:39
sorry, i mean past the link
Nick Gray
@nicholasnbg
May 28 2017 05:40
return count + "hold";
you're missing the + in your answers
Dave Reichert
@davidreichert
May 28 2017 05:41
thanks @nicholasnbg
CamperBot
@camperbot
May 28 2017 05:41
davidreichert sends brownie points to @nicholasnbg :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @nicholasnbg |http://www.freecodecamp.com/nicholasnbg
Dave Reichert
@davidreichert
May 28 2017 05:41
i've alsomst got it...
Nick Gray
@nicholasnbg
May 28 2017 05:41
no worries mate, all working now?
Dave Reichert
@davidreichert
May 28 2017 05:42
yes...
i just figure out i had my < flipped...
so i don't remember...
a lesson on that: returning a number variable and a string
i guess the + doesn't make sense to me...
but I think I can just remember it, get over it, and move on
Kris Baillargeon
@krisb1220
May 28 2017 05:48
Hmm.. I think I'm missing something?

var myVar = 87;

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

output != 87 tho ??
88*
Nick Gray
@nicholasnbg
May 28 2017 05:48

@davidreichert , whenever you are combining elements to be returned, the + is needed.

so
var names = ['bob', 'david', 'andy']; console.log("Hi, my name is " + names[0] + ", nice to meet you")
Will return "Hi my name is bob, nice to meet you

Kris Baillargeon
@krisb1220
May 28 2017 05:49
OHHH I got it nvm LOL
Nick Gray
@nicholasnbg
May 28 2017 05:49
@krisb1220 maVar++ means 87 + 1
Kris Baillargeon
@krisb1220
May 28 2017 05:50
thanks @nicholasnbg I gots it :P
CamperBot
@camperbot
May 28 2017 05:50
krisb1220 sends brownie points to @nicholasnbg :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @nicholasnbg |http://www.freecodecamp.com/nicholasnbg
Nick Gray
@nicholasnbg
May 28 2017 05:52
nw :)
Kris Baillargeon
@krisb1220
May 28 2017 05:54
Learning JS, I'm very thankful I learned basic python first LOL cause this would be so much to take in at once
Nick Gray
@nicholasnbg
May 28 2017 05:56
a lot of concepts are pretty interchangeable between languages, knowing some JS would probably help me with learning python (i hope haha)
Kelechi Chinaka
@ke1echi
May 28 2017 05:57
what array method can i use to remove duplicate elements in an array
Manish Giri
@Manish-Giri
May 28 2017 05:58
@kelechichinaka you could make a copy of the original
then use that to compare with the original
and filter duplicates
Nick Gray
@nicholasnbg
May 28 2017 05:59
@kelechichinaka as @Manish-Giri said, think about looping though the original array, and doing something with each item
Kris Baillargeon
@krisb1220
May 28 2017 06:02
Hey guys having some trouble nailing the exact algorithm they want me to use for "Convert Celsius to Farenheit" even though my algorithm works.. Any suggestions? Will post code
Nasridean
@Nasridean
May 28 2017 06:02
this code
Kris Baillargeon
@krisb1220
May 28 2017 06:02

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var farenheit = celsius * 1.8;
farenheit += 32;

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

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

Manish Giri
@Manish-Giri
May 28 2017 06:03
@krisb1220 typo
Kris Baillargeon
@krisb1220
May 28 2017 06:03
Oh I see
Thank you @Manish-Giri let me see if that works
CamperBot
@camperbot
May 28 2017 06:03
krisb1220 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5694 | @manish-giri |http://www.freecodecamp.com/manish-giri
Kris Baillargeon
@krisb1220
May 28 2017 06:03
Ahh thanks so much lol
English is my strong suit, actually a little angry I messed that one up LOL
Nasridean
@Nasridean
May 28 2017 06:05

this code


function largestOfFour(arr) {
  // You can do this!
  var array0 = arr[0][0];
  var array1 = arr[1][0];
  var array2 = arr[2][0];
  var array3 = arr[3][0];
  for (var i = 0; i < arr.length; i++) {
    if (arr[0][i] > array0) {
      array0 = arr[0][i];
    }
    if (arr[1][i] > array1) {
      array1 = arr[1][i];
    }
    if (arr[2][i] > array2) {
      array2 = arr[2][i];
    }
    if (arr[3][i] > array3) {
      array3 = arr[3][i];
    }
  }
  return [array0 + "," + array1 + "," + array2 + "," + array3];
}

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

shows ["27,5,39,1001"]. How do I remove ""marks?

Kelechi Chinaka
@ke1echi
May 28 2017 06:07
sometimes these CW katas gives me headache @Manish-Giri
Manish Giri
@Manish-Giri
May 28 2017 06:07
@kelechichinaka lol
you should do hackerrank
that makes you feel like killing yourself
Kelechi Chinaka
@ke1echi
May 28 2017 06:08
:smile: @Manish-Giri
Nick Gray
@nicholasnbg
May 28 2017 06:09
@Nasridean does that mean that you need to convert the answer from strings to numbers?
Nasridean
@Nasridean
May 28 2017 06:10
@nicholasnbg yes, they should numbers.
if I remove commas they get stacked.
Nick Gray
@nicholasnbg
May 28 2017 06:10
so maybe use parseInt(arr[x][i])
Nasridean
@Nasridean
May 28 2017 06:12
@nicholasnbg could you show any example?
of using it
can that function include more than 2 values?
@nicholasnbg
Kelechi Chinaka
@ke1echi
May 28 2017 06:14
most times i feel i need to take a basic math course @Manish-Giri
what do u think, am not the best at math @Manish-Giri
Nick Gray
@nicholasnbg
May 28 2017 06:17
@Nasridean ignore that, just need to remove the "" marks around the commas in your answer array,
using "," turns the whole thing into a string
[a,b,c] is an array with 3 values inside it,
[a+","b+","+c] is an array with one value (one string) inside it
Vivek
@vivekmittal7
May 28 2017 06:18

function rot13(str) { // LBH QVQ VG!
  var result = "";

  for (var i=0; i<str.length; i++){
  if (str.charCodeAt(i)>65 & str.charCodeAt(i)<91){
if (str.charCodeAt(i)<78){
  result = String.fromCharCode(i+13);
} else if (str.charCodeAt(i)>78) {
  result = String.fromCharCode(i-13);
}    
  }
}
 return result;                                        
}                     
// Change the inputs below to test
rot13("SERR PBQR PNZC");
hey guys, please tell me whats wrong with my code. answer box just show a red dot after running this code
Nick Gray
@nicholasnbg
May 28 2017 06:20
need to use && not just & @vivekmittal7
try that
Vivek
@vivekmittal7
May 28 2017 06:21
@nicholasnbg thanks
CamperBot
@camperbot
May 28 2017 06:21
vivekmittal7 sends brownie points to @nicholasnbg :sparkles: :thumbsup: :sparkles:
:cookie: 317 | @nicholasnbg |http://www.freecodecamp.com/nicholasnbg
Nasridean
@Nasridean
May 28 2017 06:21
@nicholasnbg I got it, but how do I remove the "" marks?
Manish Giri
@Manish-Giri
May 28 2017 06:21
@kelechichinaka you can, if you want
Nick Gray
@nicholasnbg
May 28 2017 06:21
@Nasridean return [array0 , array1 , array2 , array3];
Manish Giri
@Manish-Giri
May 28 2017 06:22
usually when I get stuck with a math topic while writing code
Santhosh Reddy
@santhu210
May 28 2017 06:22
Hey guys!
Manish Giri
@Manish-Giri
May 28 2017 06:22
I just look up the topic
Nick Gray
@nicholasnbg
May 28 2017 06:22
use that line in place of your current return line, look at the difference
Santhosh Reddy
@santhu210
May 28 2017 06:22

What is wrong with below code?
`var arrG;

function check(val){
var len = arrG.length;
for(var i=1;i<len;i++){
if(val == arrG[i])return true;
}
return false;
}

function destroyer(arr) {
// Remove all the values
var arr2 = [].slice.call(arr);
var arr3 = [].slice.call(arr2[0]);
arrG = arr2;
var arr4 = arr3.filter(check);
return arr4;
}

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

Kelechi Chinaka
@ke1echi
May 28 2017 06:23
ok @Manish-Giri
Santhosh Reddy
@santhu210
May 28 2017 06:23
This program is supposed to remove elements in the input from the array
Nasridean
@Nasridean
May 28 2017 06:24
@nicholasnbg Wow, it was so simple. Thank you!
CamperBot
@camperbot
May 28 2017 06:24
nasridean sends brownie points to @nicholasnbg :sparkles: :thumbsup: :sparkles:
:cookie: 318 | @nicholasnbg |http://www.freecodecamp.com/nicholasnbg
Santhosh Reddy
@santhu210
May 28 2017 06:25
check
Nick Gray
@nicholasnbg
May 28 2017 06:25
@Nasridean no worries you were 99% there haha
Santhosh Reddy
@santhu210
May 28 2017 06:27
'var arrG;'
var arrG;
Vicky Lai
@vickylai
May 28 2017 06:28
RegEx is /\w{3}/
I'm pretty close on the validating phone numbers challenge but lack an expression for disqualifying a string with only one ( or ). Ideas?
Nasridean
@Nasridean
May 28 2017 06:29
@nicholasnbg haha, for real!
Vivek
@vivekmittal7
May 28 2017 06:30

function rot13(str) { // LBH QVQ VG!
  var result;

  for (var i=0; i<str.length; i++){
  if (str.charCodeAt(i)>65 && str.charCodeAt(i)<78){
  result += String.fromCharCode(i+13);
  } else if (str.charCodeAt(i)>=78 && str.charCodeAt(i)<= 90){
    result += String.fromCharCode(i-13);
  }
}
 return result;                                        
}                     
// Change the inputs below to test
rot13("SERR PBQR PNZC");
does my code any sense for ceasar cipher task
Long Nguyen
@longnt80
May 28 2017 06:31
@vickylaiio what do you mean?
Ashan Mohammed
@AshanMohammed
May 28 2017 06:31

Hello Guys! Why doesn't my json api call doesn't work?
``
$(document).ready(function(){

$.getJSON('http://ip-api.com/json' , function(data){
alert("hello");
});

});
``

Vicky Lai
@vickylai
May 28 2017 06:32

@longnt80


function telephoneCheck(str) {
  var valid = [  
                /^\+?1?\s?\-?(\D{1})?\d{3}\D*\d{3}\D?\d{4}$/,
              ];
  var verdict = [];
  for (i in valid) {
    if (valid[i].test(str) === true) {
      verdict.push(true);
    } else verdict.push(false);
  }
  console.log(verdict);
  for (boolean in verdict) {
    if (verdict.indexOf(true) == -1) {
      return false;
    }
    return true;
}
}

telephoneCheck("1 555)555-5555");

Doesn't pass

@AshanMohammed what's the console say?
Kris Baillargeon
@krisb1220
May 28 2017 06:33

```var myStr = "I am a \"double quoted\" string inside \"double quotes\"";

Anyone spot the error??

why didnt that work lol
Ashan Mohammed
@AshanMohammed
May 28 2017 06:34
@vickylaiio Console Says
jquery-3.2.1.min.js:4 Mixed Content: The page at 'https://codepen.io/ashan_zeroxster/pen/MpxVOv' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://ip-api.com/json'. This request has been blocked; the content must be served over HTTPS.
Long Nguyen
@longnt80
May 28 2017 06:34
@vivekmittal7 result += String.fromCharCode(i+13);
i+13 is not right
i is not the charcode
Kris Baillargeon
@krisb1220
May 28 2017 06:35
var myStr = "I am a \"double quoted\" string inside \"double quotes\"";
halp lol
Manish Giri
@Manish-Giri
May 28 2017 06:35
@krisb1220 isn't there supposed to be a . at the end?
Kris Baillargeon
@krisb1220
May 28 2017 06:35
I tried that, but let me try putting it somewhere else
Vivek
@vivekmittal7
May 28 2017 06:35
@longnt80 wouldnt i automatically convert into a number
Long Nguyen
@longnt80
May 28 2017 06:36
@vivekmittal7 it is not a charcode
why you do i+13? to change the charcode value right?
Kris Baillargeon
@krisb1220
May 28 2017 06:36
Yeah adding a period doesn't work either @Manish-Giri
Any suggestions?
Manish Giri
@Manish-Giri
May 28 2017 06:36
@krisb1220 post the challenge url
click run tests first
Kris Baillargeon
@krisb1220
May 28 2017 06:37
with my solution token? or?
Nick Gray
@nicholasnbg
May 28 2017 06:37
@krisb1220 code works ok in my console log, what is the error saying
Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
Manish Giri
@Manish-Giri
May 28 2017 06:37
@krisb1220 did you look at the example?
I am a "double quoted" string inside "double quotes".
Vivek
@vivekmittal7
May 28 2017 06:38
ok i get it; will it work if i make a variable and make it equal to str.charCodeAt(i) and then put that variable in fromCharCode method @longnt80
Manish Giri
@Manish-Giri
May 28 2017 06:38
where is the period?
@krisb1220
Kris Baillargeon
@krisb1220
May 28 2017 06:38
I did it without the period too
I added the period per your suggestion lol
Manish Giri
@Manish-Giri
May 28 2017 06:38
where is the period?
I am a "double quoted" string inside "double quotes".
Kris Baillargeon
@krisb1220
May 28 2017 06:38
I tried with the period too lol
Manish Giri
@Manish-Giri
May 28 2017 06:38
:disappointed:
Kris Baillargeon
@krisb1220
May 28 2017 06:39
It gives me an syn error
Long Nguyen
@longnt80
May 28 2017 06:39
@vivekmittal7 yes you can do that or just put str.charCodeAt(i) + 13
Manish Giri
@Manish-Giri
May 28 2017 06:39
you still can't spot it?
I am a "double quoted" string inside "double quotes".
the period is at the END
outside the quotes
Kris Baillargeon
@krisb1220
May 28 2017 06:39
I did it outside of the quotes
I've tried the period all the which ways
Manish Giri
@Manish-Giri
May 28 2017 06:39
\"double quotes\."";
look where you have it.
Kris Baillargeon
@krisb1220
May 28 2017 06:40
Let me copy and paste the code I have in there right now that is still giving me an error
Long Nguyen
@longnt80
May 28 2017 06:40
@vickylaiio I don't think you need those ?
Vivek
@vivekmittal7
May 28 2017 06:40
@longnt80 thanks sir, it worked
CamperBot
@camperbot
May 28 2017 06:40
vivekmittal7 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @longnt80 |http://www.freecodecamp.com/longnt80
Sandeep Yadav
@sandeepyadav097
May 28 2017 06:40

function checkObj(checkProp) {
// Your Code Here

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

if(myObj.hasOwnProperty(checkProp))
{
  return myObj.checkProp;

}

return "Not Found";
}

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

Manish Giri
@Manish-Giri
May 28 2017 06:40
@sandeepyadav097 use bracket notation
Vivek
@vivekmittal7
May 28 2017 06:40
@longnt80 now i just have to do something about those spaces
Kris Baillargeon
@krisb1220
May 28 2017 06:40

var myStr = "I am a \"double quoted\" string inside \"double quotes\."";
Manish Giri
@Manish-Giri
May 28 2017 06:40
myObj.checkProp;
@sandeepyadav097
Kris Baillargeon
@krisb1220
May 28 2017 06:41
am I still missing something ...?
Sandeep Yadav
@sandeepyadav097
May 28 2017 06:41
i didnt get it
Nick Gray
@nicholasnbg
May 28 2017 06:41
@krisb1220 the full stop is in the wrong spot in that code
Manish Giri
@Manish-Giri
May 28 2017 06:41
@krisb1220 ugh
@krisb1220 \."
Nick Gray
@nicholasnbg
May 28 2017 06:41
hint, shift it to the right ;)
Manish Giri
@Manish-Giri
May 28 2017 06:41
this looks right?
Kris Baillargeon
@krisb1220
May 28 2017 06:41
oh my gos
Manish Giri
@Manish-Giri
May 28 2017 06:41
gosh
Kris Baillargeon
@krisb1220
May 28 2017 06:41
LOL
Nick Gray
@nicholasnbg
May 28 2017 06:41
haha
Sandeep Yadav
@sandeepyadav097
May 28 2017 06:41

function checkObj(checkProp) {
// Your Code Here

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

if(myObj.hasOwnProperty(checkProp))
{
  return myObj.checkProp;

}

return "Not Found";
}

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

whats wrong in this???
Kris Baillargeon
@krisb1220
May 28 2017 06:41
I hate myself sometimes LOL
It's also 3 AM
Almost
Manish Giri
@Manish-Giri
May 28 2017 06:41
@sandeepyadav097 use bracket notation
told you whats wrong
@sandeepyadav097
Sandeep Yadav
@sandeepyadav097
May 28 2017 06:42
where ??
i used it also
but no impact
Manish Giri
@Manish-Giri
May 28 2017 06:43
read posts where you're tagged
Vivek
@vivekmittal7
May 28 2017 06:45
does anyone know unicode charachter of " " space, i cant get to find it on internet
Long Nguyen
@longnt80
May 28 2017 06:46
@vivekmittal7 in caesar cipher you don't need unicode for space
@vivekmittal7 you only need unicode for character from A-Z (uppercase), everything else will return as it is
Vivek
@vivekmittal7
May 28 2017 06:48
@longnt80 but the result shows everything glued together and theres undefined in front of it

function rot13(str) { // LBH QVQ VG!
  var result;
  var number;
  for (var i=0; i<str.length; i++){
  if (str.charCodeAt(i)>65 && str.charCodeAt(i)<78){
  number = str.charCodeAt(i);
    result += String.fromCharCode(number+13);
  } else if (str.charCodeAt(i)>=78 && str.charCodeAt(i)<= 90){
    number = str.charCodeAt(i);
    result += String.fromCharCode(number-13);
  } 
}
 return result;                                        
}                     
// Change the inputs below to test
rot13("SERR PBQR PNZC");
this is my code and this is what i get after running it.
undefinedFREECODECAMP
Long Nguyen
@longnt80
May 28 2017 06:50
@vivekmittal7 try add this
else {
   result += str(i);
}
Vivek
@vivekmittal7
May 28 2017 06:51
why is there a 9
Long Nguyen
@longnt80
May 28 2017 06:51
typo
Baibhav Gautam
@baibhavx
May 28 2017 06:51
U+0020 @vivekmittal7
Vicky Lai
@vickylai
May 28 2017 06:51
@AshanMohammed Google CORS error or try to access codepen via http
Ashan Mohammed
@AshanMohammed
May 28 2017 06:53
@vickylaiio Yes! I tried to access codepen via http. But not sure how to do this. Can you please help with connecting codepen via http://
Vivek
@vivekmittal7
May 28 2017 06:53
@longnt80 it says str is not a function
Long Nguyen
@longnt80
May 28 2017 06:53
@vivekmittal7 post your code again
Vicky Lai
@vickylai
May 28 2017 06:53
@AshanMohammed What's your URL bar say?
Vivek
@vivekmittal7
May 28 2017 06:53

function rot13(str) { // LBH QVQ VG!
  var result;
  var number;
  for (var i=0; i<str.length; i++){
  if (str.charCodeAt(i)>65 && str.charCodeAt(i)<78){
  number = str.charCodeAt(i);
    result += String.fromCharCode(number+13);
  } else if (str.charCodeAt(i)>=78 && str.charCodeAt(i)<= 90){
    number = str.charCodeAt(i);
    result += String.fromCharCode(number-13);
  } else {result += str(i)};
}
 return result;                                        
}                     
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Ashan Mohammed
@AshanMohammed
May 28 2017 06:54
@vickylaiio
https://codepen.io/ashan_zeroxster/pen/MpxVOv
Vicky Lai
@vickylai
May 28 2017 06:55
@AshanMohammed Nvm. I think they disallowed that now
You'll have to learn about using Ajax to solve CORS / mixed origin error
Long Nguyen
@longnt80
May 28 2017 06:55
@vivekmittal7 my bad shoud be str[i]
Vivek
@vivekmittal7
May 28 2017 06:56
@longnt80 lol, my bad too. should have known it after so long.
@longnt80 thanks a lot
CamperBot
@camperbot
May 28 2017 06:56
vivekmittal7 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:warning: vivekmittal7 already gave longnt80 points
Long Nguyen
@longnt80
May 28 2017 06:57
@vivekmittal7 btw, you don't have to declare number many time
only after the beginning of for loop
Vivek
@vivekmittal7
May 28 2017 06:58
@longnt80 before the if statement
Long Nguyen
@longnt80
May 28 2017 06:58
@vivekmittal7
function rot13(str) { // LBH QVQ VG!
  var result;

  for (var i=0; i<str.length; i++){
  var number = str.charCodeAt(i);

  if (str.charCodeAt(i)>65 && str.charCodeAt(i)<78){
    result += String.fromCharCode(number+13);
  } else if (str.charCodeAt(i)>=78 && str.charCodeAt(i)<= 90){
    result += String.fromCharCode(number-13);
  } else {result += str[i]};
}
  console.log(result);
 return result;                                        
}                     
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Vivek
@vivekmittal7
May 28 2017 06:59
@longnt80 thanks, do you see anything wrong, answer still shows undefined before the answer I want
CamperBot
@camperbot
May 28 2017 06:59
vivekmittal7 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:warning: vivekmittal7 already gave longnt80 points
Long Nguyen
@longnt80
May 28 2017 07:00
@vivekmittal7 oh, you just need to declare result as empty string at the beginning: var result = "";
Vivek
@vivekmittal7
May 28 2017 07:01
ok thanks
Kris Baillargeon
@krisb1220
May 28 2017 07:04
hey just in case anyone wants to set up a portfolio godaddy is doing 12/yr for hosting + domains
plus free email
tbh i bought two lol
Long Nguyen
@longnt80
May 28 2017 07:05
@krisb1220 thanks for the tip
CamperBot
@camperbot
May 28 2017 07:05
longnt80 sends brownie points to @krisb1220 :sparkles: :thumbsup: :sparkles:
:cookie: 146 | @krisb1220 |http://www.freecodecamp.com/krisb1220
Kris Baillargeon
@krisb1220
May 28 2017 07:05
nah none needed man anything to same someone a buck lol
save*
Himanshu Gandhi
@desperate001
May 28 2017 07:10
studlyCapVaR this variable is showing issue with camel case. whats wrong with it?
Nasridean
@Nasridean
May 28 2017 07:17
What's wrong with this code?

function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
   if (str.substr(str.length - target.length,target.length) == target.substr(0,target.length)) {
       return "true";
       }
  else {
    return "false";
  }
}

confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification");
Nick Gray
@nicholasnbg
May 28 2017 07:19
can you give me the purpose of the function?
is it to indicate if target is the last word of str?
yashasvi13
@yashasvi13
May 28 2017 07:20
In function abTest(a,b) if any of them is negative it should return undefined and if abTest(2,2) it should return 8. How do I do the second case?
Nasridean
@Nasridean
May 28 2017 07:21
@nicholasnbg yes this is it's purpose
@nicholasnbg Check if a string (first argument, str) ends with the given target string (second argument, target).
Nick Gray
@nicholasnbg
May 28 2017 07:22
@Nasridean ok, you're way looks hard haha, my initial thought would just be to split the str
do you see where I'm heading?
Manish Giri
@Manish-Giri
May 28 2017 07:22
@yashasvi13 you should just do the first case
I think there's already code in the editor for the 2nd case
Nasridean
@Nasridean
May 28 2017 07:23
@nicholasnbg split into arrays?
Nick Gray
@nicholasnbg
May 28 2017 07:23
yeah, so str.split(' ')
Nasridean
@Nasridean
May 28 2017 07:24
But why? @nicholasnbg
Vicky Lai
@vickylai
May 28 2017 07:25
Anyone know a short way of doing, "if a string contains x or y but not x and y return true"?
yashasvi13
@yashasvi13
May 28 2017 07:25
@Manish-Giri But by just putting an else it is not returning anything
Manish Giri
@Manish-Giri
May 28 2017 07:25
@vickylaiio yeah
just use && or ||
Nick Gray
@nicholasnbg
May 28 2017 07:25

@Nasridean

var string = "this is a string";

var arr = string.split(' ');
//["this", "is","a","string"]

Manish Giri
@Manish-Giri
May 28 2017 07:26
@yashasvi13 did you write the if?
yashasvi13
@yashasvi13
May 28 2017 07:26
yes
Manish Giri
@Manish-Giri
May 28 2017 07:26
post your code
Vicky Lai
@vickylai
May 28 2017 07:26
@Manish-Giri Easy enough, it's the "but not" part..
Nick Gray
@nicholasnbg
May 28 2017 07:26
@Nasridean see what you could then check target against?
yashasvi13
@yashasvi13
May 28 2017 07:27

@Manish-Giri if(a||b<0){
return undefined;

}
else

// Only change code above this line

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

Manish Giri
@Manish-Giri
May 28 2017 07:27
@yashasvi13 if(a||b<0){
this is not right
you need to check for both a and b
in the if
yashasvi13
@yashasvi13
May 28 2017 07:28
like a<0||b<0?
Manish Giri
@Manish-Giri
May 28 2017 07:28
yes
yashasvi13
@yashasvi13
May 28 2017 07:28
alright thanks :)
Nasridean
@Nasridean
May 28 2017 07:28
@nicholasnbg but, you know, my current code still shows the expected results, but somehow I can't pass the challenge.
Manish Giri
@Manish-Giri
May 28 2017 07:28
:+1:
Nick Gray
@nicholasnbg
May 28 2017 07:28
@Nasridean can you post the challange url