These are chat archives for FreeCodeCamp/HelpJavaScript

24th
Jun 2017
Matej P.
@CroRaptor
Jun 24 2017 00:00
var myStr = "FirstLine\n\SecondLine\rThirdLine";
Nefton
@neftonjin
Jun 24 2017 00:01
// Setup
function abTest(b, a) {
  // Only change code below this line

   if  ( a < 0 ) {   
      return undefined; }
   else if  ( b < 0 )    
         { return undefined;}

  // 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);
why are these two not have the same result ??
// Setup
function abTest(b, a) {
  // Only change code below this line

   if  ( a || b < 0 ) {   
      return undefined; }


  // 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);
Joseph
@revisualize
Jun 24 2017 00:01
Again, escaping a backslash is \\
@neftonjin The two do NOT have the same result.

How to write an if conditional statements with OR and AND operators:
I am seeing a large number of people writing if conditions using OR and AND operators incorrectly.
Here is an example of what I'm seeing:

if (param1 == "a" || "c" || "e") { // incorrect
   var output = "Odd lowercase alpha character"; 
}

What I think people think is that it will compare param1 to "a" then compare param1 to "c" then compare param1 to "e"
However, that's not actually what the computer is processing.

if conditions need to be evaluated to true for the if statement to run:

if ((condition1) || (condition2) || (condition3) {
    // true statement
}

And how we would code that up from our example above where we're trying to get the odd character from a parameter (param1):

if (param1 == "a" || param1 == "c" || param1 == "e") {
   var output = "Odd lowercase alpha character"; 
}

I'm also seeing people writing and statements like this:

if (param1 == "a" && param1 == "e") {
}

The problem with this is the fact that a variable can't really be two strings or two different numbers at the same time.

Matej P.
@CroRaptor
Jun 24 2017 00:02
aaaah understand
thanks a lot
didnt watch propertly code and output
Nefton
@neftonjin
Jun 24 2017 00:04
@revisualize thanks
CamperBot
@camperbot
Jun 24 2017 00:04
neftonjin sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4242 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 24 2017 00:04

@neftonjin

   if  ( a || b < 0 ) {
      return undefined;
}

With this code you're actually trying to evaluate if a is true ... OR ... b is less than 0.
You need to understand that there needs to be far more explicitly with the condition

@neftonjin a < 0 || b < 0 ... This is the evaluation that you're actually looking for.
See how it breaks the condition down to two parts that can evaluate to true.
aRtoo
@artoodeeto
Jun 24 2017 00:06
hi guys. how do you use fb.ui?? cant you share immediately the quote? you just have to share the link and put some text? heres the link. http://www.fbrell.com/saved/2779dc018c325d85d650a3b723239650
if anyone has experienced on this please help. thanks
Nefton
@neftonjin
Jun 24 2017 00:06
yes now it makes sense to me
Dhrumit Thakkar
@Dhrumit14
Jun 24 2017 00:07
Hello,
I'm not getting text on button
https://codepen.io/Dhrumit/pen/mwREwG
can somebody help ?
Mahdi Eftekhari Moghaddam
@Mahdieft
Jun 24 2017 00:15
Hello,
How can I improve Seek and Destroy code? It works and passes, just need to improve it. Thanks in advance

function destroyer(arr) {

  for (var i = 1; i < arguments.length; i++)
    arr = arr.filter(function(value){
      if (value != this) 
        return value;
    }, arguments[i]);

  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Paulo Raoni
@paulo-raoni
Jun 24 2017 00:45
function destroyer(arr) {
    function filtering(value){
      if (value != this) {
                return value;
            }
  }
    for (var i = 1; i < arguments.length; i++){
        arr = arguments[0].filter(filtering, arguments[i]);
    }

  return arr;
}

console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));
I think it makes more sense to me. But your code is good.
function destroyer(arr) {
    function filtering(value){
        if (value != this) {
            return value;
        }
    }
    for (var i = 1; i < arguments.length; i++){
        arr = arguments[0].filter(filtering, arguments[i]);
    }

    return arr;
}

console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));
With proper indentation.
Moisés Man
@moigithub
Jun 24 2017 00:47
i think u could remove the loop... n use includes or indexOf on ur callback
didnt test.. but something like this
function filtering(val){ return !this.includes(val)} // added NOT
return arr.filter(filtering, [...arguments].slice(1));
UnkyKong
@UnkyKong
Jun 24 2017 01:15

function destroyer(arr) {
  // Remove all the values

    arr.filter(function(value){
      for (var i = 1; i < arguments.length; i++){

      return value !== arguments[i];

     }
    });

  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
What am I missing?
abraham anak agung
@padunk
Jun 24 2017 01:15
@Dhrumit14 try make the id camel case and style it base on its id
Moisés Man
@moigithub
Jun 24 2017 01:18
@UnkyKong EVERY function have its own arguments object
soo calling arguments inside destroyer funciton is NOT the same as calling it inside filter callback/function
UnkyKong
@UnkyKong
Jun 24 2017 01:19
ahh, ok. TY
raysam1998
@raysam1998
Jun 24 2017 01:19
hi
please
the counting cards games
i know im supposed to use the switch(card) function but i dont know how to start
please help :)
UnkyKong
@UnkyKong
Jun 24 2017 01:19
@moigithub Thank you, so I'm calling arguments for the internal function.
CamperBot
@camperbot
Jun 24 2017 01:19
unkykong sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3409 | @moigithub |http://www.freecodecamp.com/moigithub
abraham anak agung
@padunk
Jun 24 2017 01:20
@raysam1998 check it here switch
UnkyKong
@UnkyKong
Jun 24 2017 01:23
function destroyer(arr) {
  // Remove all the values



      for (var i = 1; i < arguments.length; i++){
        var remove = arguments[i];
      arr = arr.filter(function(value){
      return value != remove;

     });
    }

  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
got it. I'm getting a warning for having the function in a loop.
raysam1998
@raysam1998
Jun 24 2017 01:23
alright first of all
could you fine gentlemens tell me how to actually take a screenshot of the code in order to have a more precise description of my problem :)
ty in advance
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:24
@raysam1998 '''
CamperBot
@camperbot
Jun 24 2017 01:24
:bulb: to format code use backticks! ``` more info
Moisés Man
@moigithub
Jun 24 2017 01:24
create the function outside the loop @UnkyKong
functin aaa(){ ...}
for(){
 ... filter( aaa)
}
UnkyKong
@UnkyKong
Jun 24 2017 01:24
copy it and paste it inside
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:24
@raysam1998 click the more info link
raysam1998
@raysam1998
Jun 24 2017 01:25
im using codecamp if that helps
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:25
@UnkyKong create the callback outside the loop, filter also goes through all the elements in the array, a form of loop too
UnkyKong
@UnkyKong
Jun 24 2017 01:25
@moigithub it runs inside fine, just wondering what kind of problems could arise from that?
Moisés Man
@moigithub
Jun 24 2017 01:25
everytime it loops.. javascript re-create the function in memory..
... performance issues
UnkyKong
@UnkyKong
Jun 24 2017 01:27
ah, ok cool
raysam1998
@raysam1998
Jun 24 2017 01:28
heeeeee.png
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:29
@raysam1998 can you paste the code here?
raysam1998
@raysam1998
Jun 24 2017 01:29

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:

}

return "Change Me";
// 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
Jun 24 2017 01:30
@raysam1998 you're in the right direction
raysam1998
@raysam1998
Jun 24 2017 01:31
ty :)
what do i do for the (7,8,9) cases since they do nothing to the count
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:31
@raysam1998 you can eliminate it
raysam1998
@raysam1998
Jun 24 2017 01:31
so i dont need to implement those cases ? i
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:32
@raysam1998 you've already started, you're yet to complete the card values to be checked by the switch statement
UnkyKong
@UnkyKong
Jun 24 2017 01:34
@Lumexralph @moigithub got it, thanks again
CamperBot
@camperbot
Jun 24 2017 01:34
unkykong sends brownie points to @lumexralph and @moigithub :sparkles: :thumbsup: :sparkles:
:warning: unkykong already gave moigithub points
:star2: 1992 | @lumexralph |http://www.freecodecamp.com/lumexralph
UnkyKong
@UnkyKong
Jun 24 2017 01:34

```function destroyer(arr) {
// Remove all the values

function  removed(value){
  return value != remove;

 }

  for (var i = 1; i < arguments.length; i++){
    var remove = arguments[i];
  arr = arr.filter(removed);
}

return arr;
}

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

```

Guderian Raborg
@hypercuber
Jun 24 2017 01:37
Can someone help me and work on my code or tell me the easiest way to get an array of fibonacci numbers less than number, max. For some reason they started with 1,2... in project euler.
function fibonacci(n) { //should start with 1, 1; n >= 2
  var arr = [1, 2];
  for (var i = 2; i < n; i++) { //what if n=2?
    arr.push(arr[i - 1] + arr[i - 2]);
  }
  return arr;
}
console.log(fibonacci(5)); //1, 2, 3, 5, 8

function arrUpTo(max) {
  var n = 0;
  function doMath(n) {
    var arr = fibonacci(n);
    if (arr[arr.length - 1] < max) {
      n++;
      return doMath(n);
    } else {
      return arr;
    }
  }
  doMath(n);
}
console.log(arrUpTo(100));
Ateeq Khan
@ez12024
Jun 24 2017 01:37
i'm doing 'iterate over Arrays with map'

ar oldArray = [1,2,3,4,5];

// Only change code below this line.

var oldArray = [1,2,3,4,5];
var addThree = oldArray.map(function(val){
return val +3;});
console.log(addThree); // returns [4,5,6,7,8]
console.log(oldArray); // returns [1,2,3,4,5]

I need to add three to each value in the array still? What's wrong with my code?
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:38
@ez12024 you need to change the name of the array addThree to newArray I think
Ateeq Khan
@ez12024
Jun 24 2017 01:39
@Lumexralph thanks
CamperBot
@camperbot
Jun 24 2017 01:39
ez12024 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1993 | @lumexralph |http://www.freecodecamp.com/lumexralph
Guderian Raborg
@hypercuber
Jun 24 2017 01:39
I forgot the return in arrUpTo(). I think I still dont have it...
Natalia C
@MountainGirl504
Jun 24 2017 01:40
Hi everyone, I'm trying to figure out the challenge with Conditional Logic with If Statements. Does anyone else have a problem with it? Is it a bug? Or is it me? :)
I think my code is correct, but it doesn't solve :(
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:42
@MountainGirl504 show your code
Natalia C
@MountainGirl504
Jun 24 2017 01:43

// Setup
function trueOrFalse(wasThatTrue) {

// Only change code below this line.

if(wasThatTrue) {

return "Yes, that was true";

}
return "No, that was false";
}

Ogundele Olumide
@Lumexralph
Jun 24 2017 01:44
@MountainGirl504 what were you to return from FCC?
Natalia C
@MountainGirl504
Jun 24 2017 01:45
What do you mean?
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:46
@MountainGirl504 instructions from FCC
Natalia C
@MountainGirl504
Jun 24 2017 01:46
Create an if statement inside the function to return "Yes, that was true" if the parameter wasThatTrue is true and return "No, that was false" otherwise.
What am I doing wrong?
Moisés Man
@moigithub
Jun 24 2017 01:48
on left bottom side.. there are some test.. which one have red mark ?
copy the text @MountainGirl504
Gustavo Azevedo
@gustavoaz7
Jun 24 2017 01:48
What does it show on the console ?
Natalia C
@MountainGirl504
Jun 24 2017 01:48

SyntaxError: Unexpected token }

trueOrFalse should be a function
trueOrFalse(true) should return a string
trueOrFalse(false) should return a string
trueOrFalse(true) should return "Yes, that was true"
trueOrFalse(false) should return "No, that was false"

Vinnie Lu
@VinnieLu
Jun 24 2017 01:49
I'm doing Stand in Line. I pushed and shifted but it won't give me the pass. What am I doing wrong?
function nextInLine(arr, item) {
arr.push(item);
var shiftedItem = arr.shift;
return shiftedItem; // Change this line
}
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:49
@MountainGirl504 what @moigithub said will help us understand the issue
@VinnieLu shift is an array method arr.shift();
@MountainGirl504 what tests are failing?
Moisés Man
@moigithub
Jun 24 2017 01:50
@MountainGirl504 weird.. code looks ok
Vinnie Lu
@VinnieLu
Jun 24 2017 01:50
That was it! Thanks so much!
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:50
@moigithub same here
@MountainGirl504 what people also try to do is reloading the page, you can try that too
Natalia C
@MountainGirl504
Jun 24 2017 01:53
Thanks guys! Reloaded the page, but still nothing. It's gotta be a bug.
Well, at least my code is correct! :)
Gustavo Azevedo
@gustavoaz7
Jun 24 2017 01:53
@MountainGirl504 have your tried it on a different browser ?
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:53
@MountainGirl504 is it failing any test?
Moisés Man
@moigithub
Jun 24 2017 01:53
reset code do again.. make sure u dont have any extra } or missing one..
each open { should have a closing } @MountainGirl504
but what u posted here.. is ok
raysam1998
@raysam1998
Jun 24 2017 01:54

var count = 0;

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

  count+=1;
break;
case 10:
case 'j':
case 'Q':
case 'K':
case 'A':
 count-=1;
break;
case 7:
case 8:
case 9:
  count+=0;

}

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

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

Cards Sequence 10, J, Q, K, A wont return (-1 Hold) :'( :'( :'(
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:55
@raysam1998 as discussed earlier remove case 7, 8, 9
@raysam1998 case J not j
raysam1998
@raysam1998
Jun 24 2017 01:57
so the if statement in the end is mandatoru
Vinnie Lu
@VinnieLu
Jun 24 2017 01:58
@Lumexralph you are a wizard, so grateful to dudes like you
raysam1998
@raysam1998
Jun 24 2017 01:58
oh god i'm so dumb
ty
@VinnieLu
CamperBot
@camperbot
Jun 24 2017 01:58
raysam1998 sends brownie points to @vinnielu :sparkles: :thumbsup: :sparkles:
:cookie: 175 | @vinnielu |http://www.freecodecamp.com/vinnielu
Dailin
@DailinH
Jun 24 2017 01:58
can someone help me plz I'm extremely confused about what's wrong abt my code

//初始化变量
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 lookUp(firstName, prop){

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

Joseph
@revisualize
Jun 24 2017 01:59
@DailinH Okay.
Dailin
@DailinH
Jun 24 2017 01:59
thx : D
Joseph
@revisualize
Jun 24 2017 01:59
@DailinH So, here's the problem.
Ogundele Olumide
@Lumexralph
Jun 24 2017 01:59
@VinnieLu wizard ? I'm just a regular dude trying to learn as you're
Joseph
@revisualize
Jun 24 2017 01:59
@DailinH If you're looking for "Kristian"
@DailinH you have else if(contacts[i].firstName != firstName) return "No such contact";
So, let's replace those with the variables.
else if(contacts[0].firstName != firstName) return "No such contact";
else if(contacts[0].firstName != "Kristian") return "No such contact";
else if("Akira" != "Kristian") return "No such contact";
Akira does not equal Kristian ... So, that's true.
Therefore, that if statement gets executed.
raysam1998
@raysam1998
Jun 24 2017 02:00
wrong tag sorry
@Lumexralph ty friend i was stuck in there for almost an hour
CamperBot
@camperbot
Jun 24 2017 02:00
raysam1998 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1994 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 24 2017 02:00
@raysam1998 all good :smile:
Dailin
@DailinH
Jun 24 2017 02:01
yes, when I look for "Akira" it returns the correct thing, and I can't understand why @revisualize
Joseph
@revisualize
Jun 24 2017 02:02
@DailinH Look at what I wrote again, I edited it.
@DailinH It's doing what you're telling it to do.
@DailinH You're telling it to HALT if the firstName doesn't match.
Dailin
@DailinH
Jun 24 2017 02:02
ooooooh
@revisualize thx :D
CamperBot
@camperbot
Jun 24 2017 02:03
dailinh sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4243 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 24 2017 02:03
@DailinH You need to allow your loop to loop all the way before you return that a contact isn't in the list.
Dailin
@DailinH
Jun 24 2017 02:03
okay, I get it now :D
Joseph
@revisualize
Jun 24 2017 02:03
:D
@DailinH You're going to have other issues with your If / Else both having return statements as well.
I'd suggest using a nested if/else inside of an if.
glitz20
@glitz20
Jun 24 2017 02:05
Can anyone help with the code to get latitude and longitude?
~~

~~
$(document).ready(function(){
var lat;
var long;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
lat=position.coords.latitude;
long=position.coords.longitude

});
}
console.log(lat);

});
~~

$(document).ready(function(){
 var lat;
  var long;
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
    lat=position.coords.latitude;
    long=position.coords.longitude

  });
}
  console.log(lat);

});
Dailin
@DailinH
Jun 24 2017 02:09
@revisualize the code ran well after I changed the way return nested in the for loop and if/else
Joseph
@revisualize
Jun 24 2017 02:11
@DailinH Solved?
Dailin
@DailinH
Jun 24 2017 02:11

@revisualize in this manner:
function lookUp(firstName, prop){
for(var i = 0 ;i<4;i++){
if(contacts[i].firstName==firstName && contacts[i].hasOwnProperty(prop)) return contacts[i][prop];

else if(contacts[i].firstName==firstName) return "No such property";
}
return "No such contact";
}

many thanks from me =)

CamperBot
@camperbot
Jun 24 2017 02:11
dailinh sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: dailinh already gave revisualize points
KatSaldivar
@KatSaldivar
Jun 24 2017 02:25
$(".square").on("click", function(event){
    alert("add symbol here");
  });
I cant tell why this isnt working
I worked on the windows computer at work, but now it isnt working on my macbook at home. hmm.
nvm
Ateeq Khan
@ez12024
Jun 24 2017 02:32
im trying to reverse a string
reverseString("hello") should become "olleh"?

function reverseString(str) {
return str;
}

function splitString(str)
{return str;}

var a = reverseString("hello");
var reversed = a.reverse();

console.log(a); // ["hello"]
console.log(reversed); // ["olleh"]

aRtoo
@artoodeeto
Jun 24 2017 02:33
master how would i open the facebook then share a content?? i have their user interface from fbdev. heres the code:

    $('.btn-fb').on('click',function(){
      event.preventDefault();

      window.fbAsyncInit = function (){
        FB.ui({
        method: 'share',
        display: 'popup',
        href: 'https://facebook.com',
        }, function(response){
          $('.btn-fb').attr("href",href);
        });
      }
    })
Guderian Raborg
@hypercuber
Jun 24 2017 02:36
Why would I need return here "return doMath(n);" when doMath() function already have "return"?
function fibonacci(n) { //should start with 1, 1; n >= 2
  var arr = [1, 2];
  for (var i = 2; i < n; i++) { //what if n=2?
    arr.push(arr[i - 1] + arr[i - 2]);
  }
  return arr;
}
console.log(fibonacci(5)); //1, 2, 3, 5, 8

function arrUpTo(max) {
  var n = 0;
  function doMath(n) {
    var arr = fibonacci(n);
    if (arr[arr.length - 1] < max) {
      n++;
      return doMath(n);
    }
    arr.pop(); //for some reason
    return arr;
  }
  return doMath(n);
}
console.log(arrUpTo(25)); //1, 2, 3, 5, 8, 13, 21
Just seem a little old. Maybe each function need return
aRtoo
@artoodeeto
Jun 24 2017 02:39
@hypercuber not really, its just fcc. try it on repl.it just to check
Tim Porter
@potato8
Jun 24 2017 02:56
hello
Johnny O'Sullivan
@johnnyosullivan
Jun 24 2017 02:56
Trying to see if my logic is approaching anything close to what's required for the Mutations challenge.

function mutation(arr) {

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

  var find = arr[0].split('');
  var test = arr[1].split('');

  for (var j = 0; j < test.length; j++){
    if (find.indexOf(test[j]) > -1) {
    test.splice(test[j], 1);
      if (test === []) {
        return true;
      } else return false;
    }
  }
}

mutation(["hello", "hey"]);
Daniel Lim
@ddanielnp
Jun 24 2017 03:01

what is wrong here? ```
function nextInLine(arr, item) {
// Your code here
testArr = testArr.push(item);
console.log(testArr);
testArr = arr.shift();
return testArr[0]; // 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));
```


function nextInLine(arr, item) {
  // Your code here
  testArr = testArr.push(item);
console.log(testArr);
  testArr = arr.shift();
  return testArr[0];  // 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));
Tim Porter
@potato8
Jun 24 2017 03:07
@ddanielnp how is this supposed to help?
Zach Hall
@el4z
Jun 24 2017 03:08
@potato8 he was talking about his own issue. do you want to post the code of your challenge so far? the link just sends me to my finished version so can't tell where you've gone wrong
Tim Porter
@potato8
Jun 24 2017 03:09

// Initialize these three variables
var a = 5;
var b = 10;
var c = 'i am a String!';

// Do not change code below this line

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

@el4z
Joseph
@revisualize
Jun 24 2017 03:10
@potato8 your string needs to be EXACT
@ddanielnp You're using testArr when you should be using arr.
Daniel Lim
@ddanielnp
Jun 24 2017 03:11
@potato8 now u are doing it 'i am a string string'
Joseph
@revisualize
Jun 24 2017 03:11
@ddanielnp You're also overwriting testArr with a single number value.
Zach Hall
@el4z
Jun 24 2017 03:12
@potato8 that's i am a string string, you want c to be i am a
Joseph
@revisualize
Jun 24 2017 03:12
@ddanielnp You really need to really go back and read the instructions of the lesson.
Tim Porter
@potato8
Jun 24 2017 03:13
@revisualize thanks
CamperBot
@camperbot
Jun 24 2017 03:13
potato8 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4244 | @revisualize |http://www.freecodecamp.com/revisualize
fdemaa
@fdemaa
Jun 24 2017 03:30
Can anyone help me do i have to use other approach?, i can't pass this callback because i'm comparing entire word or the last character.. Can i fix it or just start over?

function confirmEnding(str, target) {
/*str.substr(start , length)
*/
/*a = str.split(" "); console.log(a)*/
/* d =  str.slice(-1);console.log(d);*/

c = str.substr(length-1); console.log(c);
b = str.length; console.log(b);  
d = str.split(" ").pop(); console.log(d);

  if( d == target ){
  return true;
} else if(c==target ) {
  return true;
}
return false;
}

confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification");
mangoyi
@mangoyi
Jun 24 2017 03:31
who can help me ?
ramundson1
@ramundson1
Jun 24 2017 03:32
im so lost on the check for palindromes section
challenge i mean
Ogundele Olumide
@Lumexralph
Jun 24 2017 03:33
@ramundson1 what've you tried?
@mangoyi ask if people can they'll
ramundson1
@ramundson1
Jun 24 2017 03:33
i dont even know where to start
@Lumexralph
Ogundele Olumide
@Lumexralph
Jun 24 2017 03:34
@fdemaa using target.length and substring will help
fdemaa
@fdemaa
Jun 24 2017 03:34
@Lumexralph thanks ogundele
!
Ogundele Olumide
@Lumexralph
Jun 24 2017 03:36
@ramundson1 I think your have to remove any non-alphanumeric from the string, make it lowercase, reverse a version of one and compare the reversed version with the unreversed version, that should solve the question of palindrome
@fdemaa :+1:
Daniel Lim
@ddanielnp
Jun 24 2017 03:38
https://www.freecodecamp.com/challenges/stand-in-line . need helpp

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

// Test Setup
var testArr = [5,6,7,8,9];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
my third requirement doesnt pass
Ogundele Olumide
@Lumexralph
Jun 24 2017 03:41
@ddanielnp use the arr parameter in place of the global array used for testing testArr you used in your code
Daniel Lim
@ddanielnp
Jun 24 2017 03:42
for all the testArr?
Ogundele Olumide
@Lumexralph
Jun 24 2017 03:42
@ddanielnp and remember that push method does do things, it returns the length of the array if pushed a value to and the side-effect is adding a value to the end of an array, it's best not to assign it to any variable/thing
yes all testArr in your function
Zhangze
@NominationP
Jun 24 2017 03:51
Hello every body !
Justin Ketterman
@jkketts
Jun 24 2017 03:52
Hi @NominationP
@ddanielnp did you figure that one out? It took me about a day before I realized what I needed to do
Joseph
@revisualize
Jun 24 2017 03:54
I have a whole document written to help people with Stand In Line.
Nothing in the instructions states to use testArr.
an array (arr) and a number (item)
Ken Haduch
@khaduch
Jun 24 2017 03:55
@ddanielnp - definitely do not use the name testArr inside the function body. The function argument arr assumes the value of the argument that is named when the function is invoked, so within the function arr and item are the two variables that you need to use.
glitz20
@glitz20
Jun 24 2017 03:58
Can anyone see why my weather app is not showing any data from the API? https://codepen.io/sabin20/pen/eREPby?editors=1111
huynguyen2071991
@huynguyen2071991
Jun 24 2017 03:59
hello, does anyone can help me solve this problem? what is my misktakes?

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line.

return Math.floor(Math.random() * 10);
}

the result is "TypeError: Math.random is not a function"
Logan Kuzyk
@logankuzyk
Jun 24 2017 04:00
function cc(card) {
  // Only change code below this line
  if (card = 2,3,4,5,6) {
    count += 1; 
  } else if (card = 7,8,9) {
    count += 0;
  } else if (card = 10,'J','Q','K','A') {
    count -= 1;
  }

  if (count <= 0){
    return count + ' Hold';
  } else if (count > 0) {
    return count + ' Bet';
  }
  // Only change code above this line
}
how can i check if card is equal to multiple options
this is what i wrote
michaelcmelton
@michaelcmelton
Jun 24 2017 04:01
doe sanyone have any suggestions for the Chunky Monkey challenge?
Logan Kuzyk
@logankuzyk
Jun 24 2017 04:01
i feel like its really bad
Johnny O'Sullivan
@johnnyosullivan
Jun 24 2017 04:05
Can somebody point me in the direction of what I'm doing wrong with the splice portion of this code?

function mutation(arr) {

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

  var find = arr[0].split('');
  var test = arr[1].split('');

  for (var j = 0; j < test.length; j++){
    if (find.indexOf(test[j]) !== -1) {
    test.splice(j, 1);
    } 
  }
  return test;
}

mutation(["hello", "Hello"]);
BoDaCat
@BoDaCat
Jun 24 2017 04:10
@johnnyosullivan missing a curly bracket maybe?
Zhangze
@NominationP
Jun 24 2017 04:14
I think it's too easy...what should I do
Moisés Man
@moigithub
Jun 24 2017 04:15
@logankuzyk = is for assigment
== or === is for comparison
also.. no shortcuts if (card = 2,3,4,5,6) { <-- wrong
u should do if (card===2 || card==3 etc etc) || :point_right: OR operator
@johnnyosullivan ur function need to return a boolean value... true or false
soo question is.. what is test return test <--
Matthew
@muzcmancoder91
Jun 24 2017 04:18
How should I go about.....
You should assign processArg to processed

var processed = 2;

function processArg(num) {
return (num + 3) / 5;
}

Kai Stullich
@kaistullich
Jun 24 2017 04:19
@logankuzyk why don't you just a switch statement? Didn't that exercise even say to use switch instead of if/else...?
Moisés Man
@moigithub
Jun 24 2017 04:19
@muzcmancoder91 compare with the example code above urs
Matthew
@muzcmancoder91
Jun 24 2017 04:20
There's an //Example and a //Setup
Instructions say to Call the processArg function with an argument of 7 and assign its return value to the variable processed.
I think I may be thinking too hard
Moisés Man
@moigithub
Jun 24 2017 04:22
on th e Example there are like 4 or 5 lines...
the Setup part is the one u need to change.. should have almost the same thing.. 4 or 5 lines
the structure is similar ... only the variables /function names changes
Johnny O'Sullivan
@johnnyosullivan
Jun 24 2017 04:24
@moigithub @kickinwing91 thanks
CamperBot
@camperbot
Jun 24 2017 04:24
johnnyosullivan sends brownie points to @moigithub and @kickinwing91 :sparkles: :thumbsup: :sparkles:
:cookie: 173 | @kickinwing91 |http://www.freecodecamp.com/kickinwing91
:star2: 3410 | @moigithub |http://www.freecodecamp.com/moigithub
Ateeq Khan
@ez12024
Jun 24 2017 04:25
im doing find the longest word in a string. I've completed it successfully, but i was wondering if i could take the successful code and then play around with it, find the shortest word instead and if so, where can i test the newly edited code?
Matthew
@muzcmancoder91
Jun 24 2017 04:25
@moigithub how do I assign processArg to processed?
Moisés Man
@moigithub
Jun 24 2017 04:25
@muzcmancoder91 paste the example part
im too lazy to open fcc n search whatever the challenge is
Matthew
@muzcmancoder91
Jun 24 2017 04:26

var changed = 0;

function change(num) {
return (num + 5) / 3;
}

changed = change(10);
That is the example.

Moisés Man
@moigithub
Jun 24 2017 04:26
changed = change(10); <--- compare ur code to that
changed is the variable... change is the function

ur code .. should have the same steps...

  1. var declaration var changed = 0;
  2. function declaration

    function change(num) {
     return (num + 5) / 3;
    }
  3. function calling and assign to some variable changed = change(10);

same steps.. only function/variables changes.. structure is the same... u only need to compare.. do something similar

ADay
@aday091
Jun 24 2017 04:29
I'm having some issues with the card counting function. Could someone take a look at my code

var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
     count = 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;
      break;
  }

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Kai Stullich
@kaistullich
Jun 24 2017 04:29
@aday091 remove case 7 - 9
KinderPreet Singh
@kindercappy
Jun 24 2017 04:30
@aday091 you should be betting if count is > 0
Matthew
@muzcmancoder91
Jun 24 2017 04:30
Thank you @moigithub
CamperBot
@camperbot
Jun 24 2017 04:30
muzcmancoder91 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3411 | @moigithub |http://www.freecodecamp.com/moigithub
KinderPreet Singh
@kindercappy
Jun 24 2017 04:31
And also count = count + 1. Change it to count++. Its the same thing.
Kai Stullich
@kaistullich
Jun 24 2017 04:32

And also count = count + 1. Change it to count++. Its the same thing.

Same for count = count - 1 you can do count--

ADay
@aday091
Jun 24 2017 04:32
@kindercappy that worked thank you!
CamperBot
@camperbot
Jun 24 2017 04:32
aday091 sends brownie points to @kindercappy :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @kindercappy |http://www.freecodecamp.com/kindercappy
glitz20
@glitz20
Jun 24 2017 04:39
can anyone help me with having border and some space between the <li> items?https://codepen.io/sabin20/pen/jwVmZd
Kai Stullich
@kaistullich
Jun 24 2017 04:46

@sabin20 When inspecting your li elements you have li elements nested inside of li. Like this:

<li id="output">
     <li>...</li>
     <li>...</li>
     <li>...</li>
     <li>...</li>
</li>

I think this may be your issue. Since the nested li do not have an id attribute you can target...

Markus Ivancsics
@ivancsicsmarkus
Jun 24 2017 04:46
@sabin20
margin-top:10px;
David Darby
@AzFalconer
Jun 24 2017 04:53
@sabin20 .borderlist { list-style-position:inside; border: 1px solid black; }
I'm trying get "title" from json api call... Shouldn't 'data.query.pages[0].title' work?
query:
    pages:
       18883158:
          pageid:    18883158
          ns:              0
          title:         "Harold Dorman"
Kai Stullich
@kaistullich
Jun 24 2017 04:56
@AzFalconer anyway you could post the whole response data? With curly brackets, square brackets etc..
Ateeq Khan
@ez12024
Jun 24 2017 04:57
what is arr?
David Darby
@AzFalconer
Jun 24 2017 04:58
@kaistullich {"batchcomplete":"","continue":{"grncontinue":"0.469999091765|0.469999236499|53040311|0","continue":"grncontinue||"},"query":{"pages":{"17501614":{"pageid":17501614,"ns":0,"title":"Alapaiwahine","extract":"<p><b>Alapa<span>\u02bb</span>iwahine</b> was a Princess of the Island of Hawaii and great-grandmother of King David Kal\u0101kaua and Queen Lydia Lili<span>\u02bb</span>uokalani. She was a <i>Naha</i> chiefess: the product of a rare father and daughter marriage uncommon in Hawaiian history.</p>..."}}}}
@ez12024 short for array
Kai Stullich
@kaistullich
Jun 24 2017 04:59
@AzFalconer format that copy/paste. Can't read that
M-C-Haker
@M-C-Haker
Jun 24 2017 05:00

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

function checkObj(checkProp) {
var result = "";
if (myObj.hasOwnProperty(checkProp)){
result = myObj[""];
}
else if (myObj.hasOwnProperty(checkProp)) {
result = "Not found";
}
return result;
}

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

can someone give me an idea of where I'm going wrong? thinking it's where i'm returing results?
Markus Ivancsics
@ivancsicsmarkus
Jun 24 2017 05:01
@M-C-Haker You return that perfectly.
@M-C-Haker However when it has a specific property (at if (myObj.hasOwnProperty(checkProp))) you should assign the property’s value to result.
@M-C-Haker Because it is a variable, you do it like:
result = myObj[checkProp];
Kai Stullich
@kaistullich
Jun 24 2017 05:02
@M-C-Haker you need to pass in checkProp into the myObj. So you need result = myObj[checkProp]
M-C-Haker
@M-C-Haker
Jun 24 2017 05:07
@kaistullich thanks getting there. how about the else if? nothing is showing up when i put "house" in to draw the "not found"
CamperBot
@camperbot
Jun 24 2017 05:07
m-c-haker sends brownie points to @kaistullich :sparkles: :thumbsup: :sparkles:
:cookie: 214 | @kaistullich |http://www.freecodecamp.com/kaistullich
M-C-Haker
@M-C-Haker
Jun 24 2017 05:09
@ivancsicsmarkus that's looks like my else if is wrong too though.. any advice?
@ivancsicsmarkus and thanks!
CamperBot
@camperbot
Jun 24 2017 05:09
:cookie: 640 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
m-c-haker sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
JJ
@Pominaus
Jun 24 2017 05:11

Hi all if I have a variable that I want to use as a flag to tell me if an object is already selected, what falsey value is best to store in it when no object selected? For example:

const someObject = {"key": "value"};
let selectedObj = false;
//... much code happens, then:
selectedObj = someObject;
// many more codes....
if (isSelected) {

Is false the best value to keep in there when no object selected?

Kai Stullich
@kaistullich
Jun 24 2017 05:12
@ @M-C-Haker You do not actually need another else if () statement. When you take a look at both, you actually wrote the same code twice. You only need:
else {
    return "Not Found";
}
M-C-Haker
@M-C-Haker
Jun 24 2017 05:12
@kaistullich you're right!
i just did this else if (myObj.hasOwnProperty(checkProp) === false){
result = "Not Found";
}
return result;
}
and it succeded and i releaised it 's the same as what you did above
Markus Ivancsics
@ivancsicsmarkus
Jun 24 2017 05:14
@Pominaus Just say: var isSelected; at the start of your code! Later you can select object with: isSelected = someObject; and deselect with: isSelected = undefined;. Or if you only need a true or false value, set it to true or false!
Kai Stullich
@kaistullich
Jun 24 2017 05:15
@M-C-Haker Like I said you don't need another else if() statement, because if .hasOwnProperty() returns false. Then you know there is no key with that name inside of the object. Therefore you can just do else
JJ
@Pominaus
Jun 24 2017 05:15
@ivancsicsmarkus Sorry, my example isn't clear, Say I wanted to then deselect the object, setting something to undefined is I understand bad practice, so I was just wondering if I should set it to false, or null I guess?
M-C-Haker
@M-C-Haker
Jun 24 2017 05:16
@kaistullich i agree but the following is not passing:

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

function checkObj(checkProp) {
var result = "";
if (myObj.hasOwnProperty(checkProp)){
result = myObj[checkProp];
}
else {
return "Not Found";
}
}
// Test your code by modifying these values
checkObj("gift");

Markus Ivancsics
@ivancsicsmarkus
Jun 24 2017 05:16
@ivancsicsmarkus set it to undefined, like I said. Did not I?
@Pominaus
| and deselect with: isSelected = undefined;
M-C-Haker
@M-C-Haker
Jun 24 2017 05:16
Thoughts/
Ogundele Olumide
@Lumexralph
Jun 24 2017 05:18
@M-C-Haker you have to retun it
@M-C-Haker return myObj[checkProp];
M-C-Haker
@M-C-Haker
Jun 24 2017 05:19
@Lumexralph dude thanks
CamperBot
@camperbot
Jun 24 2017 05:19
m-c-haker sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1996 | @lumexralph |http://www.freecodecamp.com/lumexralph
Kai Stullich
@kaistullich
Jun 24 2017 05:20
@Lumexralph took the words out of my mouth lol
Ogundele Olumide
@Lumexralph
Jun 24 2017 05:22
@kaistullich :laughing: good morning
Joseph
@revisualize
Jun 24 2017 05:24
Hello.
Markus Ivancsics
@ivancsicsmarkus
Jun 24 2017 05:24
@revisualize Hello!
Logan Kuzyk
@logankuzyk
Jun 24 2017 05:33
var count = 0;

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

  }

  if (count <= 0) {
    return count + " Hold";
  } else if (count > 0) {
    return count + " Bet";
  }
  //
mkay this is what i did know but again i feel like its really redundant
abraham anak agung
@padunk
Jun 24 2017 05:35
@logankuzyk you could combine it
case a:
case b:
result....
Kai Stullich
@kaistullich
Jun 24 2017 05:35

@logankuzyk remember that you can basically chain cases together if they return the same output. So you can reduce some code by doing:

switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
        count++;
        break;
}

And so on for all the other cases

Joseph
@revisualize
Jun 24 2017 05:51
@logankuzyk The things that individuals are outlining for you to do to correct the redundancy of your code. Are listed on the MDN Documentation for the switch.
KinderPreet Singh
@kindercappy
Jun 24 2017 05:51
and also count += 1; and count -= 1; Can be count++ or count--. It well add and subtract one @logankuzyk
glitz20
@glitz20
Jun 24 2017 05:52
@kaistullich so what should I do for the list?
Prashant Kumar
@kmrprashant
Jun 24 2017 05:52

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
if(contacts.hasownproperty(firstname) && (contacts.hasownproperty(prop))){
return contacts[likes];
else if(!contacts.hasownproperty(firstname))
return "No such contact";
}
// Only change code above this line
}

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

"Kristian", "lastName" should return "Vos"
"Sherlock", "likes" should return ["Intriguing Cases", "Violin"]
"Harry","likes" should return an array
"Bob", "number" should return "No such contact"
"Akira", "address" should return "No such property"
where i am wrong
Joseph
@revisualize
Jun 24 2017 05:53
@kmrprashant contacts is an array of elements. Each element in that array is an object.
@kmrprashant You're not accessing anything in the array correctly.
Prashant Kumar
@kmrprashant
Jun 24 2017 05:54
so how we procced
Joseph
@revisualize
Jun 24 2017 05:54
@kmrprashant How do you access an array element?
Prashant Kumar
@kmrprashant
Jun 24 2017 05:54
arrayname[]
Joseph
@revisualize
Jun 24 2017 05:55
@kmrprashant Let's say we have an array:
var contacts = [ "A" , "H" , "S" , "K" ];
How do you access "H"?
Kai Stullich
@kaistullich
Jun 24 2017 05:55
@sabin20 well I am not sure if that is even the issue....I just used the dev console and thought it was odd that li elements were nested inside of other li elements
Prashant Kumar
@kmrprashant
Jun 24 2017 05:55
contacts[1]
Joseph
@revisualize
Jun 24 2017 05:55
@kmrprashant Okay, maybe you should take that knowledge and re-read the instructions and look over the lesson again.
Prashant Kumar
@kmrprashant
Jun 24 2017 05:57
correct or not
Joseph
@revisualize
Jun 24 2017 05:57
@kmrprashant Your response to my question was correct.
Prashant Kumar
@kmrprashant
Jun 24 2017 05:58
so how do we procced in this question
Joseph
@revisualize
Jun 24 2017 05:58
@kmrprashant What are you supposed to be doing?
Prashant Kumar
@kmrprashant
Jun 24 2017 05:59

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

James Patrick Kerrane
@jamesjpk123
Jun 24 2017 05:59

Im in the challenge "Using Objects for Lookups", and I need help. Here are the conditions I am meeting and not meeting:

[✘] phoneticLookup("alpha") should equal "Adams"
[✘] phoneticLookup("bravo") should equal "Boston"
[✘] phoneticLookup("charlie") should equal "Chicago"
[✘] phoneticLookup("delta") should equal "Denver"
[✘] phoneticLookup("echo") should equal "Easy"
[✘] phoneticLookup("foxtrot") should equal "Frank"
[✘] phoneticLookup("") should equal undefined
[✔] You should not use case, switch, or if statements

My code is as follows:

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

// Only change code below this line

var alpha = {
"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");

I need help, because phoneticLookup is not working with alpha. Can someone help me know why this is happening?

Joseph
@revisualize
Jun 24 2017 05:59
@jamesjpk123 Your object isn't named correctly.
@jamesjpk123 Your function has declared and initialized the variable result to "". You are not modifying result and your function is returning result. Ergo, you're returning "". You need to modify result to be the value of the property from the object that you created.
James Patrick Kerrane
@jamesjpk123
Jun 24 2017 06:00
OK
let me try
Prashant Kumar
@kmrprashant
Jun 24 2017 06:01

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

James Patrick Kerrane
@jamesjpk123
Jun 24 2017 06:01
Thank you @revisualize!
CamperBot
@camperbot
Jun 24 2017 06:01
jamesjpk123 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4246 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 24 2017 06:01
@jamesjpk123 No problem.
pablovvb
@pablovvb
Jun 24 2017 06:02

can someone tell me what I'm doing wrong here?

function repeatStringNumTimes(str, num) {
// repeat after me
var repeat = "";
if (str > 0) {
for (i = 0; i < num; i++) {
repeat += str;
}
}

return repeat;
}

Joseph
@revisualize
Jun 24 2017 06:02
@pablovvb Depends... What are you doing? What are you trying to do?
pablovvb
@pablovvb
Jun 24 2017 06:04
also, how do I post it correctly?
Joseph
@revisualize
Jun 24 2017 06:04
@pablovvb if (str > 0) can you compare a string with a number?
pablovvb
@pablovvb
Jun 24 2017 06:05
ooooh there you go!! thanks, @revisualize !!!
CamperBot
@camperbot
Jun 24 2017 06:05
pablovvb sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4247 | @revisualize |http://www.freecodecamp.com/revisualize
Prashant Kumar
@kmrprashant
Jun 24 2017 06:10

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
if(contacts[0].firstName) && (contacts[0].prop){
return contacts[0].prop;

}
// Only change code above this line
}

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

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

Joseph
@revisualize
Jun 24 2017 06:10
@kmrprashant Okay. You have more than 1 array element.
Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
Abhishek Tiwari
@fillopfy
Jun 24 2017 06:12
@kmrprashant use nested ifs to see if contactname is same and then check property name with hasOwnProperty method
Joseph
@revisualize
Jun 24 2017 06:12
@kmrprashant Also: if(contacts[0].firstName) && (contacts[0].prop){ isn't how you write a correct if condition.
mithun
@dmithun
Jun 24 2017 06:13

function palindrome(str) {
// Good luck!

return str.toLowerCase().replace(/\s+/g) ? "false":"true";

}

palindrome("eye");

give some hints about this plz
Joseph
@revisualize
Jun 24 2017 06:14
@dmithun You need a bit more code than that.
@dmithun You're not removing all non-alphanumeric characters.
mithun
@dmithun
Jun 24 2017 06:14
is my format ok??????
Joseph
@revisualize
Jun 24 2017 06:15
@dmithun I wouldn't use a ternary op for that lesson.
mithun
@dmithun
Jun 24 2017 06:16
@revisualize thankx man for giving some advice :)
CamperBot
@camperbot
Jun 24 2017 06:16
dmithun sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4248 | @revisualize |http://www.freecodecamp.com/revisualize
ADay
@aday091
Jun 24 2017 06:23
I'm having some trouble using objects for lookups. I don't understand what is supposed to go after my lookup table.

// 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"
  };
  val = "charlie";
  lookup[val];
  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("charlie");
Kai Stullich
@kaistullich
Jun 24 2017 06:25
@aday091 You are almost there. You need need to now check whether that property exists or not and then return the result.
@aday091 use the .hasOwnProperty() method to check. It returns either true or false.
ADay
@aday091
Jun 24 2017 06:26
@kaistullich I'm super confused about the concept here, can you give any more detail?
ADay
@aday091
Jun 24 2017 06:28
@kaistullich I don't think I've learned the .hasOwnProperty() method yet
KinderPreet Singh
@kindercappy
Jun 24 2017 06:28
which challenge @aday091
ADay
@aday091
Jun 24 2017 06:28
"Using Objects for Lookups"
KinderPreet Singh
@kindercappy
Jun 24 2017 06:30
@shashank1999coder what have you done?
Ateeq Khan
@ez12024
Jun 24 2017 06:30
how would you describe the function of the "." in something like "return arr.map(function(group){
return group.reduce(function(prev, current) {
return (current > prev) ? current : prev;" ? Also, (prev, current)- what does this mean?
schizo99
@shashank1999coder
Jun 24 2017 06:30
plz help
Ateeq Khan
@ez12024
Jun 24 2017 06:30
Please. And thank you in advance :D
@shashank1999coder what do you need help with?
share it here
Kai Stullich
@kaistullich
Jun 24 2017 06:31
@aday091 Gotcha! I think that is in the next lesson. Well like I said you are close, you just need to store the value that is passed to lookup inside of the result variable
Nick Forlivio
@whackdev
Jun 24 2017 06:31
@aday091 the val=charlie and lookup[val] need to go
Ateeq Khan
@ez12024
Jun 24 2017 06:31
someone will come to help you
Nick Forlivio
@whackdev
Jun 24 2017 06:32
@aday091 you want to test it by calling the function not setting the variables to the values you want
Kai Stullich
@kaistullich
Jun 24 2017 06:32
@whackdev the val='charlie' needs to be removed, but the lookup[val] does not, this will be used.
PoXinh
@ptanhkhoa
Jun 24 2017 06:32
Hi, i'm doing excerside 216, anyone could show me what wrong with my code

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.lenghth; i++ ){
var lp = "firstName";
if (contacts[i][lp] == firstName) {
if (contacts[i].hasOwnProperty(prop)){
console.log(contacts[i].prop);
return;
}
else{
console.log("No such property");
return;
}
}
}
console.log("No such contact");
// Only change code above this line
}

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

Nick Forlivio
@whackdev
Jun 24 2017 06:32
@kaistullich correct. my point was not in the form it is.
ADay
@aday091
Jun 24 2017 06:33
@whackdev I understand that they need to go, I'm trying to figure out what goes in their place. I am painfully aware that those are terrible lines of code.
Nick Forlivio
@whackdev
Jun 24 2017 06:33
@aday091 not terrible
KinderPreet Singh
@kindercappy
Jun 24 2017 06:33
@ptanhkhoa you are just logging the property. you need to return it
Kai Stullich
@kaistullich
Jun 24 2017 06:33
@whackdev gotcha! :+1:
Ateeq Khan
@ez12024
Jun 24 2017 06:33
@ptanhkhoa contacts.length
Nick Forlivio
@whackdev
Jun 24 2017 06:33
@aday091 you just need to assign what you are returning to the righ thing you are very close
Ateeq Khan
@ez12024
Jun 24 2017 06:33
your spelling is wrong
PoXinh
@ptanhkhoa
Jun 24 2017 06:34
ah, thank, i fix it
but still not right
Prashant Kumar
@kmrprashant
Jun 24 2017 06:34

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(i=0; i<contacts.length; i++){
if(contacts[i].firstName==firstName && contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}
if(!contacts[i].hasOwnProperty(prop)){
return "No such property";
}

}
return "No such contact";
// Only change code above this line
}

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

Nick Forlivio
@whackdev
Jun 24 2017 06:34
@aday091 think about what you want to get out of the funtion and return that *hint you've already done it without assigning it to anything
Prashant Kumar
@kmrprashant
Jun 24 2017 06:35
now its correct
Nick Forlivio
@whackdev
Jun 24 2017 06:36
trying to figure out a cool design for this pomodoro timer assignment is killing me
I keep focusing on the example
Prashant Kumar
@kmrprashant
Jun 24 2017 06:36
@revisualize now its correct
Ateeq Khan
@ez12024
Jun 24 2017 06:37
@whackdev just do something simplistic yet elegant. Subtle yet fresh. Whatever first comes to mind. :P
Nick Forlivio
@whackdev
Jun 24 2017 06:37
@ez12024 I really like the circle concept but I want to do a progress bar instead of a fill just need to figure out how to do it
kirontoo
@kirontoo
Jun 24 2017 06:37
@whackdev maybe try sketching things out on paper before you code it
Ateeq Khan
@ez12024
Jun 24 2017 06:37
@ptanhkhoa @kindercrappy's right
Nick Forlivio
@whackdev
Jun 24 2017 06:38
@kirontoo that's a good idea I need to be better about that
ADay
@aday091
Jun 24 2017 06:38
@whackdev @kaistullich the Lesson didn't adequately present the concept you may as well be speaking gibberish... I don;t understand how to store the value passed to Lookup
Kai Stullich
@kaistullich
Jun 24 2017 06:38
@aday091 result = lookup[val]
Nick Forlivio
@whackdev
Jun 24 2017 06:39
@aday091 that's right
@aday091 you have to tell it what to return or what you want to get from the function
Ateeq Khan
@ez12024
Jun 24 2017 06:39
@kmrprashant which challenge is this?
Kai Stullich
@kaistullich
Jun 24 2017 06:39
@aday091 That was all you needed. Like we had mentioned you had it correct, you were just not storing the value in a variable.
Nick Forlivio
@whackdev
Jun 24 2017 06:39
@aday091 and just remove the val = "charlie"
Ravi Pachar
@ravipachar
Jun 24 2017 06:41
below code is working in firefox console but not working in FCC browser compiler .. any suggestion ?
function palindrome(str) {
  // Good luck!
  str.toLowerCase();
  str.replace(/[^a-z0-9]+/gi, '');
  console.log(str);

  return str;
}
Joseph
@revisualize
Jun 24 2017 06:43
@ravipachar The code that you posted doesn't work in the console.
Ravi Pachar
@ravipachar
Jun 24 2017 06:44
"AAAee**+++*aa".replace(/[^a-z0-9]+/gi, '').toLowerCase();
this i i have tried and returning "aaaeeaa"
ADay
@aday091
Jun 24 2017 06:44
@kaistullich Thanks, I still have to study why that worked. I don't understand why I'm having such trouble understanding these concepts. Am I crazy or are the lessons not super clear? Also, the variable names in the example and the lesson are poorly chosen and add to the confusion.
CamperBot
@camperbot
Jun 24 2017 06:44
aday091 sends brownie points to @kaistullich :sparkles: :thumbsup: :sparkles:
:cookie: 216 | @kaistullich |http://www.freecodecamp.com/kaistullich
Joseph
@revisualize
Jun 24 2017 06:45
@ravipachar I made the function call of palindrome("ASDFghjkl12345678999999990"); and I got back my input.
@ravipachar Okay.
@ravipachar You know strings are immutable. So, what you're doing doesn't actually do anything to mutate the string.
Ravi Pachar
@ravipachar
Jun 24 2017 06:46
@revisualize so using it directly in console or in function , does it make any diff
Kai Stullich
@kaistullich
Jun 24 2017 06:46
@aday091 I do have to agree with you that some of the variable names they have chosen could be much better.
Ravi Pachar
@ravipachar
Jun 24 2017 06:46
@revisualize okay so do i need to store it in diff string
right ?
Nick Forlivio
@whackdev
Jun 24 2017 06:46
@ravipachar try assigning the changes to a new variable
Joseph
@revisualize
Jun 24 2017 06:46
@ravipachar Or you could just reassign it back to the same string.
Ravi Pachar
@ravipachar
Jun 24 2017 06:46
yeah got it.. thanks
lemme try
@revisualize yeah got it working
silly mistakes
Joseph
@revisualize
Jun 24 2017 06:47
@ravipachar It's all good.
:D
schizo99
@shashank1999coder
Jun 24 2017 06:48

function nextInLine(arr, item) {
// Your code here
var nextInLine = item;

testArr.push();
testArr.shift();
console.log(testArr);
return item; // Change this line
}

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

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

Ravi Pachar
@ravipachar
Jun 24 2017 06:49
@revisualize :)
schizo99
@shashank1999coder
Jun 24 2017 06:52
plz help
Baibhav Gautam
@baibhavx
Jun 24 2017 06:53
Can I please get a review on my calculator. It seems to be working for most cases but has some problems such as text overflowing when the result is large.
https://codepen.io/baibhavx/full/XgaYPZ/
Joseph
@revisualize
Jun 24 2017 06:54
@shashank1999coder You're using testArr in your function when you shouldn't.
@shashank1999coder This line: var nextInLine = item; isn't actually doing anything because you're creating a variable that you don't use anywhere else.
@shashank1999coder I don't know why you're doing: var nextInLine = item; ... Why are you creating a variable with the same name as the function?
Ateeq Khan
@ez12024
Jun 24 2017 06:56
what is ES ? It says a concept was introduced in ES2015
Joseph
@revisualize
Jun 24 2017 06:57
@shashank1999coder return item; // Change this line You didn't actually change that line and you're still returning item you're not returning the element that was removed.
@ez12024 EcmaScript
Ateeq Khan
@ez12024
Jun 24 2017 06:57
@revisualize how do i learn this script? Which challenge section is this in
@ez12024 Are you learning JavaScript?
schizo99
@shashank1999coder
Jun 24 2017 06:59
@revisualize still not working i have deleted that variable
Joseph
@revisualize
Jun 24 2017 07:00
@shashank1999coder Just deleting that variable won't solve the challenge.
Ateeq Khan
@ez12024
Jun 24 2017 07:00
@revisualize uhmmmm...tbh, i skipped a few JS challenges. Temporarily.
It just felt overwhelming to begin with
i think it still does
schizo99
@shashank1999coder
Jun 24 2017 07:00
@revisualize then how to solve
Joseph
@revisualize
Jun 24 2017 07:01
@shashank1999coder Are you still using testArr inside of your function?
If you say: Yes. You won't solve the challenge.
Unless you write a bunch of useless code.
abraham anak agung
@padunk
Jun 24 2017 07:02
@baibhavx your percent is not working and i can write 0...., the design looks good
Baibhav Gautam
@baibhavx
Jun 24 2017 07:24
@padunk Thank you for letting me know. I'll do my best to take care of those issues. Cheers!
CamperBot
@camperbot
Jun 24 2017 07:24
baibhavx sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 364 | @padunk |http://www.freecodecamp.com/padunk
Kai Stullich
@kaistullich
Jun 24 2017 07:27
@baibhavx should be pretty easy to fix the 0.... probably just disable the button when clicked, and re-enable once they click multiply, addition, etc..
Baibhav Gautam
@baibhavx
Jun 24 2017 07:29
@kaistullich Thanks!
CamperBot
@camperbot
Jun 24 2017 07:29
baibhavx sends brownie points to @kaistullich :sparkles: :thumbsup: :sparkles:
:cookie: 217 | @kaistullich |http://www.freecodecamp.com/kaistullich
100ce
@100ce
Jun 24 2017 07:35
Hi Im stuck where I have done the lesson but one condition is not met where I am supposed to change myVar = myVar which I did and got the correct result (changing numerical value with ++)?
mithun
@dmithun
Jun 24 2017 07:37

function palindrome(str) {
// Good luck!

return str.replace(/\W/g, ''). toLowerCase().split('').reverse().join('')? "true":"false";

}

palindrome("eye");

i think my coding is ok
100ce
@100ce
Jun 24 2017 07:40
myVar = myVar should be changed
Pethaf
@Pethaf
Jun 24 2017 07:41
@dmithun Why are you using regex?
mithun
@dmithun
Jun 24 2017 07:44
i'm confused man @Pethaf
Pethaf
@Pethaf
Jun 24 2017 07:46
I would say, make the string lower case. And check if the reverse of the string is equal to the string.
Hassan McCutchen
@hmccutchen
Jun 24 2017 07:48
I'm confused as to why this code..
function nextInLine([arr], item) {
  // Your code here

  return arr;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
satisfies two of the four tasks?
i changed the return value to "arr" and had to add brackets to the arr value in the original function for this to work
Zhangze
@NominationP
Jun 24 2017 07:54
@hmccutchen arr is a variable , "arr" is a string value
Hassan McCutchen
@hmccutchen
Jun 24 2017 07:59
sorry i meant i changed the return value from item to the arr
arr and item are parameters one represents an array(arr) the other a number(item)
Pieter Stokkink
@forkerino
Jun 24 2017 08:46

@hmccutchen you are using array destructuring by placing the brackets around arr. It is a relatively new feature to JS, where you can do stuff like:

var [a,b] = [1,2,3,4,5]

a will be 1 and b will be 2.
You pass the tests where they test the return value of the function and the array was not empty.

Because arr will be the first element of the array being passed into the function
Ethan John White
@LopooNerd
Jun 24 2017 09:01
Hi I was doing the counting cards activity in java script, I eventually had to look at a solution but why doesn't this work? switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count += 1;
break;
it had to be count ++;
Pethaf
@Pethaf
Jun 24 2017 09:04
@LopooNerd You are missing the case where you have to decrement the count.
Ethan John White
@LopooNerd
Jun 24 2017 09:05
@Pethaf ?
no, I'm not putting the entire code here, I just want to know why "count += 1" is not the same as "count ++". I tried returning the value of 'count' to determine if the switch was working but it didn't. Not until I used '++'
Pethaf
@Pethaf
Jun 24 2017 09:07
@LopooNerd I just looked over my solution for the counting cards problem.
I use count++ as well.
  case 2:
   case 3:
   case 4:
   case 5:
   case 6:
        count++;
        break;
This is part of my solution.
So the problem is probably elsewhere.
Ethan John White
@LopooNerd
Jun 24 2017 09:11
yeah but how does count+= 1 affect the value of "count" over all? and how does 'count++' change it's value as well because from the way it was presented to me it seems that the two of them do not make the same answer. So how does either code affect the math?
I just want to know the math in it so I can apply it to new problems down the road
Pethaf
@Pethaf
Jun 24 2017 09:12
count += 1 is a shortcut for count = count+1
should be the same as count++
Ethan John White
@LopooNerd
Jun 24 2017 09:13
@Pethaf by the way how do you make the screen shot of code there? I had to copy paste mine which doesn't look as nice
Pethaf
@Pethaf
Jun 24 2017 09:13
@LopooNerd Start by typing ```(that is three backticks)
Then end by typing ```
Klaudijus
@klasta
Jun 24 2017 09:14
var a;
var a = 7;
var b;
var b = 7;
a = b;
Pethaf
@Pethaf
Jun 24 2017 09:14
Code
Klaudijus
@klasta
Jun 24 2017 09:14
whats wrong with this picture var a;
var a = 7;
var b;
var b = 7;
a = b;
Ethan John White
@LopooNerd
Jun 24 2017 09:15
code
abraham anak agung
@padunk
Jun 24 2017 09:15
@klasta nothing wrong. what are you trying to do?
Ethan John White
@LopooNerd
Jun 24 2017 09:16
var code = "Formatted";
Klaudijus
@klasta
Jun 24 2017 09:17
xD no seriously this is just beginning java script and i have no idea why i cant asighnt a to b var a;
var a = 7;
var b;
var b = 7;
a = b;
Ethan John White
@LopooNerd
Jun 24 2017 09:17
@Pethaf thanks
CamperBot
@camperbot
Jun 24 2017 09:17
lopoonerd sends brownie points to @pethaf :sparkles: :thumbsup: :sparkles:
:cookie: 348 | @pethaf |http://www.freecodecamp.com/pethaf
abraham anak agung
@padunk
Jun 24 2017 09:17
@klasta a and b have the same value of 7 try change it and you can see the difference
Klaudijus
@klasta
Jun 24 2017 09:20
@padunk they suppose to have the same value the problem is i cant assign them to one another
abraham anak agung
@padunk
Jun 24 2017 09:21
@klasta you already assign it with a=b
Klaudijus
@klasta
Jun 24 2017 09:23
@padunk the task says a should have a value of 7 b should have a value of 7 a should be assigned to b with = and i just cant asign them
abraham anak agung
@padunk
Jun 24 2017 09:24
@klasta what is the challenge url? you don't need to declare both value then
@padunk i tried this to var a = 7;
var b = 7;
var a = b;
abraham anak agung
@padunk
Jun 24 2017 09:27

@klasta this is the instruction:

Assign the value 7 to variable a.

Assign the contents of a to variable b.

you need to assign 7 to a and then assign it to b

var a = 7;
var b = a; // assign a to b
Klaudijus
@klasta
Jun 24 2017 09:28
@padunk ahhhh thank man :D
CamperBot
@camperbot
Jun 24 2017 09:28
klasta sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 365 | @padunk |http://www.freecodecamp.com/padunk
abraham anak agung
@padunk
Jun 24 2017 09:29
@klasta np
Abhinav Keshav
@shoutoutloud
Jun 24 2017 09:29

function titleCase(str) {
str=str.toLowerCase();
var arr = str.split(' ');

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

return arr.join(' ');
}

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

why is the above soln not working
Ronald T. Casili
@nvlled
Jun 24 2017 09:34
@shoutoutloud toUpperCase does not modify the string in place, you have to assign it to the variable
Abhinav Keshav
@shoutoutloud
Jun 24 2017 09:34
if i do
Wiktor
@victorcodecamp
Jun 24 2017 09:34

function palindrome(str) {
var reverseStr;
var palindromeStr;

//str = str.toLowerCase();
//str = str.replace( /[^a-z]/g, '' );

palindromeStr = str.toLowerCase().replace( /[^a-z]/g, '' ).split("");
//reverseStr = palindromeStr.reverse("");
reverseStr = str.toLowerCase().replace( /[^a-z]/g, '' ).split("").reverse("");

if (palindromeStr==reverseStr) {
return true;
} else if (palindromeStr !==reverseStr) {
return false;
}

}

palindrome("iS 5 tH $% iSa PaL#iNd RoMe?");

can somebody help me out? I have been stuck on this challenge for like an hour, I'm trying to figure it out but I don't know what's wrong. The challenge name is: "Checking for Palindromes". Any help would be greatly appreciated.

oh sorry, excuse me

function palindrome(str) {
  var reverseStr;
  var palindromeStr;

  //str = str.toLowerCase();
  //str = str.replace( /[^a-z]/g, '' );



  palindromeStr = str.toLowerCase().replace( /[^a-z]/g, '' ).split("");
  //reverseStr = palindromeStr.reverse("");
   reverseStr = str.toLowerCase().replace( /[^a-z]/g, '' ).split("").reverse("");

  if (palindromeStr==reverseStr) {
    return true;
  } else if (palindromeStr !==reverseStr) {
    return false;
  } 

}



palindrome("iS 5 tH $% iSa PaL#iNd RoMe?");
Abhinav Keshav
@shoutoutloud
Jun 24 2017 09:35
arr[i][o]=arr[i][0].toUpperCase
it still dont work
Ronald T. Casili
@nvlled
Jun 24 2017 09:35
@shoutoutloud it should be 0 not o
Abhinav Keshav
@shoutoutloud
Jun 24 2017 09:36
@nvlled lol yes
Ronald T. Casili
@nvlled
Jun 24 2017 09:36
well, you still have lot's of things wrong
Abhinav Keshav
@shoutoutloud
Jun 24 2017 09:36
@nvlled but it throws an error
@nvlled such as?
Ronald T. Casili
@nvlled
Jun 24 2017 09:37
toUpperCase()
Abhinav Keshav
@shoutoutloud
Jun 24 2017 09:37
@nvlled yes
@nvlled still error
Dan Couper
@DanCouper
Jun 24 2017 09:38
@victorcodecamp that particular challenge should include numbers
Ronald T. Casili
@nvlled
Jun 24 2017 09:38
@shoutoutloud what's the error? show me the code
Abhinav Keshav
@shoutoutloud
Jun 24 2017 09:39

@nvlled
function titleCase(str) {
str=str.toLowerCase();
var arr = str.split(' ');

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

return arr.join(' ');
}

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

Wiktor
@victorcodecamp
Jun 24 2017 09:39
@DanCouper it does, but the only thing I have wrong is that either I dont have all the requirements that return the value true, or i dont have all the requirements that return the value false.
Ronald T. Casili
@nvlled
Jun 24 2017 09:39
@shoutoutloud you have to do only arr[i] = ...
try figuring out first what to do
Dan Couper
@DanCouper
Jun 24 2017 09:40
@victorcodecamp
Your code will work if you don't remove the numbers
Abhinav Keshav
@shoutoutloud
Jun 24 2017 09:40
@nvlled TypeError: 0 is read-only
Wiktor
@victorcodecamp
Jun 24 2017 09:42
@DanCouper How would i do that?
@DanCouper and why only then?
Ronald T. Casili
@nvlled
Jun 24 2017 09:42
@shoutoutloud yes, you have to do arr[i] = r[i][0].toUpperCase() + __;
Abhinav Keshav
@shoutoutloud
Jun 24 2017 09:42
@nvlled ya i got it.Thanks
CamperBot
@camperbot
Jun 24 2017 09:42
shoutoutloud sends brownie points to @nvlled :sparkles: :thumbsup: :sparkles:
:cookie: 195 | @nvlled |http://www.freecodecamp.com/nvlled
Dan Couper
@DanCouper
Jun 24 2017 09:43
@victorcodecamp replace(/[^a-z]/, '') you are saying remove everything that isn't a-z. So you're removing the numbers, and consequently you won't pass the test because it's not asking you to remove numbers
Wiktor
@victorcodecamp
Jun 24 2017 09:45
replace( /[^a-z][^1-9]/g, '' ) like this? @DanCouper
blanke
@1314wan
Jun 24 2017 09:49
Can you speak Chinese?
Wiktor
@victorcodecamp
Jun 24 2017 09:50
How do I remove everything BUT numbers AND lowercase letters from a JS string?
Pieter Stokkink
@forkerino
Jun 24 2017 09:52
@victorcodecamp you can put everything inside the brackets: [^a-z0-9]
note that 0 is also a number
:P
Wiktor
@victorcodecamp
Jun 24 2017 09:54
in this line it says theres an error
palindromeStr = str.toLowerCase().replace([^a-z0-9], '').split("");
@forkerino
Long Nguyen
@longnt80
Jun 24 2017 09:58
@victorcodecamp what error?
@victorcodecamp your regexp need global flag though
Wiktor
@victorcodecamp
Jun 24 2017 09:59
@longnt80 It just doesnt work :/
Long Nguyen
@longnt80
Jun 24 2017 09:59
should be /[^a-z0-9]/
Pieter Stokkink
@forkerino
Jun 24 2017 09:59
@victorcodecamp I just gave you the inside of the regex, you need to format it the way you did above
Long Nguyen
@longnt80
Jun 24 2017 09:59
@victorcodecamp and add global flag /[^a-z0-9]/g
Wiktor
@victorcodecamp
Jun 24 2017 10:01
okay, but this code still doesnt work....

function palindrome(str) {
  var reverseStr;
  var palindromeStr;

  //str = str.toLowerCase();
  //str = str.replace( /[^a-z]/g, '' );



  palindromeStr = str.toLowerCase().replace(/[^a-z0-9]/g, '').split("");
  //reverseStr = palindromeStr.reverse("");
   reverseStr = str.replace(/[^a-z0-9]/g, '').toLowerCase().split("").reverse("");

  if (palindromeStr==reverseStr) {
    return true;
  } else if (palindromeStr !==reverseStr) {
    return false;
  } 

}



palindrome("iS 5 tH $% iSa PaL#iNd RoMe?");
Pieter Stokkink
@forkerino
Jun 24 2017 10:04
@victorcodecamp you cannot compare arrays
[] == [] is false
@victorcodecamp you have to compare elements. Or do a .join() to compare strings.
Wiktor
@victorcodecamp
Jun 24 2017 10:04
@forkerino so do i compare them using a for loop?
Yang Lu
@Luyang2016
Jun 24 2017 10:05

```
var myArray = [];

for(var i = 1; i < 10; i += 2) {
myArray.push(i);
}

Dan Couper
@DanCouper
Jun 24 2017 10:05
No, just join them, compare strings not arrays
Yang Lu
@Luyang2016
Jun 24 2017 10:05
Why can't I pass,it says i didnt use the for loop
Long Nguyen
@longnt80
Jun 24 2017 10:05
@victorcodecamp
palindromeStr = str.toLowerCase().replace(/[^a-z0-9]/g, '');

   reverseStr = str.toLowerCase().replace(/[^a-z0-9]/g, '').split("").reverse("").join('');
to lower case first then replace
Wiktor
@victorcodecamp
Jun 24 2017 10:07
wow i did it thanks @longnt80
CamperBot
@camperbot
Jun 24 2017 10:07
victorcodecamp sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 398 | @longnt80 |http://www.freecodecamp.com/longnt80
Wiktor
@victorcodecamp
Jun 24 2017 10:07
thanks @DanCouper
CamperBot
@camperbot
Jun 24 2017 10:07
victorcodecamp sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 802 | @dancouper |http://www.freecodecamp.com/dancouper
Wiktor
@victorcodecamp
Jun 24 2017 10:08
thanks @forkerino
CamperBot
@camperbot
Jun 24 2017 10:08
victorcodecamp sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2734 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jun 24 2017 10:08
@victorcodecamp :+1:
Dan Couper
@DanCouper
Jun 24 2017 10:08
@Luyang2016 need more context; you've written a loop that pushes odd numbers from 1 to 9 into an array, but without knowing what you're supposed to be doing cannot tell why you're not passing some challenge
@victorcodecamp 😊👍
Pieter Stokkink
@forkerino
Jun 24 2017 10:09
@victorcodecamp note that you could shorten @longnt80 's suggestion a bit:
palindromeStr = str.toLowerCase().replace(/[^a-z0-9]/g, '');

reverseStr = palindromeStr.split('').reverse().join('');
Yang Lu
@Luyang2016
Jun 24 2017 10:11
the task is to write a for loop that can add odd numbers 1 to 9 to myArray , that's all it says @DanCouper
Pieter Stokkink
@forkerino
Jun 24 2017 10:13
@Luyang2016 what is the challenge name again?
Long Nguyen
@longnt80
Jun 24 2017 10:13
@Luyang2016 it works
Pieter Stokkink
@forkerino
Jun 24 2017 10:15
@Luyang2016 I found it. If this doesn't pass, please copy paste all the code on the page.
Yang Lu
@Luyang2016
Jun 24 2017 10:16

@forkerino It's Iterate Odd Numbers With a For Loop in basic javascript

var myArray = [];

for(var i = 1; i < 10; i += 2) {
myArray.push(i);
}

Pieter Stokkink
@forkerino
Jun 24 2017 10:16
@Luyang2016 maybe refresh the page, because this code looks good.
If I copy paste it in FCC, it passes the tests
Yang Lu
@Luyang2016
Jun 24 2017 10:17
@forkerino Tried it many times already, if the code is good, maybe I'll just skip it
thanks anyways
Pieter Stokkink
@forkerino
Jun 24 2017 10:19
@Luyang2016 did you delete the example code?
that might cause the test to fail
Yang Lu
@Luyang2016
Jun 24 2017 10:19
Oh, yes.
Maybe
Pieter Stokkink
@forkerino
Jun 24 2017 10:19
Don't know why exactly, but usually it is best to leave it there
Yang Lu
@Luyang2016
Jun 24 2017 10:20
All right .
Pieter Stokkink
@forkerino
Jun 24 2017 10:20
:+1:
Yang Lu
@Luyang2016
Jun 24 2017 10:20
Thanks all of you.
Thayyeb salim
@Thayyebsalim
Jun 24 2017 10:27
Guys can someone help me with the profile lookup problem
pasha00786
@pasha00786
Jun 24 2017 10:29

Hello there, it seems that there is a bug as my code is returning the expected output i.e, 5 , but still there is a red cross on that given test.

alt

heroiczero
@heroiczero
Jun 24 2017 10:30
@pasha00786 which exercise? and lets see your code
@pasha00786 did you try refreshing the page?
Yeah, i already refreshed 5-7 times.
What should i do?
heroiczero
@heroiczero
Jun 24 2017 10:37
@pasha00786 personally i used the split and sort to split it into an array and sort it into highest length to lowest then return the first eleemnt of the array
ibtehaj raza
@ibtehajraza
Jun 24 2017 10:37
if(contacts[firstName].hasOwnProperty(prop))
return contacts[firstName]+contacts[firstName][prop] ;
is this statement is right
??
pasha00786
@pasha00786
Jun 24 2017 10:38
@heroiczero i don't find any logical mistake in my code as it is working as expected.
ibtehaj raza
@ibtehajraza
Jun 24 2017 10:39
??
heroiczero
@heroiczero
Jun 24 2017 10:39
@pasha00786 maybe put the var max inside the function. I dont see any mistake either in your coding
ibtehaj raza
@ibtehajraza
Jun 24 2017 10:40
anybody
heroiczero
@heroiczero
Jun 24 2017 10:40
@pasha00786 if nothing else works try copy and reset and paste
ibtehaj raza
@ibtehajraza
Jun 24 2017 10:40
the error is in hasOwnProperty
pasha00786
@pasha00786
Jun 24 2017 10:41
@heroiczero Woah! It worked. Thanks.
CamperBot
@camperbot
Jun 24 2017 10:41
pasha00786 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1416 | @heroiczero |http://www.freecodecamp.com/heroiczero
mitron6
@mitron6
Jun 24 2017 10:43
@ibtehajraza no
heroiczero
@heroiczero
Jun 24 2017 10:43
@ibtehajraza contacts is an array so you need a number like contacts[0] or contacts[1] so i would use a for loop to go through it
mitron6
@mitron6
Jun 24 2017 10:44
@ibtehajraza Normally something like if (contacts[i] == firstName) ...
heroiczero
@heroiczero
Jun 24 2017 10:44
@ibtehajraza currently you have contacts[firstName].hasOwnProperty(prop) you need something like contacts[0].hasOwnProperty(prop)
ibtehaj raza
@ibtehajraza
Jun 24 2017 10:45
oh okey
thanks
justarandominternetuser
@idonthavefriend
Jun 24 2017 10:53
hello there,so i'm doing the caesars cipher algorithm challenge and i'm having problem on making the charcode to the uncode version,can anybody help me to uncode them numbers ?
here's my code
function rot13(str) { // LBH QVQ VG!
  var array=[];
  for(var i=0;i<str.length;i++){
array.push(str.charCodeAt(i));
  }

return array.map(function(something){
  if(something>=65&&something<=90){
   if (something<78){
    return something+13;
   }else if(something>=78){
     return something-13;
   }
  }else{
    return something;
  }
 });

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
justarandominternetuser
@idonthavefriend
Jun 24 2017 10:55
so i want to uncode the numbers inside the array of variable array.
justarandominternetuser
@idonthavefriend
Jun 24 2017 11:09
@padunk lol i'm having difficulty to use from charcode
abraham anak agung
@padunk
Jun 24 2017 11:10
@idonthavefriend have u read the link i give?
justarandominternetuser
@idonthavefriend
Jun 24 2017 11:10
yes
but i still dont understand
abraham anak agung
@padunk
Jun 24 2017 11:10
Ok, maybe i can help
justarandominternetuser
@idonthavefriend
Jun 24 2017 11:11
can i just type array.fromCharCode(array)
or do i have to change the array to a string?
abraham anak agung
@padunk
Jun 24 2017 11:11
@idonthavefriend no, array don't have that methods. you have to iterate it
alpox
@alpox
Jun 24 2017 11:12
@idonthavefriend you can only do String.fromCharCode(charcode)
Keon Samuel
@keonsam
Jun 24 2017 11:12

nice

alpox
@alpox
Jun 24 2017 11:12
So you have to do this for each character and then put a string together from all those chars
abraham anak agung
@padunk
Jun 24 2017 11:12
hi @keonsam may i ask u about react?
Keon Samuel
@keonsam
Jun 24 2017 11:13
yes
abraham anak agung
@padunk
Jun 24 2017 11:13
@keonsam how to combine react and canvas? how can we write it on codepen?
Keon Samuel
@keonsam
Jun 24 2017 11:14
@alpox maybe you can help on that one.
alpox
@alpox
Jun 24 2017 11:16
@padunk you can put the canvas into the render function and draw into it as usual - first setup of the canvas in componentDidMount and interactive stuff through eventhandlers
abraham anak agung
@padunk
Jun 24 2017 11:17
@alpox so i don't need to add any library?
Keon Samuel
@keonsam
Jun 24 2017 11:25
mostly likely you will need to add the link in codepen setting.
abraham anak agung
@padunk
Jun 24 2017 11:31
ok, will try it. thanks @keonsam @alpox
CamperBot
@camperbot
Jun 24 2017 11:31
padunk sends brownie points to @keonsam and @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1173 | @alpox |http://www.freecodecamp.com/alpox
:cookie: 399 | @keonsam |http://www.freecodecamp.com/keonsam
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 11:32
@idonthavefriend
var myArray = [65,66,67];
String.fromCharCode.apply(null, myArray); // "ABC"
Robert Marić
@Mariciano95
Jun 24 2017 11:33

Hi guys I can't belive this works...


function titleCase(str) {
  var string = str.split(' ');
  var test = '';
  var final = '';
  for (var i = 0; i < string.length;i++) {
    var b = string[i].toLowerCase().split('');
    var a = b.shift().toUpperCase();
    test = a + b.join('');
    if (i < string.length - 1) {
      final += test + ' ';
    } else if (i === string.length - 1) {
      final += test;
    }
  }
  return final;
}


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

I know there is a better solution but I wanted it to do it my way.
Shoul I know try to simplify it, I know it can be done with 'chatAt'

Diego Mayer
@Chrono79
Jun 24 2017 11:34
@Mariciano95 you can do without the second split, try working with string methods, like slice/substr/substring
Stephen James
@sjames1958gm
Jun 24 2017 11:35
@Mariciano95 If you transform the word at string[i] to title case and put back into string[i] then you can join at the end.
string[i] = string[i].charAt(0).toUpperCase() + string[i].slice(1);
@Mariciano95 By using join, you avoid the extra work to add or not add a space at the end
justarandominternetuser
@idonthavefriend
Jun 24 2017 11:37
can anybody tell me why this code doesn't work:

function rot13(str) { // LBH QVQ VG!
  var array=[];
  for(var i=0;i<str.length;i++){
array.push(str.charCodeAt(i));
  }

 array.map(function(something){
  if(something>=65&&something<=90){
   if (something<78){
    return something+13;
   }else if(something>=78){
     return something-13;
   }
  }else{
    return something;
  }
 });
var string="";

for(var j=0;j<array.length;j++){
  string.fromCharCode(array[j]);
}
  return string;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 11:37
string.fromCharCode(array[j]);
It should be String (global)
Stephen James
@sjames1958gm
Jun 24 2017 11:37
@idonthavefriend fromCharCode is not a string function,
it is a String function
And you don't do anything with the function result regardless
String.fromCharCode
justarandominternetuser
@idonthavefriend
Jun 24 2017 11:38
then how to type the fromcharcode
alpox
@alpox
Jun 24 2017 11:38
@idonthavefriend the function map returns a new array but does not manipulate the old array. This means that the variable array still holds the old charcodes
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 11:38
@idonthavefriend
String.fromCharCode(65); // "A"
alpox
@alpox
Jun 24 2017 11:39
@idonthavefriend yea just make the S uppercase in String
@idonthavefriend and then append the new value it returns to the string variable
Stephen James
@sjames1958gm
Jun 24 2017 11:40
@idonthavefriend You could return String.fromCharCode(something+13) inside the map and eliminate a for loop
justarandominternetuser
@idonthavefriend
Jun 24 2017 11:41
@sjames1958gm hmmm
perhaps
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 11:41
@idonthavefriend map() does not change the original array
justarandominternetuser
@idonthavefriend
Jun 24 2017 11:44
@sjames1958gm okay,so i tried what you say about putting the fromcharcode in the map
and it worked
but for some reason i havent pass the challenge
Stephen James
@sjames1958gm
Jun 24 2017 11:45
@idonthavefriend :+1: You still have an array of strings you need to join()
Since you split at the beginning, generally a join is required if the output is a string
justarandominternetuser
@idonthavefriend
Jun 24 2017 11:45
maybe i need to add a string?
yes
i have join the array
but i havent pass the challenge @sjames1958gm
Stephen James
@sjames1958gm
Jun 24 2017 11:47
@idonthavefriend Show your code.
justarandominternetuser
@idonthavefriend
Jun 24 2017 11:47
function rot13(str) { // LBH QVQ VG!
  var array=[];
  for(var i=0;i<str.length;i++){
array.push(str.charCodeAt(i));
  }

 return array.map(function(something){
  if(something>=65&&something<=90){
   if (something<78){
    return String.fromCharCode(something+13);
   }else if(something>=78){
     return String.fromCharCode(something-13);
   }
  }else{
    return String.fromCharCode(something);
  }
 }).join(" ");


}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 11:48
join(""); instead of join(" ");
without any space
@idonthavefriend
justarandominternetuser
@idonthavefriend
Jun 24 2017 11:48
@saifsmailbox98 oh yeah
the space is already added inside the code
i forgot about that
Robert Marić
@Mariciano95
Jun 24 2017 11:49

@sjames1958gm

function titleCase(str) {
  var string = str.split(' ');
  var final = '';
  for (var i = 0; i < string.length;i++) {
    string[i] = string[i].charAt(0).toUpperCase() + string[i].slice(1).toLowerCase();
  }
  final = string.join(' ');
  return final;
}


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

Thanks, can you just elaborate what string[i].slice(1) does?

CamperBot
@camperbot
Jun 24 2017 11:49
mariciano95 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7875 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
justarandominternetuser
@idonthavefriend
Jun 24 2017 11:49
@saifsmailbox98 @sjames1958gm thx a lot guys
CamperBot
@camperbot
Jun 24 2017 11:49
idonthavefriend sends brownie points to @saifsmailbox98 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 569 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
:star2: 7876 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 24 2017 11:49
@Mariciano95 Just returns a new string taken from string[i] starting at index 1
Robert Marić
@Mariciano95
Jun 24 2017 11:50
@sjames1958gm I see, thanks :D @Chrono79 Ty for link
CamperBot
@camperbot
Jun 24 2017 11:50
mariciano95 sends brownie points to @sjames1958gm and @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: mariciano95 already gave sjames1958gm points
:star2: 4406 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 24 2017 11:50
:+1:
Stephen James
@sjames1958gm
Jun 24 2017 11:51
@Mariciano95 :+1:
@idonthavefriend Here is a way - stealing reduce from arrays
function rot13(str) { // LBH QVQ VG!
  var A = "A".charCodeAt(0);
  var Z = "Z".charCodeAt(0);
  var M = "M".charCodeAt(0);

  return [].reduce.call(str, function(a, b) {
    var code = b.charCodeAt();
    if (code >= A && code <= M) {
      code += 13;
    }
    else if (code > M && code <=Z) {
      code -=13;
    }
    return a + String.fromCharCode(code);
  }, "");

}
Stuhl
@Stuhl
Jun 24 2017 11:51
slice and splice do the same thing, except slice is returning a new array and isnt mutating the original one
Diego Mayer
@Chrono79
Jun 24 2017 11:52
@Stuhl he was talking about string's slice
justarandominternetuser
@idonthavefriend
Jun 24 2017 11:53
@sjames1958gm ok thx
CamperBot
@camperbot
Jun 24 2017 11:53
idonthavefriend sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: idonthavefriend already gave sjames1958gm points
Stuhl
@Stuhl
Jun 24 2017 11:53
Ah ok, didnt read the entire post
Diego Mayer
@Chrono79
Jun 24 2017 11:55
@Stuhl don't worry, he knows there is a slice for arrays too and the difference with splice now :+1:
Stuhl
@Stuhl
Jun 24 2017 12:00
warming words mate :D Im quite obsessed with fp atm and wanted to put my 2cents in
Diego Mayer
@Chrono79
Jun 24 2017 12:01
what is fp?
functional programming?
Stuhl
@Stuhl
Jun 24 2017 12:02
Yes ^^
Jianhao Tan
@jaanhio
Jun 24 2017 12:10

Hi all, not sure if this is the correct place to be posting this, forgive me its the wrong section. I am trying to load the movie titles and movie url onto the movie page but i cant seem to be able to retrieve the movie data. can anyone advise me on it?

movies.html

<table class="table table-striped">
  <thead>
    <th>Title</th>
    <th>URL</th>
  </thead>
  <tbody>
  <tr ng-repeat="movie in movies"> <!--angular component, telling it to repeat the tr element for every movie, every movie will be assigned a movie variable-->
    <!--need to provide scope to the movie variable via controller (movies.js) in order to load movies-->
    <td>{{ movie.title }}</td>
    <td>{{ movie.url }}</td>
  </tr>
  </tbody>
</table>

movies.js

'use strict';

/**
 * @ngdoc function
 * @name clientApp.controller:MoviesCtrl
 * @description
 * # MoviesCtrl
 * Controller of the clientApp
 */
angular.module('clientApp')
  .controller('MoviesCtrl', function ($scope) {
    /*this.awesomeThings = [ //replace awesomeThings with the movie object
      'HTML5 Boilerplate',
      'AngularJS',
      'Karma'
    ];*/

    $scope.movies = [
      {
        title: 'A New Hope',
        url: 'http://google.com'
      },
      {
        title: 'Iron Man',
        url: 'http://google.com'
      },
      {
        title: 'Thor',
        url: 'http://google.com'
      }
    ];
  });
Robert Marić
@Mariciano95
Jun 24 2017 12:14
function largestOfFour(arr) {
  // You can do this!
  var sum = 0;
  var lastSum = 0;
  var max = arr[0];
  var temp = 0;
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
      temp += arr[i][j];
    }
    sum = temp;
    temp = 0;
    if (sum > lastSum) {
      sum = lastSum;
      max = arr[i];
    }
  }
  return max;
}

largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]);
This happens if you don't read what is need from you, I thought I need to return the array which has the largest numbers...
Thayyeb salim
@Thayyebsalim
Jun 24 2017 12:16
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

  // Only change code below this line.
var i =0;
  return Math.floor(Math.random(i)*10);
}
this works but the challenge is not getting completed
Stephen James
@sjames1958gm
Jun 24 2017 12:18
@Thayyebsalim random doesn't take a parameter try removing the i variable
Stuhl
@Stuhl
Jun 24 2017 12:20
@Thayyebsalim Yes, the 0 isn't needed. Furthermore the 10 is useless too except u want a number between 0 and 9
Stephen James
@sjames1958gm
Jun 24 2017 12:20
@Thayyebsalim The test is checking for the string Math.random()*10 which i is breaking
@Stuhl The 10 is part of the challenge
Stuhl
@Stuhl
Jun 24 2017 12:21
@sjames1958gm Oh, is that in the basic javascript course ?
Stephen James
@sjames1958gm
Jun 24 2017 12:21
@Stuhl yes.
@Mariciano95 Do you understand now what to do?
Robert Marić
@Mariciano95
Jun 24 2017 12:23
@jaanhio You can try the main fourm, you may get more assistance there. If not, you can you use the r/learnprogramming subreddit. It's good place to get help for any problem in programming.
@sjames1958gm Yeah xD
@sjames1958gm Find the largest number in each subarray
Stephen James
@sjames1958gm
Jun 24 2017 12:23
@Mariciano95 :+1:
Thayyeb salim
@Thayyebsalim
Jun 24 2017 12:25
thank you guys @Stuhl @sjames1958gm
I thought it requires a variable
CamperBot
@camperbot
Jun 24 2017 12:25
thayyebsalim sends brownie points to @stuhl and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 167 | @stuhl |http://www.freecodecamp.com/stuhl
:star2: 7877 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
MarcusBA96
@MarcusBA96
Jun 24 2017 12:27
Hey guys. I can't figure out how to get past the "Using Objects for Lookups" challenge. This is my code:

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

// Only change code below this line
var lookup = {
"alpha": "Adamas",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};
result = lookup.val;

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

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

Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 12:28
@MarcusBA96 use the bracket notation when accessing property from variables.
lookup[val];
Stephen James
@sjames1958gm
Jun 24 2017 12:29
@MarcusBA96 Recall what you need when the property is in a variable, BTW not dot notation
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 12:30
@MarcusBA96 Also it should be"Adams"
Stuhl
@Stuhl
Jun 24 2017 12:30
Can someone explain why that is btw ?
Thayyeb salim
@Thayyebsalim
Jun 24 2017 12:30
switch case? @MarcusBA96
MarcusBA96
@MarcusBA96
Jun 24 2017 12:30
@saifsmailbox98 @sjames1958gm Thank you both very much :)
CamperBot
@camperbot
Jun 24 2017 12:30
marcusba96 sends brownie points to @saifsmailbox98 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 570 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
:star2: 7878 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Robert Marić
@Mariciano95
Jun 24 2017 12:32

@sjames1958gm


function largestOfFour(arr) {
  // You can do this!
  var max = 0;
  var maxArr = [];
  for (var i = 0; i < arr.length;i++) {
    for(var j = 0; j < arr[i].length; j++) {
      if (max < arr[i][j]) {
        max = arr[i][j];
      }
    }
    maxArr.push(max);
    max = 0;
  }
  return maxArr;
}

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

easy-peasy-lemon-squeezy

Any thoughts on the solution? :D

Thayyeb salim
@Thayyebsalim
Jun 24 2017 12:35
guys I have a doubt
Would n't Math.random()*15 give values btwn 1 and 15?
if so how is it done with a range
Like between 5 and 25
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 12:36
@Thayyebsalim it will give values from 0 to approx 14.9999 (but not 15)
Math.random() generates values from 0(inclusive) to 1 (exclusive) that is 0 to approx. 0.99999
Kevin
@kevinwr
Jun 24 2017 12:36

Hey all. Quick question.

if I have an array called uniArray with numbers in each element, and want to add 13 to the number if it's between 65 and 77, will having the statement uniArray[i] + 13; add 13 to that number? Yes, also this is in a for loop, so that's why I have i.

if(65 < uniArray[i] < 77 ){
            uniArray[i] + 13;
        }
Dan Couper
@DanCouper
Jun 24 2017 12:37
You add, then multiply (basically, you will set the lowest possible value then the highest
Thayyeb salim
@Thayyebsalim
Jun 24 2017 12:37
function randomRange(myMin, myMax) {

  return Math.floor(Math.random() * (myMax-myMin+1))+myMin;
Kevin
@kevinwr
Jun 24 2017 12:37
I don't need to set that equal to another variable or anything, do i?
Pethaf
@Pethaf
Jun 24 2017 12:37
@Thayyebsalim See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random in particular the section called Getting a random number between two values
Alexander Køpke
@alexanderkopke
Jun 24 2017 12:37
@Stuhl obj[variable] vs obj.variable <-- if we do obj.variable then we're trying to access the property name of variable on obj which would only work if we had this in the object: var obj ={ variable: "test"}; but let's say the variable holds a string of "hello". var variable = "hello"; and we do this obj[variable]; then it would look for this: var obj ={ hello: "world"}; So therefore if we're using a variable to access object properties we have to use [bracket] notation
PipsChips
@PipsChips
Jun 24 2017 12:37
Hello! I need help with my Twitch.tv project. I'm having trouble with my for loop, probably smth with socpes & hoisting. I'm confused and would like someone's help/explanation: https://codepen.io/PipsChips/pen/bRroBN
Robert Marić
@Mariciano95
Jun 24 2017 12:37
Thayyeb salim
@Thayyebsalim
Jun 24 2017 12:38
thank you guyys @Mariciano95 @saifsmailbox98 @Pethaf @DanCouper
CamperBot
@camperbot
Jun 24 2017 12:38
thayyebsalim sends brownie points to @mariciano95 and @saifsmailbox98 and @pethaf and @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 133 | @mariciano95 |http://www.freecodecamp.com/mariciano95
:cookie: 350 | @pethaf |http://www.freecodecamp.com/pethaf
:cookie: 571 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
:cookie: 803 | @dancouper |http://www.freecodecamp.com/dancouper
Dan Couper
@DanCouper
Jun 24 2017 12:39
@kevinwr note you can't make conditions like that (Python lets you do it, JS does not), you need to explicitly say eg greater than 65 and less than 77
uniarray[i] > 64 && uniarray[i] < 77
Denis Kharkovskyy
@messier-74
Jun 24 2017 12:42
@messier-74
Hi , can someone helps me to understand some detail in Advanced Challenge "Inventory Update" ?
var updatedArr = arr1.concat(arr2).reduce(function (a,b){
if (a[b[1]]){
a[b[1]] += b[0];
} else {
a[b[1]] = b[0];
}
return a;
}, {});
How is this line exactly works ?
if (a[b[1]]) ?
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 12:43
@PipsChips are you getting this?
noobs2ninjas - false
noobs2ninjas - false
noobs2ninjas - false
noobs2ninjas - false
noobs2ninjas - true
noobs2ninjas - true
noobs2ninjas - false
noobs2ninjas - false
PipsChips
@PipsChips
Jun 24 2017 12:43
@saifsmailbox98
yep
Diego Mayer
@Chrono79
Jun 24 2017 12:43
What's b[1]? Isn't the item's name?
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 12:44
as the json call is asynchronous the for loop goes on without waiting for the data to be received and moves to the next channel
@PipsChips
Diego Mayer
@Chrono79
Jun 24 2017 12:45
@messier-74 try your code on pythontutor, you'll see it running step by step
PipsChips
@PipsChips
Jun 24 2017 12:46
@saifsmailbox98
so, instead of using getJSON method, I shuold use $ajax method (due to possibility of using success condition)?
but, I think the problem is not in asynchronous behaviour of json call
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 12:48
@PipsChips you can even create a function that takes a channel name and appends it data
PipsChips
@PipsChips
Jun 24 2017 12:49
that would be my next step. First, I want to handle the data...
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 12:50
@PipsChips
var getJsonAll = function() {        
    for (var i = 0; i < names.length; i++) {
             myCall(names[i]);
    }

}

function myCall(name){

        console.log(name);
      $.getJSON("https://wind-bow.gomix.me/twitch-api/streams/" + name + "?callback=?", function(json) {
            console.log(json);            
            console.log(name);
            var isChannelLive = (json.stream !== null);        
                        $("#results").append("<li>" + name + " - " + isChannelLive + "</li>");    
        });
}
cretetion - false
habathcx - false
OgamingSC2 - true
storbeck - false
RobotCaleb - false
noobs2ninjas - false
ESL_SC2 - true
freecodecamp - false
Denis Kharkovskyy
@messier-74
Jun 24 2017 12:54
@Chrono79 Thank you so much! :)
PipsChips
@PipsChips
Jun 24 2017 12:55
@saifsmailbox98
Thank you!
CamperBot
@camperbot
Jun 24 2017 12:55
pipschips sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 572 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 12:55
@PipsChips :+1:
PipsChips
@PipsChips
Jun 24 2017 12:59
@saifsmailbox98
Though it works now, I still don't understand why do all the names get consoled before first getJSON call...?
Yash Wate
@yashtheastral
Jun 24 2017 13:02
Anyone out there could help me with the topic "Nesting for Loops"?
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 13:03
@PipsChips are they inside the callback function?
PipsChips
@PipsChips
Jun 24 2017 13:08
@saifsmailbox98
What do you mean? I don't understand, sorry...
Yash Wate
@yashtheastral
Jun 24 2017 13:11
can anyone help me with the code for "Nesting for loops"?
SaiChand Duppala
@saichandd
Jun 24 2017 13:12
@PipsChips because its asynchronous, the code doesnt wait for getJSON
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 13:12

@yashtheastral you can use for loops for different purposes but here i am going to explain to you how to access values from an array. If you have an array myArray= [6, 5, 2, 4] and you want to access all the values you can write a for loop as

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

myArray[i]; // this will run sufficient number of times to access all the values.
}

order in which elements are acccessed
myArray[0] // 6
myArray[1] // 5
myArray[2] // 2
myArray[3] // 4

But if you have an array of arrays

myNewArray = [ [1, 2, 6 ], [5, 7, 6 ], [8, 0 ,2 ] ]

you need nested loops like this

for(var i=0 ; i< myNewArray.length;i++){ // outer loop to access the the inner arrays

for(var k=0; k<myNewArray[i].length;k++){ //inner loop to access the inner values

myNewArray[i][k];

}

}

order in which elements are acccessed
myArray[0][0] // 1
myArray[0][1] // 2
myArray[0][2] // 6
myArray[1][0] // 5
myArray[1][1] // 7
myArray[1][2] // 6
myArray[2][0] // 8
myArray[2][1] // 0
myArray[2][2] // 2

@PipsChips both the console.logs should be in the function that manipulates the json data
:wave:
aRtoo
@artoodeeto
Jun 24 2017 13:15
goodmorning guys.
Yash Wate
@yashtheastral
Jun 24 2017 13:16
@saifsmailbox98 why did we use k < myNewArray[i].length instead of k < myNewArray.length again?
aRtoo
@artoodeeto
Jun 24 2017 13:17
have you worked with facebook dev ui?? if you do can you help me run this to share a quote. i dont have error but i wont pop up a window. heres the code:
  $('.btn-fb').on('click',function(){
      event.preventDefault();

      window.fbAsyncInit = function (){
        FB.ui({
        method: 'share',
        display: 'popup',
        href: 'https://facebook.com',
        }, function(response){
          $('.btn-fb').attr("href",href);
        });
      }
    })
@yashtheastral because u need to target the other index to get the data
@yashtheastral the inner loop will run until it hits false. then go back to outer loop.
PipsChips
@PipsChips
Jun 24 2017 13:23
@saifsmailbox98
Thank you for your effort. I understand outer/innder for loop (at least I think I do :))
CamperBot
@camperbot
Jun 24 2017 13:23
pipschips sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:warning: pipschips already gave saifsmailbox98 points
PipsChips
@PipsChips
Jun 24 2017 13:24
@saifsmailbox98
Oh, now I see that for loop explanation wasn't addressed to me :)
@saifsmailbox98
however, I wanted to show you this: https://codepen.io/PipsChips/pen/bRroBN
I've added another console.log after the getJSON method
PipsChips
@PipsChips
Jun 24 2017 13:31
myCall(names[0]) will execute all the statements inside it's scope, then, myCall(names[1]) will do the same, etc. Then, myCall(names[0]) will execute it's inner function (inside etJSON call), same for myCall(names[1]), etc.?
Jeffrey
@code4meplz
Jun 24 2017 13:42
so both arrays 'arr' and 'base' contain single lettter strings. if they match i would like to replace the one in 'arr' with one in 'base'(caesar cipher).but i seem to have some kind of error and the code thinks that arr[i] and base[j] match, although they dont.
 if(arr[i]==base[j]){

   arr.splice(arr[i],1,base[j-13]);
      }

//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 (i = 0; i < contacts.length; i++) {
  for (j = 0; j < contacts[i][prop].length; j++) {
  if (contacts[i] != firstName) {
    return "No such contact";
  }
    if (contacts[i][prop][j] != prop) {
      return "No such property";
    }
  }
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 13:59
@ddanielnp why are you using two for loops (nested)?
you can search for the right contact object with only a single for loop
Daniel Lim
@ddanielnp
Jun 24 2017 14:01
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
  if (contacts[i] != firstName) {
    return "No such contact";
  } if (contacts[i][prop] != prop) {
      return "No such property";
    }

}
```
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:01
contacts[i].firstName==firstName
@ddanielnp don't put the "No such contact"; inside the loop it will be executed for all the contacts if the name doesn't match
and return will break the further search
first search for the right contact with firstName then check if there is a property prop or not in that contact object, you can use hasOwnProperty() method for this purpose
:heavy_check_mark: Read the instructions again.
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:06
@ddanielnp
Here's an outline, if you follow it step-wise it'll help a great deal in telling you what to do or step you missed
1. you need a loop to pick each objects in the contacts array
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                  return the value of prop in the object
                 1.1.1.2  return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:09

@ddanielnp Some importants point related to the return statement.

  • The return statement ends function execution and specifies a value to be returned to the function caller.
  • The expression whose value is to be returned. If omitted, undefined is returned instead.

-mdn

makalohri
@makalohri
Jun 24 2017 14:11
@knrt10 thank you
CamperBot
@camperbot
Jun 24 2017 14:11
makalohri sends brownie points to @knrt10 :sparkles: :thumbsup: :sparkles:
:cookie: 437 | @knrt10 |http://www.freecodecamp.com/knrt10
TWoerner94
@TWoerner94
Jun 24 2017 14:17
Hey guys, looking for some help with the ES6 section of the beta
Basically I'm failing at the first task and idk if it's a bug or not
Jeffrey
@code4meplz
Jun 24 2017 14:17

so both arrays 'arr' and 'base' contain single lettter strings. if they match i would like to replace the one in 'arr' with one in 'base'(caesar cipher).but i seem to have some kind of error and the code thinks that arr[i] and base[j] match, although they dont.

 if(arr[i]==base[j]){

   arr.splice(arr[i],1,base[j-13]);
      }

any1?;)

TWoerner94
@TWoerner94
Jun 24 2017 14:17
'use strict';
let favorite = redNosedReindeer + " is Santa's favorite reindeer.";
let redNosedReindeer = "Rudolph";
let redNosedReindeer = "Comet";
This here throws up a bunch of error messages, like "use the function form of use strict"
But the assignment just says to replace all the var's with let's and to add the "use strict" at the top
UnkyKong
@UnkyKong
Jun 24 2017 14:18
function rot13(str) { // LBH QVQ VG!
  for(var i = 0; i < str.length; i++){
    num = str.charCodeAt(i);
    if(num >= 65 && num <= 91) {
      newNum = num - 13;

      if(newNum <= 65){
        newNum += 26;
      }
      newChar = String.fromCharCode(newNum);
    }
    str[i] = newChar;
  }
  return str;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
getting a TypeError cannot assign to read only property '0' of string
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:19
@UnkyKong you can't assign back the value of a character back to the same place of a string.
str[i] = newChar;
@UnkyKong you can try split-insert-join
Adanoch
@Adanoch
Jun 24 2017 14:20
Hey, I'm having trouble with the Celsius to Fahrenheit code. I know it's pretty easy, but I can't figure out how to put it in. Literally just started javascript
UnkyKong
@UnkyKong
Jun 24 2017 14:20
@saifsmailbox98 ok so I need to build a new string and not modify the old
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:20
@UnkyKong yes, strings are immutable,
UnkyKong
@UnkyKong
Jun 24 2017 14:20
ok cool , i'm sure i've read that somewhere. first time learning it lol :D
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:21
@Adanoch you tried anything?
UnkyKong
@UnkyKong
Jun 24 2017 14:21
learning from mistakes. yay!!
@saifsmailbox98 thank you
CamperBot
@camperbot
Jun 24 2017 14:21
unkykong sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 573 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:21
@Adanoch what have you done?
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:21
@UnkyKong don't worry, that's how we learn. :+1:
UnkyKong
@UnkyKong
Jun 24 2017 14:22
truth :D
Adanoch
@Adanoch
Jun 24 2017 14:22
Yeah, I'm trying to use something like
convertToF = celsius * (9/5) +32
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:23
@Adanoch convertToF is the function
you need to assign it to fahrenheit variable.
Adanoch
@Adanoch
Jun 24 2017 14:23
so, var fahrenheit = to start?
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:24
@Adanoch yes, you can use var if its already not defined.
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:24
@Adanoch just like @saifsmailbox98 converToF is the name of your function. you are to assign the formula to the fahrenheit variable declared in your function
Adanoch
@Adanoch
Jun 24 2017 14:24
Hey thanks, you guys are awesome.
alican karalar
@alicankaralar
Jun 24 2017 14:24
typescript + react help needed :(
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:25
@Adanoch
Example.

function addBoth(a,b){
var c;

c=a+b;

return c;
}
Adanoch
@Adanoch
Jun 24 2017 14:25
It worked, thank you very much
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:25
:+1:
Kelechi Chinaka
@ke1echi
Jun 24 2017 14:26
:wave: @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:26
@kelechichinaka Bro
just dey enter Lag, how're you?
Kelechi Chinaka
@ke1echi
Jun 24 2017 14:26
hapi wikend @Lumexralph
UnkyKong
@UnkyKong
Jun 24 2017 14:27
@saifsmailbox98 ```
function rot13(str) { // LBH QVQ VG!
  arr = str.split('');
  for(var i = 0; i < str.length; i++){
    num = arr[i].charCodeAt(0);
    if(num >= 65 && num <= 91) {
      newNum = num - 13;

      if(newNum < 65){
        newNum += 26;
      }
      newChar = String.fromCharCode(newNum);
    } else {
      newChar = arr[i];
    }
    arr[i] = newChar;
  }
  return arr.join('');
}

// Change the inputs below to test
rot13("LBH QVQ VG!");
Kelechi Chinaka
@ke1echi
Jun 24 2017 14:27
o rily, aw shagamu na @Lumexralph ..i de o bro
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:27
weekend full of activities no space to relax @kelechichinaka
UnkyKong
@UnkyKong
Jun 24 2017 14:27
got it
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:27
Osogbo
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:27
@UnkyKong YOU DID IT!
Kelechi Chinaka
@ke1echi
Jun 24 2017 14:28
Osogbo i meant @Lumexralph u mean party activities?
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:29
@kelechichinaka nope, none related.... just moving my stuffs from my former appartment
Kelechi Chinaka
@ke1echi
Jun 24 2017 14:29
to Osogbo? @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:29
@kelechichinaka nope :worried: ...ha!
Daniel Lim
@ddanielnp
Jun 24 2017 14:29
https://www.freecodecamp.com/challenges/profile-lookup can check my code whats wrong?
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
  if (contacts[i].firstName == firstName) {
    if (contacts[i].hasOwnProperty(prop)){
        return contacts[firstName].prop;
        } else {
        return "No such property";
        }
  }    return "No such contact";
}
}
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:30
@ddanielnp put return "No such contact"; outside the loop as you want to return "No such contact"; if the whole search is done
Kelechi Chinaka
@ke1echi
Jun 24 2017 14:30
ok..i fear o :smile: @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:30
@ddanielnp this return contacts[firstName].prop; and what @saifsmailbox98 said
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:31
@ddanielnp you access the prop use the bracket notation.
 return contacts[i][prop];
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:31
@kelechichinaka if i'll be staying longer than I thought I might ooo, buying stuffs against not be financially wise
Daniel Lim
@ddanielnp
Jun 24 2017 14:31
when should i use . ?
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:32
@ddanielnp return contacts[i][prop]
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:32
@ddanielnp ?
Daniel Lim
@ddanielnp
Jun 24 2017 14:32
when should i use dots to access
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:32
@ddanielnp it's when not to use dots
Kelechi Chinaka
@ke1echi
Jun 24 2017 14:33
ok @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:33
@ddanielnp when dealing with a variable, parameter, a string with space or beginning with a number too I think, don't use bracket notation
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:33
if you are going to use dot like this contacts[i].prop it will search for a property name prop and not what was passed to prop.
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:34
@kelechichinaka just seem to be making so many errors today, very tired
drove all the way from Osogbo
Kelechi Chinaka
@ke1echi
Jun 24 2017 14:35
lol..u need that rest @Lumexralph
Daniel Lim
@ddanielnp
Jun 24 2017 14:35
@Lumexralph @saifsmailbox98 got it thanks!
CamperBot
@camperbot
Jun 24 2017 14:35
ddanielnp sends brownie points to @lumexralph and @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 574 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
:star2: 1997 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:36
@kelechichinaka i'm waiting to get home, in the neighbourhood but not home
@ddanielnp :+1:
Kelechi Chinaka
@ke1echi
Jun 24 2017 14:37
ohkk..jus get that rest @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:37
@kelechichinaka thanks baba
CamperBot
@camperbot
Jun 24 2017 14:37
lumexralph sends brownie points to @kelechichinaka :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @kelechichinaka |http://www.freecodecamp.com/kelechichinaka
Daniel Lim
@ddanielnp
Jun 24 2017 14:39
@Lumexralph when dealing with a variable, parameter, a string with space or beginning with a number too I think, don't use bracket notation
kumquatfelafel
@kumquatfelafel
Jun 24 2017 14:40
they mean do use bracket notation
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:40
@ddanielnp use i'm sorry for the typo
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:40
@ddanielnp use bracket notation when dealing with a variable, parameter, a string with space or beginning with a number.
Daniel Lim
@ddanielnp
Jun 24 2017 14:40
ok found that odd
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:41
@ddanielnp i'm very tired, been making some silly errors, just not able to rest yet, sorry for the mistake
kumquatfelafel
@kumquatfelafel
Jun 24 2017 14:41
@ddanielnp good you're questioning. Shows you're paying attention. ;)
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:41
@kumquatfelafel :+1:
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:41
@Lumexralph don't worry too much, take some rest, you'll be fine.
Daniel Lim
@ddanielnp
Jun 24 2017 14:42
rest well too @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:42
@saifsmailbox98 thanks, chilling to get to my apartment, not home yet
CamperBot
@camperbot
Jun 24 2017 14:42
lumexralph sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 575 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:42
thanks guys .....i can't wait to jump on my bed
Chloe
@cguttweb
Jun 24 2017 14:43
I have a question I'm working my way through basic jQuery section on the map (I have dabbled in basics before) but why does this come before JavaScript? I've always been told to learn vanilla JavaScript first.
ZoDo85
@ZoDo85
Jun 24 2017 14:44
hi, everyone, i have tried this code on my own text editor and seems to work just fine, however it does not let me pass the exercise, any suggestions

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

// Only change code below this line

var myStr = "This is the first sentence. ";
myStr += "This is the second sentence. ";

Ogundele Olumide
@Lumexralph
Jun 24 2017 14:44
@cguttweb they don't want to overwhelm you early, they want you to be able to build stuffs with the little you get and as you dive deeper you learn more
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:45
@ZoDo85 please post the link to the challenge.
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:45
@ZoDo85 you have a space at the end of the second sentence
Chloe
@cguttweb
Jun 24 2017 14:45
@Lumexralph I can understand that and once you've learned a bit of JS jQuery syntax is a piece of cake in comparison
ZoDo85
@ZoDo85
Jun 24 2017 14:46
@saifsmailbox98 yes I have tried that
kumquatfelafel
@kumquatfelafel
Jun 24 2017 14:46
As @saifsmailbox98 says, get rid of space at end of second sentence. Have to be veeery careful about capitalization, spaces etc. String has to be exactly the same or they mark you wrong.
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:47
@ZoDo85 you need to remove that extra space from the end of the second sentence.
It's always good to copy-paste the strings/literals.
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:48
@cguttweb JQuery is also JS just a framework to do stuffs faster without going too deep into details, VanillaJS will require more and deeper and for beginners that might extinguish the fire of enthusiasm
ZoDo85
@ZoDo85
Jun 24 2017 14:48
@saifsmailbox98 Thank you very much mate....It did work
CamperBot
@camperbot
Jun 24 2017 14:48
zodo85 sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 576 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:48
@ZoDo85 :+1:
Chloe
@cguttweb
Jun 24 2017 14:49
@Lumexralph I agree although I quite like the challenge personally... but not everyone would I can appreciate that.
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:49
@cguttweb I'm a big VanillaJS fan though
Guderian Raborg
@hypercuber
Jun 24 2017 14:50

I need help on this problem: https://projecteuler.net/archives

function smallestNThatIsMultipleOfOneTo(r) { //r is biggest remeinder
  var n = r + 1;
  function inc(n) {
    for (var i = 1; i <= r; i++) {
      if (n % i !== 0) {

      }
    }
  }
  return inc(n);
}
console.log(smallestNThatIsMultipleOfOneTo(10));

Pretty peas please

I need something like
        n++;
        inc(n);
else {
return n
}
shamzingi
@shamzingi
Jun 24 2017 14:51
function areSameLength(str1, str2) {
if (str1 = str2) {
return true;
}
return false;
//return true if the two strings have the same length
//otherwise return false
//code here
}
what is the solution?
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:51
@cguttweb i think FCC Beta was created to meet some deficiency
Diego Mayer
@Chrono79
Jun 24 2017 14:51
@shamzingi Use == or === to compare
Chloe
@cguttweb
Jun 24 2017 14:51
@Lumexralph I have learnt the basics in both it just makes more sense to me to be able to use JS first then jQuery as not everyone would be able to use jQuery in projects but I'm still very much a beginner with a lot to learn.
Stephen James
@sjames1958gm
Jun 24 2017 14:51
@shamzingi User .length as well as ===
Chloe
@cguttweb
Jun 24 2017 14:51
whats FCC Beta? @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:51
@shamzingi use the length property of the string
kumquatfelafel
@kumquatfelafel
Jun 24 2017 14:52
@hypercuber could you link to the actual problem itself? That just links to archives. Don't know what problem wants you to do.
kumquatfelafel
@kumquatfelafel
Jun 24 2017 14:53
@Lumexralph I noticed it looks like they talk more about ecma6 or whatever it's called as well.
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:53
@cguttweb let's keep learning
@kumquatfelafel yeah it's important
kumquatfelafel
@kumquatfelafel
Jun 24 2017 14:53
agreed
Diego Mayer
@Chrono79
Jun 24 2017 14:54
@hypercuber pretty much the same as https://www.freecodecamp.com/challenges/smallest-common-multiple but with the first parameter being 1
Stephen James
@sjames1958gm
Jun 24 2017 14:54
@hypercuber you need some sort of loop calling inc ( and inc shouild return true/false
Ogundele Olumide
@Lumexralph
Jun 24 2017 14:54
@kumquatfelafel if you'll be learning React ES 6 knowledge will come in handy
shamzingi
@shamzingi
Jun 24 2017 14:55

function areSameLength(str1, str2) {
if (str1 = str2) {
return true;
}
return false;
//return true if the two strings have the same length
//otherwise return false
//code here
}

what am i doing wrong in the above problem?

Chloe
@cguttweb
Jun 24 2017 14:55
@saifsmailbox98 Thanks! @Lumexralph Yeah definitely I've dabbled in ES6 syntax too not gone into enough detail that's my issue not concentrating enough on one thing.
CamperBot
@camperbot
Jun 24 2017 14:55
cguttweb sends brownie points to @saifsmailbox98 and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1998 | @lumexralph |http://www.freecodecamp.com/lumexralph
:cookie: 577 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
shamzingi
@shamzingi
Jun 24 2017 14:57
?
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:57
@shamzingi if (str1.length === str2.length)
kumquatfelafel
@kumquatfelafel
Jun 24 2017 14:57
@shamzingi as stated, str1 = str2 is no good here. "=" is known as an assignment operator. It takes the value of whatever is on the right hand side, and stores it in left hand side. You need "==" or "===" which are known as comparison operators. They compare the right hand side and the left hand side, and if the same will return true, otherwise return false.
shamzingi
@shamzingi
Jun 24 2017 14:58
oh ok... so @kumquatfelafel , all i need is == or === in my statement?
Diego Mayer
@Chrono79
Jun 24 2017 14:59
@shamzingi and use .length property
kumquatfelafel
@kumquatfelafel
Jun 24 2017 14:59
@shamzingi also, .length
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 14:59

By using = you assign a value to something.

x = 1 //x now equals 1
x = 2 //x now equals 2

By using == you check if something is equal to something else. This is not strict

x == 1 //is x equal to 1? (False)
x == 2 //is x equal to 2? (True)
true == 1 //does the boolean value of true equal 1? (True)

By using === you check if something is equal to something else. This is also strict.

x === 1 //is x equal to 1? (False)
x === 2 //is x equal to 2? (True)
true === 1 //does the boolean value of true equal 1? (False)

What strict does, in case it wasn't clear there, is that it checks not only the equality of the two values, it compares the types of the two values too. Using == will try and convert one side of the expression to be the same type as the other. For example, boolean and integer. The boolean value for true is 1, therefore does 1 equal 1? Yes, true. When using strict however, it does not try and convert before doing the comparison, it checks if true equals 1, which is doesn't as they are two different data types, and returns false. - codecademy

@shamzingi
Yordan Zhelev
@yordanzhelevdev
Jun 24 2017 15:00
Hi guys. I need help with one challenge. I return the right values but can't pass the tests. Here is the challenge: https://www.freecodecamp.com/challenges/wherefore-art-thou
My code:
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var keys = Object.keys(source);

for (var i = 0; i < keys.length; i++) {
   for (var b = 0; b < collection.length; b++) {
      if (collection[b].hasOwnProperty(keys[i])) {
        if (collection[b][keys[i]] === source[keys[i]]) {
          arr.push(collection[b]);
        }
      }
    }
  }
   return JSON.stringify(arr);
}

whatIsInAName([{ "a": 1 }, { "a": 1 }, { "a": 1, "b": 2 }], { "a": 1 });
Lord Detex
@sammyoung007
Jun 24 2017 15:00
Hi everyone
kumquatfelafel
@kumquatfelafel
Jun 24 2017 15:01
even though if === returns true, it implies they are same length, many times this won'd give you the result you want. For example, "apple" and "sleep" are the same length, but are not the same. Since you are concerned with the length here, you want .length as well.
Diego Mayer
@Chrono79
Jun 24 2017 15:01
@YordanZhelev2 you're returning a string, return arr instead
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 15:01
The length property represents the length of a string. @shamzingi
str.length
shamzingi
@shamzingi
Jun 24 2017 15:03
thanks people
Yordan Zhelev
@yordanzhelevdev
Jun 24 2017 15:03
@Chrono79 How to return it as array?
shamzingi
@shamzingi
Jun 24 2017 15:04
im an M.D trying to switch to computers
Joseph
@revisualize
Jun 24 2017 15:04
Greetings.
shamzingi
@shamzingi
Jun 24 2017 15:04
bit of a challenge lol
Diego Mayer
@Chrono79
Jun 24 2017 15:04
@YordanZhelev2 return arr; but your code isn't ok
try whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "c": 2 });
Nefton
@neftonjin
Jun 24 2017 15:05
hi can anyone help me with the "Counting Cards" challenge
Joseph
@revisualize
Jun 24 2017 15:05
@neftonjin
Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
...
Then the function will 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.
...
...
Things to note: You should NOT be returning based on the value of the card. The value of card should only be adding or subtracting 1 from the global variable count.
The value of the global variable count is used to determine the return statement.
Yordan Zhelev
@yordanzhelevdev
Jun 24 2017 15:05
@Chrono79 alt
Yeah :D Thank you anyway
CamperBot
@camperbot
Jun 24 2017 15:05
yordanzhelev2 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4407 | @chrono79 |http://www.freecodecamp.com/chrono79
Lord Detex
@sammyoung007
Jun 24 2017 15:07
Pls can anyone help me Global scope and function challenge?
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 15:08
@sammyoung007 what have you tried?
Nefton
@neftonjin
Jun 24 2017 15:08
so this means i need to write a switch function
kumquatfelafel
@kumquatfelafel
Jun 24 2017 15:08
@neftonjin sounds good
Nefton
@neftonjin
Jun 24 2017 15:09
thanks i will try to see how this goes :D
Lord Detex
@sammyoung007
Jun 24 2017 15:10

this is my code var myGlobal = 10;
// Declare your variable here

function fun1() {
console.log(5); // Assign 5 to oopsGlobal Here

}
fun1();
// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

@saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 15:11
@sammyoung007 // Assign 5 to oopsGlobal Here
kumquatfelafel
@kumquatfelafel
Jun 24 2017 15:11
console.log(5) does not assign 5 to oopsGlobal
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 15:11
do you see the comment?
Lord Detex
@sammyoung007
Jun 24 2017 15:11
k. so the output is to be 5?
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 15:11
@sammyoung007 you need to assign the value to the variable there
and not log it to the log

Instructions

:heavy_check_mark: Using var, declare a global variable myGlobal outside of any function. Initialize it with a value of 10.

Inside function fun1, assign 5 to oopsGlobal without using the var keyword.

Lord Detex
@sammyoung007
Jun 24 2017 15:13
The first part is ok right?
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 15:14
@sammyoung007 yes
Lord Detex
@sammyoung007
Jun 24 2017 15:14
And I don't have to touch fun2
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 15:15
@sammyoung007 no
// Only change code above this line
Guderian Raborg
@hypercuber
Jun 24 2017 15:15
@kumquatfelafel @sjames1958gm @Chrono79 Thanks. It is this problem: https://projecteuler.net/problem=5
CamperBot
@camperbot
Jun 24 2017 15:15
hypercuber sends brownie points to @kumquatfelafel and @sjames1958gm and @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4408 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 298 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
:star2: 7879 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 15:16
@hypercuber isn't it LCM of n natural numbers?
Lord Detex
@sammyoung007
Jun 24 2017 15:17
function fun1() {
oopsGlobal(5);
console.log(); Could this be it? @saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 15:17
@sammyoung007 oopsGlobal = 5 ;
this assigns 5 to oopsGlobal
right to left
Lord Detex
@sammyoung007
Jun 24 2017 15:18
Thanks man @saifsmailbox98 . It's done
CamperBot
@camperbot
Jun 24 2017 15:18
sammyoung007 sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 578 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jun 24 2017 15:18
@sammyoung007 :+1:
Guderian Raborg
@hypercuber
Jun 24 2017 15:19
@saifsmailbox98 idk :(