These are chat archives for FreeCodeCamp/HelpJavaScript

9th
Apr 2017
Benji
@Benji-Leboe
Apr 09 2017 00:01
So does anyone know why my code works until I put in my "else" statements? As soon as I add the elses they override the ifs even when the if condition is true.
function lookUpProfile(firstName, prop){
// Only change code below this line
  var first = firstName;
  console.log("output",firstName, prop);
  for(i = 0; i < contacts.length; i++){
    if(contacts[i].firstName == first){
      if(contacts[i].hasOwnProperty(prop)){
        console.log(contacts[i][prop]);
        return contacts[i][prop];
      } else {
        console.log("noprop");
        return "No such property";
      }
    } else {
      console.log("nocont");
      return "No such contact";
    }
  }
// Only change code above this line
}
Keon Samuel
@keonsam
Apr 09 2017 00:04
@moigithub it says if either is less than zero so if a or b is less than zero.
Sindre Berge
@trust20
Apr 09 2017 00:07
what am i missing in this challange?
Instructions
Fix the function isLess to remove the if/else statements.

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

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

isLess(10,15) should return true
console: false
Moisés Man
@moigithub
Apr 09 2017 00:08
@trust20 check about COMPARISON operators....
and which one is less operator (see function name )
Sindre Berge
@trust20
Apr 09 2017 00:09
@moigithub thx :D
CamperBot
@camperbot
Apr 09 2017 00:09
trust20 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3025 | @moigithub |http://www.freecodecamp.com/moigithub
Francis Ngo
@francisngo
Apr 09 2017 00:10
does anyone know how to keep a count of each word in array
Riadh
@KWFE
Apr 09 2017 00:10
hey anyone here is familiar with node !
Francis Ngo
@francisngo
Apr 09 2017 00:11
for example: countWords('ask a bunch get a bunch'); there would be ask(1), a(2), bunch(2), etc.
Riadh
@KWFE
Apr 09 2017 00:11
@trust20 put the link of the test
Roxroy
@roxroy
Apr 09 2017 00:11
@KWFE , I have started that part. I can see if I can help. Hope it is an easy question.
Sergey Lukin
@not-a-cylon
Apr 09 2017 00:12
@Benji-Leboe your no such contact is being executed too early -- stick it outside the for loop.
Riadh
@KWFE
Apr 09 2017 00:12
@roxroy have you tried php as a back-end before !! or node is better
Ross
@rossauusa
Apr 09 2017 00:13
Storing Values with the Assignment Operator struggling with assigning a-b with = ??
Mychal Simka
@msimka
Apr 09 2017 00:13
@rossauusa What's the issue?
@KWFE Learning it right now on nodeschool.io :)
Roxroy
@roxroy
Apr 09 2017 00:13
@KWFE , I have more experience with php, but nodes due to npm makes somethings easier.
Sergey Lukin
@not-a-cylon
Apr 09 2017 00:14
@KWFE I have limited experience with both, but they seem about the same. PHP is easier to set up, though.
Moisés Man
@moigithub
Apr 09 2017 00:14
@francisngo u can use object or Map to keep track of ur words...
(both uses key:value pair)
if NOT exist start a new count with 1
if already exist .. increase count for that word
EK Azubuike
@ekazubuike
Apr 09 2017 00:15
I've completed three of the challenges related to using API's (Random Quotes, Weather, and Wikipedia Viewer), and I haven't used the new XMLHttpRequest(); AJAX methodology. I've been using $.getJSON("someurl", function(json){});. Are there some rules or best practices that govern when programmers use one or the other way of getting and rendering JSON data?
Francis Ngo
@francisngo
Apr 09 2017 00:15
would i check last item with next item?
arr[i] === arr[i + 1]
JAPerera
@JAPerera
Apr 09 2017 00:15
Has anyone completed the "Profile Lookup" challenge? I'm not really sure where to start.
Ryan Haire
@RyaanH
Apr 09 2017 00:16

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

firstName = contacts.firstName;
prop = contacts.prop;

if(contacts.hasOwnProperty[prop]){

return;

} else {

return "No such property";
}
if(contacts.hasOwnProperty[firstName]){

return;

} else {

return "No such contact";
}
// Only change code above this line
return firstName + ", " + prop;
}

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

why doesnt this work?
Ross
@rossauusa
Apr 09 2017 00:16
@msimka a should be assigned to b with = and i dont fully understand the question
Ryan Haire
@RyaanH
Apr 09 2017 00:16
it is the profile lookup in javascript
Moisés Man
@moigithub
Apr 09 2017 00:17
u need to check whats I value
cuz array elements start on 0 index.. (and ends on length -1 )
IF u use i+1 to check ur last element.. then ur i should end on length-2
else u will accessing unexistant elements @francisngo
Ross
@rossauusa
Apr 09 2017 00:17
@msimka Assign the contents of a to variable b the instructions aren't clear ?
EK Azubuike
@ekazubuike
Apr 09 2017 00:17
@RyaanH Double check the way you're using the .hasOwnPropety() method
dryo98
@dryo98
Apr 09 2017 00:17
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;
    console.log(count," Bet");
    break;
    case 7:
    case 8:
    case 9:
      console.log(count," Hold");
    break;  
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count = count-1;
    console.log(count, " Hold");
     break; 

}

  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');
how should I display the answer?
all i know is, that count is not an global variable
Ryan Haire
@RyaanH
Apr 09 2017 00:18
ok @ekazubuike thanks
CamperBot
@camperbot
Apr 09 2017 00:18
ryaanh sends brownie points to @ekazubuike :sparkles: :thumbsup: :sparkles:
:cookie: 271 | @ekazubuike |http://www.freecodecamp.com/ekazubuike
Sergey Lukin
@not-a-cylon
Apr 09 2017 00:18
@RyaanH contacts is not an object, it's an array of objects.
EK Azubuike
@ekazubuike
Apr 09 2017 00:18
@RyaanH Specifically, make sure you're using the right punctuation marks
dryo98
@dryo98
Apr 09 2017 00:18
but it askes me not to modify the code above
Moisés Man
@moigithub
Apr 09 2017 00:18
@dryo98 AFTER ur switch.. u need to evaluate count value
and RETURN count + " some string"
EK Azubuike
@ekazubuike
Apr 09 2017 00:18
Also, You have to return something. The computer doesn't know what you're asking it to return.
And you need to declare your variables.
Francis Ngo
@francisngo
Apr 09 2017 00:19
i am close but im not keeping any record of the count
function countWords(str) {
  // your code here
  var obj = {};
  var arr;
  arr = str.split(' ');
  for(var i = 0; i < arr.length - 2; i++) {
    var count = 0;
    if(arr[i] === arr[i + 1]){
      count++;
      obj[arr[i]] = count;
    } else {
      obj[arr[i]] = count;
    }
  }
  return obj;
}

var output = countWords('ask a bunch get a bunch'); 
console.log(output);
EK Azubuike
@ekazubuike
Apr 09 2017 00:20
@RyaanH The computer doesn't know what prop means if you don't first tell it that it's a new variable like this: var prop = ...
Luke Ciciliano
@LukeCiciliano
Apr 09 2017 00:20
Can I ask for help on the Iterate Through an Array with a For Loop
Not understanding why my code is returning a value of 0
var total = 0;
for (var a = 0; a < myArr.legth; a++){
total += myArr[a];
}
Moisés Man
@moigithub
Apr 09 2017 00:21
length misspell
Luke Ciciliano
@LukeCiciliano
Apr 09 2017 00:21
var myArr = [ 2, 3, 4, 5, 6];
Now I feel like a dumbass - thanks @moigithub
CamperBot
@camperbot
Apr 09 2017 00:21
lukeciciliano sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3026 | @moigithub |http://www.freecodecamp.com/moigithub
Riadh
@KWFE
Apr 09 2017 00:22
@not-a-cylon @roxroy @msimka THANK YOU GUYS
CamperBot
@camperbot
Apr 09 2017 00:22
kwfe sends brownie points to @not-a-cylon and @roxroy and @msimka :sparkles: :thumbsup: :sparkles:
:cookie: 382 | @not-a-cylon |http://www.freecodecamp.com/not-a-cylon
:cookie: 600 | @roxroy |http://www.freecodecamp.com/roxroy
:cookie: 307 | @msimka |http://www.freecodecamp.com/msimka
Roxroy
@roxroy
Apr 09 2017 00:22
@francisngo , you should move var count = 0; out of the loop. And you would return it as your anwer
Francis Ngo
@francisngo
Apr 09 2017 00:23
return it as my answer?
Ryan Haire
@RyaanH
Apr 09 2017 00:23
@ekazubuike prop is declared as an argument in the function
Moisés Man
@moigithub
Apr 09 2017 00:23
@francisngo u no need to compare "current" word with "next"
but if obj already have the "word" ( as key/prop )
Francis Ngo
@francisngo
Apr 09 2017 00:24
am i not comparing it in my if statement?
Moisés Man
@moigithub
Apr 09 2017 00:25

countWords('ask a bunch get a bunch');

obj have "ask" ???
if not.. obj.ask = 1 else obj.ask++

soo what would happen if u have

countWords('ask ask ask');

obj start empty {}
on first "ask"
obj.ask = 1
on second "ask"
obj.ask++ (will be 2)
on third "ask"
obj.ask++ (will be 3)
@francisngo

Ross
@rossauusa
Apr 09 2017 00:26
Been stuck on -
Storing Values with the Assignment Operator can someone help ?
dryo98
@dryo98
Apr 09 2017 00:28
ok how about now
var count = 0;

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

}

  return card;
  // 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');
Brian
@BrianCodes33
Apr 09 2017 00:28
function uniteUnique(...arr) {
  var args = [...arguments];
  var original = args[0];
  for (var i=1; i<args.length; i++) {
     for (var j=1; j<args[i].length; j++) {
       if (args[i][j] !== original[i])  {
            original.push(args[i][j]);
       }
     }        
   }
    return original;
  }
any ideas?
Moisés Man
@moigithub
Apr 09 2017 00:29
@dryo98 count variable is already declared as global variable..
U should NOT redeclare again
also.. AFTER ur switch.. u need to evaluate count variable.. and return count + hold or bet strings (check the instructions)
Benji
@Benji-Leboe
Apr 09 2017 00:29
@dryo98 you can use count += 1. Also I believe you want return statements and not console logs
Francis Ngo
@francisngo
Apr 09 2017 00:31
@moigithub
function countWords(str) {
  // your code here
  var obj = {};
  var arr = str.split(' ');
  var count = 0;
  for(var i = 0; i < arr.length; i++) {
    console.log(arr[i]);
    if(!obj[arr[i]]) {
      obj[arr[i]] = 1;
    } else{
      obj[arr[i]]++
    }
  }
  return obj;
}
Moisés Man
@moigithub
Apr 09 2017 00:33
:clap: @francisngo
Brian
@BrianCodes33
Apr 09 2017 00:33
can someone check out my cod
Moisés Man
@moigithub
Apr 09 2017 00:33
how u call ur function ? i forgot @BrianCodes33
(show some sample data)
Francis Ngo
@francisngo
Apr 09 2017 00:34
thanks @moigithub !!!!!
CamperBot
@camperbot
Apr 09 2017 00:34
francisngo sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3027 | @moigithub |http://www.freecodecamp.com/moigithub
Brian
@BrianCodes33
Apr 09 2017 00:34
function uniteUnique(...arr) {
  var args = [...arguments];
  var original = args[0];
  for (var i=1; i<args.length; i++) {
     for (var j=1; j<args[i].length; j++) {
       if (args[j] !== original)  {
            original.push(args[i][j]);
       }
     }        
   }
    return original;
  }

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
Moisés Man
@moigithub
Apr 09 2017 00:34
soo args is an array of arrays ? @BrianCodes33
var args = [...arguments]; what this do?
console.log(args) <-- to check
Brian
@BrianCodes33
Apr 09 2017 00:35
yes
returns [Array(3), Array(4), Array(2)]
Moisés Man
@moigithub
Apr 09 2017 00:36
if (args[j] !== original) {
that would do something like
if ([1,2,3] !== [1,2,3]) {
Brian
@BrianCodes33
Apr 09 2017 00:36
oh ok
Moisés Man
@moigithub
Apr 09 2017 00:36
but []==[] return false
Brian
@BrianCodes33
Apr 09 2017 00:36
so i need to check [1] and [1]
[2] i mean
i am confused
Moisés Man
@moigithub
Apr 09 2017 00:38
if u adding values to original [1, 3, 2]
i should point to second subarray [5, 2, 1, 4]
j should point to 5 (the FIRST value)
and check if 5 is on [1,2,3] and add it if no exist
then check if 2 is on [1,2,3,5]
then if 1 is on [1,2,3,5]
then check if 4 is on [1,2,3,5]
@BrianCodes33
i think keep track of those values can give u an idea..
dryo98
@dryo98
Apr 09 2017 00:39
ok i think im close now

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;
    return count+" Bet";
    break;
    case 7:
    case 8:
    case 9:
      return count+" Hold";
    break;  
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count-=1;
    return count+" Hold";
     break; 

}
return card;

  // 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');
Moisés Man
@moigithub
Apr 09 2017 00:40
@dryo98 u should NOT return inside the switch.. but AFTER the switch
AFTER evaluate count variable value
dryo98
@dryo98
Apr 09 2017 00:42
I'm so embarassed you did
Brian
@BrianCodes33
Apr 09 2017 00:42
@moigithub can you pm me?
dryo98
@dryo98
Apr 09 2017 00:43
now im bogged
Moisés Man
@moigithub
Apr 09 2017 00:43
soo u have something like
switch(card){
  // some cases
      // and increase or decrease count value
}

if (count > 0)  {
   // do something
} else {
  // do other thing
}
dryo98
@dryo98
Apr 09 2017 00:44
i don't wanna use if statements
or...should I have to?
Moisés Man
@moigithub
Apr 09 2017 00:44
u can use ternary operator
which is almost the same thing.. "inline if"
Ray
@RayRay97
Apr 09 2017 00:45

https://www.freecodecamp.com/challenges/word-blanks

Can someone help me with this exercise?

dryo98
@dryo98
Apr 09 2017 00:45
nevermind Ill use if statements
Ray
@RayRay97
Apr 09 2017 00:45
I can't quite understand what they want me to do.
David Amanze
@GodKingShogun
Apr 09 2017 00:46
i am doing the tic-tac-toe challenge. anyone know how to get my document ready function to reload again. i have tried windows.location.ready and load method but none of them worked
Moisés Man
@moigithub
Apr 09 2017 00:50
@RayRay97 ur function its called with 4 words big run quick dog
thse words are "mapped" to variables like myVerb myAdj etc
the task is to build a phrase and add some extra words/joiners/fillers
Ray
@RayRay97
Apr 09 2017 00:51
What should I store the sentence in?
David Amanze
@GodKingShogun
Apr 09 2017 00:51
@RayRay97 results if i remember correctly
Ray
@RayRay97
Apr 09 2017 00:52

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


  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
That's the whole code.
David Amanze
@GodKingShogun
Apr 09 2017 00:53
@RayRay97 look at what @moigithub said
Ray
@RayRay97
Apr 09 2017 00:53
I did.
David Amanze
@GodKingShogun
Apr 09 2017 00:53
@GodKingShogun do you remember the lesson on concatenating strings
@RayRay97
Ray
@RayRay97
Apr 09 2017 00:54
I understand that you have to make a sentence and use concatenation with with variables
but do I store the sentence in a different variable and then assign that variable to the result?
Moisés Man
@moigithub
Apr 09 2017 00:56
u can actually do everything on a single line
but if adding extra variable helps u.. go ahead @RayRay97
David Amanze
@GodKingShogun
Apr 09 2017 00:56
@RayRay97 okay so you are going to make a sentence using variables you are already given which are myNoun myAdjective and so forth and combine them with your own words in between each variable and assign it to results
Ray
@RayRay97
Apr 09 2017 00:58
I'm asking this because the result variable does not have a value but the comment says that you code below it.
David Amanze
@GodKingShogun
Apr 09 2017 00:58
@RayRay97 build upon this. result=myNoun+" yourwords " +"myAdjective"
Miguel Dorta
@ellipticaldoor
Apr 09 2017 00:59
How I can convert this callback into an es6 promise?
export const slugify = function (c, slug, _id, count, cb) {
    const final_slug = count ? `${ slug }_${ (count || '') }` : slug
    const search_slug = item => {
        if (item)
            // Checks if current document has already the current slug
            if (`${ item._id }` === `${ _id }`)
                cb(final_slug)
            else
                return this.slugify(c, slug, _id, (count || 0) + 1, cb)
        else
            cb(final_slug)
    }

    const that = c || this
    that.findOne({ slug: final_slug })
    .then(search_slug)
}
David Amanze
@GodKingShogun
Apr 09 2017 01:00
@ellipticaldoor i don't think i have worked with promises yet
@moigithub can you help me out with this question. i am doing the tic-tac-toe challenge. anyone know how to get my document ready function to reload again. i have tried windows.location.ready and load method but none of them worked
c0d0er
@c0d0er
Apr 09 2017 01:01
in code line 56-59, i tried to get location of meteorite through google json file, but my location variable is fired late due to getting json file, so now location is shown undefined, any idea to fix this? http://codepen.io/c0d0er/pen/RpzOZO?editors=0010
Keon Samuel
@keonsam
Apr 09 2017 01:01

function smallestCommons(arr) {
  arr.sort(function(a,b){
    return a-b;
  });
  var m= 1;
  var s=2;
  var range=[];
  var firstSCM =arr[0]*arr[1];
  var secondSCM =arr[1];
  var lCM =0;
  var isItEqual;
  for (var i=arr[0]+1;i<arr[1];i++){
    range.push(i);
  }
  do { 
    firstSCM = arr[0]*m;
    m++;
      for (var e=0; e<range.length;e++){
        if(firstSCM%range[e] !==0){
          isItEqual = "false";
          break;
        }
}  
    if(firstSCM==secondSCM && isItEqual=== "false"){
      secondSCM =arr[1] *s;
          s++;
    }
    else {
     lCM= firstSCM;
    }


}while (firstSCM <= secondSCM);
  return lCM;
}


smallestCommons([1,5]);
David Amanze
@GodKingShogun
Apr 09 2017 01:02
@c0d0er it isn't numbered when we look at it
c0d0er
@c0d0er
Apr 09 2017 01:03
@GodKingShogun dont understand
David Amanze
@GodKingShogun
Apr 09 2017 01:03
@keonsam keon you cant just post a long piece of code and not explain what you need help with
Keon Samuel
@keonsam
Apr 09 2017 01:04
Smallest Common Multiple
infinite loop at line 17
Moisés Man
@moigithub
Apr 09 2017 01:07
@GodKingShogun im not sure im understanding ur question
why u wanna reload again
David Amanze
@GodKingShogun
Apr 09 2017 01:08
@moigithub i created a tic tac toe game and when either the ai or the user wins i need the game to reload so you can play again
Moisés Man
@moigithub
Apr 09 2017 01:08
@c0d0er move ur div code inside ur json callback
c0d0er
@c0d0er
Apr 09 2017 01:09
@moigithub thanks!
CamperBot
@camperbot
Apr 09 2017 01:09
c0d0er sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3028 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Apr 09 2017 01:10
what if.. u use some global variables..
and make a function to reset those values when any1 wins ? @GodKingShogun
ie:
var gameBoard=[], whosTurn = "computer";

function reset(){
  gameBoard=[], whosTurn = "computer";
}

function checkWinner(){
    if (win) {
            alert("x won!");
          reset();
    }
}
Joseph
@martip07
Apr 09 2017 01:15
Hi guys
how are we supposed to return true of isLess(10, 15)
`function isLess(a, b) {

// Fix this code
return a === b;
}

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

Moisés Man
@moigithub
Apr 09 2017 01:19
@martip07 check this https://www.w3schools.com/js/js_comparisons.asp
and also check the function name on ur code
tambien hay un canal en español https://gitter.im/FreeCodeCamp/Espanol
aunque a estas horas ya no hay mucha gente
Joseph
@martip07
Apr 09 2017 01:20
:O
got it
gracias ;)
wunnyjamil
@wunnyjamil
Apr 09 2017 01:21
hello
Moisés Man
@moigithub
Apr 09 2017 01:21
:wave:
wunnyjamil
@wunnyjamil
Apr 09 2017 01:26
somebody here.. can help me to give some example how to do interactive website?
David Amanze
@GodKingShogun
Apr 09 2017 01:28
@moigithub that's a good idea. thanks
CamperBot
@camperbot
Apr 09 2017 01:28
godkingshogun sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3029 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Apr 09 2017 01:28
learn about html css and JS
check the freecodecamp.com/map
after u get ur front end certification u will know :) @wunnyjamil
HeebieGeeBee
@HeebieGeeBee
Apr 09 2017 01:30
that is a pretty general question
David Amanze
@GodKingShogun
Apr 09 2017 01:33
@moigithub you are literally a life save lol thanks again
CamperBot
@camperbot
Apr 09 2017 01:33
godkingshogun sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: godkingshogun already gave moigithub points
David Amanze
@GodKingShogun
Apr 09 2017 01:35
@moigithub now that i think about it my 600 lines of code could have been cut down to a sixth of that if i had used your method in other aspect of my tic tac toe game :worried:
Jack Lyons
@JackEdwardLyons
Apr 09 2017 01:38
hey guys, any Angular 4 coders here?
Manish Giri
@Manish-Giri
Apr 09 2017 01:39
<- react
HeebieGeeBee
@HeebieGeeBee
Apr 09 2017 01:39
fight
Daniel
@OldRainBlaze
Apr 09 2017 01:43

how is a switch statement writen
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val){
case 1:
val = "alpha";
break;
case 2:
val = "beta";
break;
case 3:
val = "gamma";
break;
case 4:
val = "delta";
break;

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

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

HeebieGeeBee
@HeebieGeeBee
Apr 09 2017 01:44
answer = "alp.... and so on.
not val
@OldRainBlaze
Daniel
@OldRainBlaze
Apr 09 2017 01:45
oh thanks mate @HeebieGeeBee
CamperBot
@camperbot
Apr 09 2017 01:45
oldrainblaze sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1220 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Ah, a typo on my part.
I knew I had it right :)
Mohamed Derhalli
@derhallim
Apr 09 2017 02:29
@jnelli glad we helped :'(
Ryan Haire
@RyaanH
Apr 09 2017 02:56

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

firstName = contacts.firstName;
prop = contacts.prop;

if(contacts.hasOwnProperty[prop]){

return;

} else {

return "No such property";
}
if(contacts.hasOwnProperty[firstName]){

return;

} else {

return "No such contact";
}
// Only change code above this line
return firstName + ", " + prop;
}

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

why does my code not work?
Mohamed Derhalli
@derhallim
Apr 09 2017 02:58
@RyaanH inside ur function, why are u changing the parameters values?
firstName = contacts.firstName;
prop = contacts.prop;
Mychal Simka
@msimka
Apr 09 2017 03:00

Anyone see a problem in my async function structure here? ``` var fs = require('fs');

var file = process.argv[2];

fs.readFile(file, countStuff);

function countStuff(err, myFile) {

if (err) throw err;

console.log(3);

);

```

var fs = require('fs');

var file = process.argv[2];

fs.readFile(file, countStuff);

function countStuff(err, myFile) {

    if (err) throw err;

    console.log(3);

);
Mohamed Derhalli
@derhallim
Apr 09 2017 03:00
@msimka am not familiar with these :'(
Ryan Haire
@RyaanH
Apr 09 2017 03:01
@derhallimso should i assign the values to variables?
Mohamed Derhalli
@derhallim
Apr 09 2017 03:02
@RyaanH no, u should just keep the parameters names as they are, and compare against them, for example:
function lookUpProfile(firstName, prop){
// Only change code below this line

if(contacts.hasOwnProperty[prop]){
return contacts[prop];
Ryan Haire
@RyaanH
Apr 09 2017 03:03
ahh okay
Moisés Man
@moigithub
Apr 09 2017 03:03
@msimka doesnt work ?? what node version u using ?
Mohamed Derhalli
@derhallim
Apr 09 2017 03:03
I am not familiar with this challenge, i skipped it, but some notes are.. u r having empty return, u change param names
Ryan Haire
@RyaanH
Apr 09 2017 03:04
contacts is also a array, so dot notation wouldnt work
Mohamed Derhalli
@derhallim
Apr 09 2017 03:04
u can do something like contacts[0].propertyName
if u loop, so contacts[i].propertyName
Ryan Haire
@RyaanH
Apr 09 2017 03:05
ok thanks you @derhallim
CamperBot
@camperbot
Apr 09 2017 03:05
ryaanh sends brownie points to @derhallim :sparkles: :thumbsup: :sparkles:
:cookie: 148 | @derhallim |http://www.freecodecamp.com/derhallim
Mychal Simka
@msimka
Apr 09 2017 03:05
@moigithub 7.6.0
James Hall
@James-H33
Apr 09 2017 03:06
@msimka Is there a closing curly brace for the countStuff function?
Moisés Man
@moigithub
Apr 09 2017 03:08
@James-H33 good catch :)
@msimka replace ur last ); for a }
James Hall
@James-H33
Apr 09 2017 03:10
:)
Mychal Simka
@msimka
Apr 09 2017 03:19
@moigithub oh boy that was a dumb mistake haha Thanks
CamperBot
@camperbot
Apr 09 2017 03:19
msimka sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3030 | @moigithub |http://www.freecodecamp.com/moigithub
Joseph
@revisualize
Apr 09 2017 03:20
Hey.
@RyaanH You know contacts is an array of objects
Abhijeet Singh
@abhijeetps
Apr 09 2017 03:20
Hey guys, need help.
I am building my portfolio. In that, I want to add a contact me thing. And I want it to actually work. Is there any Google Form Feeds or some API for this?
http://codepen.io/aps120797/full/GWaXdp
Joseph
@revisualize
Apr 09 2017 03:20
This message was deleted
Tono
@2hands10fingers
Apr 09 2017 03:21
Sup guys. I am totally stumped. I can't seem to figure out how to position my canvas in Matter.js
Is anyone familiar with its documentation?
Joseph
@revisualize
Apr 09 2017 03:21
@2hands10fingers You know, this is a chat room for people to get help with basic javascript.
Tono
@2hands10fingers
Apr 09 2017 03:22
Right, and I don't know if it's the fundamentals that is holding me back or not on this one
Joseph
@revisualize
Apr 09 2017 03:22
@2hands10fingers How to create variables, function declaration, how to use JS methods, solve algorithm challenges on freeCodeCamp.
@2hands10fingers I've personally never heard of Matter.js before.
Mychal Simka
@msimka
Apr 09 2017 03:23
@revisualize Mattel.js is toybuilding application
Tono
@2hands10fingers
Apr 09 2017 03:23
OK, and where else might I go? Stackoverflow and repo and documentation is a dead end atm
Joseph
@revisualize
Apr 09 2017 03:24
@msimka I'm a Barbie Girl in a Barbie World. Life is plastic, It's fantastic.
Mychal Simka
@msimka
Apr 09 2017 03:25
function var newToy extends mattel.transformer.autobot.optimusPrime;
woops no function at teh beginning won't work
or vice versa
@revisualize good song
Ryan Haire
@RyaanH
Apr 09 2017 03:48

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

if(contacts[prop]){
return contacts[prop];
} else {
return "No such property";
}

if(contacts[firstName]){
return contacts[firstName];
} else {
return "No such contact";
}
// Only change code above this line
return firstName + ", " + prop;
}

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

i keep changing my code but cant find anything that works
Joseph
@revisualize
Apr 09 2017 03:53
@RyaanH contacts is an Array
@RyaanH You're not even accessing the data correctly.
Ryan Haire
@RyaanH
Apr 09 2017 03:54

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

if(contacts[prop]){
return contacts[prop];
} else {
return "No such property";
}

Joseph
@revisualize
Apr 09 2017 03:54
@RyaanH That won't work either.
Ryan Haire
@RyaanH
Apr 09 2017 03:54
im not sure how to, i even went back to relook over looking up properties
Joseph
@revisualize
Apr 09 2017 03:55
@RyaanH length.contacts isn't correct.
Ryan Haire
@RyaanH
Apr 09 2017 03:55
lmao
mistake
what should i do? @revisualize
Joseph
@revisualize
Apr 09 2017 03:55
@RyaanH That solution is "more correct" than the one before.
Ryan Haire
@RyaanH
Apr 09 2017 03:56
ok
Joseph
@revisualize
Apr 09 2017 03:56

@RyaanH Gist by revisualize / FreeCodeCamp - Profile Lookup.js

We have an array of objects representing different people in our contacts lists.
Example: var contacts = [ { ... } , { ... } , { ... } , { ... } ];

@RyaanH I think you're trying to rush your solution. You aren't returning the correct stuff. You aren't accessing the data correctly
@RyaanH you had a for loop and you had contacts[i].firstName; ... That's the most correct part.
Ryan Haire
@RyaanH
Apr 09 2017 03:57
its pretty late for me, probably why
Joseph
@revisualize
Apr 09 2017 03:58
@RyaanH This challenge is taking ALL of the previous challenges and putting them into 1
@RyaanH Arrays, Objects, Loops, Ifs, Nested Ifs, return statements, Accessing object properties.
Ryan Haire
@RyaanH
Apr 09 2017 04:01
i am going to have look over them again
Joseph
@revisualize
Apr 09 2017 04:03
@RyaanH I linked a little re-write that I did of the instructions.
jokerrapeu
@jokerrapeu
Apr 09 2017 04:07
someone help me pls
the code var myStr ="FirstLine\n\SecondLine\\rThirdline";// Change this line
and the error = myStr should have encoded text with the proper escape sequences and no spacing.
help me to fix pls
need
hello
Mohamed Derhalli
@derhallim
Apr 09 2017 04:11
@jokerrapeu challenge name?
Ashish Inamdar
@Ashish-Inamdar
Apr 09 2017 04:13
@revisualize Can you help me Joseph
Joseph
@revisualize
Apr 09 2017 04:16
@jokerrapeu Thirdline is not spelled correctly.
Joseph
@revisualize
Apr 09 2017 04:21
@jokerrapeu Should be an L
Ryan Haire
@RyaanH
Apr 09 2017 04:23
@revisualize thanks for the write up
CamperBot
@camperbot
Apr 09 2017 04:23
ryaanh sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3701 | @revisualize |http://www.freecodecamp.com/revisualize
Owen Watkins
@ogre14t
Apr 09 2017 05:05

hey all im trying to reverse a string function reverseString(str) {
return str;
}

reverseString("howdy").split("").reverse().join("");

it has the desired effect, but is not completing teh objective.. any thoughts?

Manish Giri
@Manish-Giri
Apr 09 2017 05:06
@ogre14t why don't you put the code inside the function?
Owen Watkins
@ogre14t
Apr 09 2017 05:11
yep, you are awesome
Makrand R
@makrandr
Apr 09 2017 05:14
From where am I supposed to learn API's for building the random quote machine?
Charles Williams
@cfunkles
Apr 09 2017 05:15

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

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Jason Luboff
@JLuboff
Apr 09 2017 05:15
@Manish-Giri :wave:
Charles Williams
@cfunkles
Apr 09 2017 05:15
can anybody tell me why this code returns an array with all the same numbers?
Manish Giri
@Manish-Giri
Apr 09 2017 05:15
@JLuboff :wave:
@makrandr "google"
:wink:
Jason Luboff
@JLuboff
Apr 09 2017 05:16
@Manish-Giri no sleep again?
Manish Giri
@Manish-Giri
Apr 09 2017 05:16
@JLuboff yeah :sob:
trying to finish up this node course
Makrand R
@makrandr
Apr 09 2017 05:16
@Manish-Giri ah :sweat_smile:
Daniel
@OldRainBlaze
Apr 09 2017 05:16

var count = 0;

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

if (count > 0){
return "Bet";
}else{
return "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');

Jason Luboff
@JLuboff
Apr 09 2017 05:16
Which course?
Return count and bet or hold
Daniel
@OldRainBlaze
Apr 09 2017 05:17
Counting Cards
Manish Giri
@Manish-Giri
Apr 09 2017 05:17
@JLuboff "complete node web dev course first ed" by andrew mead
on udemy
Daniel
@OldRainBlaze
Apr 09 2017 05:18
return count + (count > 0 ? " Bet" : " Hold"); @JLuboff like this
Jason Luboff
@JLuboff
Apr 09 2017 05:18
@Manish-Giri any good? The course I did in udemy ended not being complete...
Ya that I believe would do it
Manish Giri
@Manish-Giri
Apr 09 2017 05:19
@JLuboff it's quite good, atho there's a second edition out now by the same name, you should get that
generally courses by andrew mead are quite good
I'm also doing his react course
Jason Luboff
@JLuboff
Apr 09 2017 05:19
DM me a link? I'm on mobile right now so I'll have it to look at later
Manish Giri
@Manish-Giri
Apr 09 2017 05:19
will do :+1:
Makrand R
@makrandr
Apr 09 2017 05:20
@Manish-Giri When I look at other people's projects on codepen I'm able to understand it but the syntax part ,is it cool if i take bits and pieces from different sources and make my project?
Manish Giri
@Manish-Giri
Apr 09 2017 05:20
@makrandr lol no don't do that
make your own
Makrand R
@makrandr
Apr 09 2017 05:21
@Manish-Giri ohkay :sweat_smile: let me try it out
first should i focus on functioning and then the styling ?
Jason Luboff
@JLuboff
Apr 09 2017 05:21
Man...another 40 minute until the race
Manish Giri
@Manish-Giri
Apr 09 2017 05:22
@makrandr I do the opposite
@JLuboff race?
Makrand R
@makrandr
Apr 09 2017 05:22
ohkay @Manish-Giri
Jason Luboff
@JLuboff
Apr 09 2017 05:22
@Manish-Giri Formula 1...china GP
Manish Giri
@Manish-Giri
Apr 09 2017 05:23
ah
@makrandr if your app has AJAX calls to fetch data, you can shove placeholder data/images in your html for styling purposes, then do the js..
Phillip Troutman
@troutman21
Apr 09 2017 05:28
Hi everyone. I'm working through some algorithms on a project outside of FCC and i was wondering if anyone could help me out. The directions are as follows:
Write a function once that accepts a callback as input and returns a function. When the returned function is called the first time, it should call the callback and return that output. If it is called any additional times, instead of calling the callback again it will simply return the output value from the first time it was called.

``
function addByTwo(x){
console.log(2+x);
}

function once(func) { // func = addByTwo.
var counter = 0;
var firstvalue;
function returnedFunc(num){
if (counter === 0){ //has access to counter,first value through the Closure.
counter++;
firstValue = func(num);
}
else{
return firstValue;
}
}
return returnedFunc;
}

var onceFunc = once(addByTwo);

// UNCOMMENT THESE TO TEST YOUR WORK!
console.log(onceFunc(4)); //should log 6
console.log(onceFunc(10)); //should log 6
console.log(onceFunc(9001)); //should log 6
``

Manish Giri
@Manish-Giri
Apr 09 2017 05:29
@troutman21 I just did that one a few days back
I used localStorage
Phillip Troutman
@troutman21
Apr 09 2017 05:30
What do you mean? @Manish-Giri
how do you post the actual code in the chat room? i thought you use ticks?
Manish Giri
@Manish-Giri
Apr 09 2017 05:34
@troutman21 3 ticks
PtLeon
@PtLeon
Apr 09 2017 05:34
hey guys, right now i'm in the "counting cards" challenge. I have achieved the goal already but i don't know why only the last function would actually display. could anybody told me that? thanks do much.
Leafie Tutoring
@www-leafie-io
Apr 09 2017 05:36
@PtLeon Don't understand the question
PtLeon
@PtLeon
Apr 09 2017 05:37

var count = 0;

function cc(card) {
// Only change code below this line
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
break;
}
if (count > 0) {
return count + " Bet";
}
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');
the last line use that function for 5 times, there should be like 5 results
bilaal-s
@bilaal-s
Apr 09 2017 05:38
Hello. For the "Trigger Click Events with Jquery challenge, why can I not use addEventListener instead of "on"?
<script>
  $(document).ready(function() {
    // Only change code below this line.
    //Used addEventListener instead of "on"
    $("#getMessage").addEventListener('click', function() {

    });
    // Only change code above this line.
  });
</script>
PtLeon
@PtLeon
Apr 09 2017 05:39
why the note said that "only the last will dis play"
Dalton Escoe
@Alenero129
Apr 09 2017 05:39
Hey guys, can hasOwnProperty function return more than 1 value?
bilaal-s
@bilaal-s
Apr 09 2017 05:40
@Alenero129 no, only true and false
Dalton Escoe
@Alenero129
Apr 09 2017 05:40
Thanks @bilaal-s
CamperBot
@camperbot
Apr 09 2017 05:40
alenero129 sends brownie points to @bilaal-s :sparkles: :thumbsup: :sparkles:
:cookie: 191 | @bilaal-s |http://www.freecodecamp.com/bilaal-s
PtLeon
@PtLeon
Apr 09 2017 05:41
@www-leafie-io the last line use that function for 5 times, there should be like 5 results,why the note said that "only the last will dis play"
Leafie Tutoring
@www-leafie-io
Apr 09 2017 05:42
@bilaal-s you can't use addEventListener because you selected with jQuery and addEventListener in that way is not a valid jquery function
@bilaal-s it's basically like writing half of a statement in ruby and the last half in javascript or something. It doesn't work
bilaal-s
@bilaal-s
Apr 09 2017 05:43
@www-leafie-io I see, okay, that gives me something to think about, thanks! how would I go about it?
CamperBot
@camperbot
Apr 09 2017 05:43
bilaal-s sends brownie points to @www-leafie-io :sparkles: :thumbsup: :sparkles:
:cookie: 5 | @www-leafie-io |http://www.freecodecamp.com/www-leafie-io
Leafie Tutoring
@www-leafie-io
Apr 09 2017 05:43
@bilaal-s you have to choose between jquery or vanilla js for any given line of code
@bilaal-s you cant mix 2 different lanuages together on the same line
bilaal-s
@bilaal-s
Apr 09 2017 05:44
@www-leafie-io Ah I see, big blunder haha
Leafie Tutoring
@www-leafie-io
Apr 09 2017 05:44
@bilaal-s everyone makes that mistake. you're doing a good job :D
DMXGeo
@DMXGeo
Apr 09 2017 05:48
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if(myObj.hasOwnProperty(checkProp))
    return myObj[checkProp];
  else
    return "Not Found";
}

// Test your code by modifying these values
checkObj("gift");
myObj.checkprop ?
for returning the value of the property, why does dot notation not work, but bracket notation does
Leafie Tutoring
@www-leafie-io
Apr 09 2017 05:50
@DMXGeo because when you use dot notation it thinks that after the dot is just a key
@DMXGeo when you use bracket notation it lets you use the variable
DMXGeo
@DMXGeo
Apr 09 2017 05:51
Ohh okay, thank youu
Leafie Tutoring
@www-leafie-io
Apr 09 2017 05:51
@DMXGeo :D
bilaal-s
@bilaal-s
Apr 09 2017 05:59
This also does not seem to pass the challenge:
<script>
  $(document).ready(function() {
    // Only change code below this line.
    function addEventLogger(elt) {
      elt.addEventListener('click', function() {

      })
    }
    const getMessage = document.querySelector('#getMessage');
    addEventLogger(getMessage);
    // Only change code above this line.
  });
</script>
Mohamed Derhalli
@derhallim
Apr 09 2017 06:05
@bilaal-s what's the name of the challenge?
hp77-creator
@hp77-creator
Apr 09 2017 06:08
anyone there who can help me in the algorithms section
?
Jor
@joreyesl
Apr 09 2017 06:09
@hp77-creator yea theres ppl here
hp77-creator
@hp77-creator
Apr 09 2017 06:11
@joreyesl I am stuck at check for the palindromes.. wrote this code: function palindrome(str) {
str = str.toLowerCase();
var d = str.replace(/[0-9]/g, '');
var count = 1;
var b = d.split(" ");
var c = b.reverse();
for(var i = 0; i < b.length ; ++i){
if(b[i] == c[i]){
count++;
}
else{
count = 0;
}
}
if(count == b.length){
return true;
}
else{
return false;
}
}
can you tell me what Am missing or what I did wrong...
Markus Kiili
@Masd925
Apr 09 2017 06:11
@hp77-creator You need to remove anything that is not a letter or a number. Are you doing it?
@hp77-creator If you loop and compare, you don't need to split or reverse anything. Choose one of those ways.
hp77-creator
@hp77-creator
Apr 09 2017 06:13
@Masd925 I did with replace but I think am replacing numbers too.... Unable to understand how to remove non alpha numerals from string..
Markus Kiili
@Masd925
Apr 09 2017 06:13
@hp77-creator You could look at metacharacters \W and \w.
hp77-creator
@hp77-creator
Apr 09 2017 06:14
@Masd925 tried without split or reverse i.e only by loop but still stuck.. I think my logic is bad..
bilaal-s
@bilaal-s
Apr 09 2017 06:15
@derhallim Trigger Click Events with Jquery
Markus Kiili
@Masd925
Apr 09 2017 06:15
@hp77-creator After lowercasing and replacing you can: reverse the string and compare with the original, or compare the first and last characters and return false if they are not equal. If they are compare the second to second to last etc...
hp77-creator
@hp77-creator
Apr 09 2017 06:17
thanks... @Masd925 .. gonna try it..
CamperBot
@camperbot
Apr 09 2017 06:17
hp77-creator sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3809 | @masd925 |http://www.freecodecamp.com/masd925
Mohamed Derhalli
@derhallim
Apr 09 2017 06:19
@bilaal-s u need to do it in jQuery
@bilaal-s so u need to use the $('selector').on('event', callbackfunction);
hey @Masd925 how r u?
Markus Kiili
@Masd925
Apr 09 2017 06:21
@derhallim Fine. Waking up. How about you?
Mohamed Derhalli
@derhallim
Apr 09 2017 06:21
about to sleep :'(
micojay020
@micojay020
Apr 09 2017 06:23
can someone help me
i need help on converting celsius to fahrenheit
Markus Kiili
@Masd925
Apr 09 2017 06:25
@micojay020 Use the formula and the parameter celsius to calculate value for the variable fahrenheit = ...
micojay020
@micojay020
Apr 09 2017 06:25
how do i exactly write it
Dalton Escoe
@Alenero129
Apr 09 2017 06:37
Send the link to it @Masd925
I also need some help with https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afor(var%20i%20%3D0%3Bi%3Ccontacts.length%3Bi%2B%2B)%7B%20%2F%2FLoop%20through%20contacts%0A%20%20if(contacts%5Bi%5D.hasOwnProperty(prop))%7B%20%2F%2FCheck%20property%0A%20%20%20%20if(contacts%5Bi%5D.prop%3D%3D%3DfirstName)%7B%2F%2Fcheck%20if%20property%20value%20is%20equal%20to%20firstName%0A%20%20%20%20%20%20return%20firstName%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20return%20%22No%20such%20contact%22%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20else%7B%0A%20%20%20%20return%20%22No%20such%20property%22%3B%0A%20%20%7D%0A%20%20%0A%7D%0A%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A this one
Paul Wiggers
@pwiggers
Apr 09 2017 06:38
Good morning all
Dalton Escoe
@Alenero129
Apr 09 2017 06:38
oh snap
My bad
Good morning, Mr. Wiggers
Paul Wiggers
@pwiggers
Apr 09 2017 06:39
Currently working on Chunky Monkey and I got the code to pass but once again I am left wondering if there isn't a better way.
function chunkArrayInGroups(arr, size) {
  var groupArr = [];
  var sliceCount = 0;
  var sizeCount = size;

  while (sliceCount < arr.length){
    groupArr.push(arr.slice(sliceCount, sizeCount));
    sliceCount += size;
    sizeCount += size;
  }
  return groupArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Markus Kiili
@Masd925
Apr 09 2017 06:39
@Alenero129 Better if you copy-paste the code you have done here.
@pwiggers You only need one index.
Dalton Escoe
@Alenero129
Apr 09 2017 06:39

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i =0;i<contacts.length;i++){ //Loop through contacts
if(contacts[i].hasOwnProperty(prop)){ //Check property
if(contacts[i].prop===firstName){//check if property value is equal to firstName
return firstName;
}
else{
return "No such contact";
}
}
else{
return "No such property";
}

}

// Only change code above this line
}

I dunno.
Markus Kiili
@Masd925
Apr 09 2017 06:40
@Alenero129 First test first name and then property existence.
@Alenero129 First return should be return contacts[i][prop];
@Alenero129 The logic for returning No such contact is wrong.
.prop looks for property key "prop", not what you wan't here.
Paul Wiggers
@pwiggers
Apr 09 2017 06:44
@Masd925 How do you mean? You need to specify a begin and end for the slice?
Dalton Escoe
@Alenero129
Apr 09 2017 06:44
How would I test firstName?
And hasOwnProperty checks if the variable exists within the object, yes?
Markus Kiili
@Masd925
Apr 09 2017 06:45
@pwiggers Yes, but because the slice size is fixed, you only need the start index (that increments).
Bashir Harrell
@bookofbash
Apr 09 2017 06:45
Im at a loss, can someone point me in the right direction?

function mutation(arr) {
  var firstElement = arr[0];
  var secondElement = arr[1];
 for (var i = 0; i<secondElement.length; i++){
   //what goes here?
  if (firstElement.indexOf(secondElement, 0) ==-1 ){
   return false;
  }
  else {
    return true;
  }
 }
}

mutation(["hello", "hey"]);
I don't know what i need to do to iterate through the second element and check each character
Dalton Escoe
@Alenero129
Apr 09 2017 06:45
Wouldn't I need to test if there is a property first? And then check if the value of the property is === to firstName? @Masd925
Markus Kiili
@Masd925
Apr 09 2017 06:45
@bookofbash Don't return true based on one checked character.
@Alenero129 You only need to check property existence if it is the contact you look for. So first name check first.
Dalton Escoe
@Alenero129
Apr 09 2017 06:47
@Masd925 Thanks, man. I'm going to go over it again. brb
CamperBot
@camperbot
Apr 09 2017 06:47
alenero129 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3810 | @masd925 |http://www.freecodecamp.com/masd925
Paul Wiggers
@pwiggers
Apr 09 2017 06:47
@Masd925 Can you explain? I thought that the end index of slice was the array index and not the amount so (begin, end). You are saying that it is (begin, amount), or is it to early still and am I missing something crucial?
Bashir Harrell
@bookofbash
Apr 09 2017 06:47
@Masd925 What does that mean? I need to check each character in secondElement against the firstElement string, right? but I can't see how to iterate though the second string to get to each character.
micojay020
@micojay020
Apr 09 2017 06:48
so in convert celsius to fahrenheit
Bashir Harrell
@bookofbash
Apr 09 2017 06:48
So if i understand what you are saying, then as I have it now. it returns true for just one character
micojay020
@micojay020
Apr 09 2017 06:48
how should i do all the convertion at the same time
Jor
@joreyesl
Apr 09 2017 06:48
@bookofbash that is why you have the loop. secondeElement[i] that will access each character.
micojay020
@micojay020
Apr 09 2017 06:48
with the same var
Markus Kiili
@Masd925
Apr 09 2017 06:48
@pwiggers If you start the slice from index i and the slice is to hold size elements, you can count the end index using i and size. No need for second index.
Using second index works, but is more complex.
Paul Wiggers
@pwiggers
Apr 09 2017 06:50
Oh, snap, yes of course. I'll grab my coffee now ;)
But besides that, is there a way to improve the program? Perhaps not use a while loop?
Markus Kiili
@Masd925
Apr 09 2017 06:51
@pwiggers For loop is a bit simpler.
Paul Wiggers
@pwiggers
Apr 09 2017 06:55
It saves me a line or two:
function chunkArrayInGroups(arr, size) {
  var groupArr = [];

  for (i = 0; i < arr.length; i += size){
    groupArr.push(arr.slice(i, i + size));
  }

  return groupArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
@Masd925 thanks!
CamperBot
@camperbot
Apr 09 2017 06:56
pwiggers sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3811 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Apr 09 2017 06:56
@pwiggers That is good now. Elegant while loop solution doesn't need an index at all.
Paul Wiggers
@pwiggers
Apr 09 2017 06:59
Hmm, can you give an example?
Markus Kiili
@Masd925
Apr 09 2017 06:59
@pwiggers
function chunkArrayInGroups(arr, size) {
  var result = [];
  while (arr.length>0) result.push(arr.splice(0,size));
  return result;
}
But I like the first one better because it doesn't mutate the passed array. That might surprise the method user.
Paul Wiggers
@pwiggers
Apr 09 2017 07:02
Aha, hadn't heard of splice before. So slice leaves the source intact while splice mutates the source?
Markus Kiili
@Masd925
Apr 09 2017 07:02
Yes.
Paul Wiggers
@pwiggers
Apr 09 2017 07:04
Great, and so you learn every day ;)
Hehe, splice is brought up in the next exercise
Muhammad Hasham
@MohammadHasham
Apr 09 2017 07:08
how can i get youtube json response yo use in my website like we did in wikipedia viewer
maxxero
@maxxero
Apr 09 2017 07:17
hello
please tell me what I am doing wrong
var myArray = [];
for(var i=1; i<11; i+= 2) {
  myArray.push(i);
}
You should be using a for loop for this.
myArray should equal [1,3,5,7,9].
Markus Kiili
@Masd925
Apr 09 2017 07:19
@maxxero It is.
Jor
@joreyesl
Apr 09 2017 07:19
@maxxero looks correct, try refreshing the page.
Dalton Escoe
@Alenero129
Apr 09 2017 07:19
I still can't get the it to loop through. @Masd925
Is it not looping through because returning a value ends the loop? Or was something wrong with my for loop?
maxxero
@maxxero
Apr 09 2017 07:19
@joreyesl ok so it does accept the array
Markus Kiili
@Masd925
Apr 09 2017 07:20
@Alenero129 Return inside the loop if you find the contact and after the loop block if you don't.
maxxero
@maxxero
Apr 09 2017 07:20
but the first task is not
green
Jor
@joreyesl
Apr 09 2017 07:20
@maxxero what is the first task
maxxero
@maxxero
Apr 09 2017 07:20
You should be using a for loop for this.
@joreyesl nvm I removed everything and pasted again
it accepted
Jor
@joreyesl
Apr 09 2017 07:22
@maxxero ok :thumbsup:
Dalton Escoe
@Alenero129
Apr 09 2017 07:23

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

I return inside the loop. @Masd925
In fact, I'm not sure what exactly it's doing because it seems to skips the first object and go to the second.

Markus Kiili
@Masd925
Apr 09 2017 07:23
@Alenero129 First test is wrong.
It needs to compare the firstName property value of the looped contact with the parameter firstName with ===. That tells if it is the contact we look for.
Second nested if should use hasOwnProperty.
Paul Wiggers
@pwiggers
Apr 09 2017 07:25
Should I just get used that I have to use loops all the time? Even though it seems to work they make me feel uncomfortable. I always have the feeling that there has to be a better way;
function mutation(arr) {

  for (i = 0; i < arr[1].length; i++){
    if (arr[0].toLowerCase().indexOf(arr[1].toLowerCase()[i]) < 0){
      return false;
    }
  }

  return true;
}

mutation(["hello", "hey"]);
Markus Kiili
@Masd925
Apr 09 2017 07:26
@pwiggers Loops are basic things in programming. You can use array iterators here too if you like. Pure functional programming uses recursion instead of loops.
Jor
@joreyesl
Apr 09 2017 07:26
@pwiggers you can do it with array methods, but they use loops internally. Can't really get away from it.
maxxero
@maxxero
Apr 09 2017 07:26
var myArray = [];

for(var i=9; i>0; i-=2) {
  myArray.push(i);
}
Paul Wiggers
@pwiggers
Apr 09 2017 07:27
@Masd925 @joreyesl Do you have an example of that?
maxxero
@maxxero
Apr 09 2017 07:27
why can't I use i==1; instead of i>0
Markus Kiili
@Masd925
Apr 09 2017 07:28
@pwiggers
function mutation(arr) {
  return arr[1].toLowerCase().split("").every(function(val, index){
    return arr[0].toLowerCase().indexOf(val)>-1;
  });
}
Should lowercase them first and then use every, but you get the point here.
maxxero
@maxxero
Apr 09 2017 07:29
@joreyesl why won't i===1 work instead of i>0 in my loop?
Paul Wiggers
@pwiggers
Apr 09 2017 07:29
Aha, I see what is going on there but I hide behind the "haven't learned that yet" excuse :)
Markus Kiili
@Masd925
Apr 09 2017 07:30
@pwiggers Yeah, you can try different ways later.
devpaaji
@devpaaji
Apr 09 2017 07:30
@Masd925 should nt map do the same thing'
Paul Wiggers
@pwiggers
Apr 09 2017 07:30
@Masd925 Thanks again
Markus Kiili
@Masd925
Apr 09 2017 07:30
@devpaaji No.
CamperBot
@camperbot
Apr 09 2017 07:30
pwiggers sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: pwiggers already gave masd925 points
devpaaji
@devpaaji
Apr 09 2017 07:30
thought it does transiform the existing array
Jor
@joreyesl
Apr 09 2017 07:31
@maxxero the loop runs as long as the condition is true, but if you start at i=9 then i==1 will be false, thats why usually you use > or <
Markus Kiili
@Masd925
Apr 09 2017 07:31
@devpaaji Every is better here. Map would give you an array that you still would need to test. Every returns the result.
iamingh
@iamingh
Apr 09 2017 07:38
blob
whats wrong with this code
devpaaji
@devpaaji
Apr 09 2017 07:41
@Masd925 there is some function as well
to test for if any of the values in the stack is true
return
Markus Kiili
@Masd925
Apr 09 2017 07:42
@devpaaji Yeah, that would work too.
Dalton Escoe
@Alenero129
Apr 09 2017 07:42
@Masd925 hasOwnProperty function simply checks if there is a variable of the name you pass into it and returns a negative and a positive, yes?
This is the longest I've been stuck on any of these challenges
Markus Kiili
@Masd925
Apr 09 2017 07:43
@Alenero129 If checks whether the object has the given property key.
Dalton Escoe
@Alenero129
Apr 09 2017 07:43
property key meaning value?
Markus Kiili
@Masd925
Apr 09 2017 07:44
@Alenero129 Property keys are strings. You can use a variable too that holds a string.
Addy Progger
@AddyProgger
Apr 09 2017 07:45
What is wrong with my code?

function myLocalScope() {
  'use strict';
  var myVar ="test";

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

// Run and check the console
// myVar is not defined outside of myLocalScope


// Now remove the console log line to pass the test
Yeshu Kochher
@theyeshu
Apr 09 2017 07:46
@iamingh i guess no need to define "" because it's passing undefined string
@AddyProgger there's semicolon after 'use strict' i guess you should try to remove it.
Addy Progger
@AddyProgger
Apr 09 2017 07:49
thx, I passed
soltution was refresh page, lil bug
Yeshu Kochher
@theyeshu
Apr 09 2017 07:50
@AddyProgger is it ok with semicolon?
Addy Progger
@AddyProgger
Apr 09 2017 07:50
yes it is
Yeshu Kochher
@theyeshu
Apr 09 2017 07:51
please tell me the challenge name or number.
Dalton Escoe
@Alenero129
Apr 09 2017 07:55
I don't get it. I thought it would search for a variable name and not the value.
The function call is this lookUpProfile("Akira", "likes"); In which "Akira" is the value of a name and "likes" would be a variable. The function accepts "Akira" as firstName, so by doing contacts[i].hasOwnProperty(firstName) wouldn't I be checking to see if there is a variable within the object called "Akira"?
maxxero
@maxxero
Apr 09 2017 08:02
hello, I am having a trouble with Nesting For Loops challenge
Dalton Escoe
@Alenero129
Apr 09 2017 08:03
I think I've already done that one.
Is it the one with multidimentional array?
maxxero
@maxxero
Apr 09 2017 08:03
yes
abhijith shenoy
@shenoyabhijith
Apr 09 2017 08:04
any 1 who knows android here
Dalton Escoe
@Alenero129
Apr 09 2017 08:05
@maxxero Paste your code
maxxero
@maxxero
Apr 09 2017 08:07

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Dalton Escoe
@Alenero129
Apr 09 2017 08:07
product *= arr[i][j];
So it loops through and multiply all values of the array
Aruseli
@Aruseli
Apr 09 2017 08:08
@alfredim88 are you solve the Stand in line?
maxxero
@maxxero
Apr 09 2017 08:10
@Alenero129 can you explain please what each loop does?
Dalton Escoe
@Alenero129
Apr 09 2017 08:11
@maxxero The first one loops through the length of the array and the second one loops through the sub elements of the array.
So arr[0] = [1,2]
arr[0][0]=1
Getting it? @maxxero
maxxero
@maxxero
Apr 09 2017 08:16
nom sorry
is it the simplest way you can put it?
Dalton Escoe
@Alenero129
Apr 09 2017 08:16
I'm bad at explaining. I'll try again
maxxero
@maxxero
Apr 09 2017 08:17
try to explain it to me like you would explain it to a child :)
Dalton Escoe
@Alenero129
Apr 09 2017 08:17
Alright, I will lol
maxxero
@maxxero
Apr 09 2017 08:22
hello
Dalton Escoe
@Alenero129
Apr 09 2017 08:22
The first loop checks for the length of the array. Which in this case is 2. (2 because the count starts from 0) 0=[1,2], 1=[3,4], 2=[5,6,7])
The second loop which is inside the first checks the length of the specified element.
I'm trying lol
alpox
@alpox
Apr 09 2017 08:23

@maxxero
You have a list. This list has elements. The elements can be numbers, strings, objects, whatever you want. Even another lists.
This is your case.
You loop through one list with a for loop to access its values. This happens then through bracket notation:

var arr = [1, 3, 5];
for(var i = 0; i < arr.length; i++) {
    console.log(arr[i]);
}

This code logs:

1
3
5

as you see, you access each element in this simple array and print it

@maxxero Now you go one step further and put some lists there instead of numbers.
The lists which you put in there will themselves have numbers in themselves though
Dalton Escoe
@Alenero129
Apr 09 2017 08:25
What @alpox said
@alpox have you finished the profile lookup challenge?
maxxero
@maxxero
Apr 09 2017 08:26
ok i kinda understand
and the second part @alpox ?
Dalton Escoe
@Alenero129
Apr 09 2017 08:26
@maxxero You'll get it soon enough
alpox
@alpox
Apr 09 2017 08:27
So you get var arr = [[1, 3], [5, 7]]; which is a list of lists of numbers.
If you would now use the above for loop, you would print the full arrays [1, 3] and [5, 7]. But, you want to access the single numbers, right?
So you just put another for loop - since you learned you loop over lists/arrays with such a for loop to access its elements:
for(var i = 0; i < arr.length; i++) {
    for(var p = 0; p < arr[i].length; p++) {
       console.log(arr[i][p]);
    }
}
As you see arr[i] is either [1, 3] or [5, 7] inside of the outer forloop. then you just put another bracket notation behind it to access the single elements inside of the second for loop.
@Alenero129 Yup
Maybe i jumped over that one though
But i know it and its pitfalls :-)
Dalton Escoe
@Alenero129
Apr 09 2017 08:28
I need some assistance with it. I've been stuck for about 3 hours. All night basically.
alpox
@alpox
Apr 09 2017 08:28
The night is here to sleep :-)
Dalton Escoe
@Alenero129
Apr 09 2017 08:29
lol Sleep is for the weak... Or people with jobs or a busy Sunday.
alpox
@alpox
Apr 09 2017 08:29
:D i'm busy all time
But just go ahead and ask
Dalton Escoe
@Alenero129
Apr 09 2017 08:30
If you've already done it, I'd like to see how it's done. I've never stopped on a challenge for more than 10 minutes.

I asked this about it earlier.

I don't get it. I thought it would search for a variable name and not the value.
The function call is this lookUpProfile("Akira", "likes"); In which "Akira" is the value of a name and "likes" would be a variable. The function accepts "Akira" as firstName, so by doing contacts[i].hasOwnProperty(firstName) wouldn't I be checking to see if there is a variable within the object called "Akira"?

alpox
@alpox
Apr 09 2017 08:31
I don't like to give solutions, but i like to assist you. You can show me what you alread have
Rudy Hernandez
@rudolphh
Apr 09 2017 08:31
i give solutions, step right up
jk lol
DoUSeeMeNow
@DoUSeeMeNow
Apr 09 2017 08:32
i'm stuck at Shopping List
Dalton Escoe
@Alenero129
Apr 09 2017 08:32
lol Alright gimme a sec let me revisit it. Though I think I've posted what I've been doing in this chat a few times.
Rudy Hernandez
@rudolphh
Apr 09 2017 08:32
what have done so far @DoUSeeMeNow
maxxero
@maxxero
Apr 09 2017 08:32
@alpox ok thanks for your explanation, it is somewhat clearer to me now but not quite there yet, i just need to let that sink in :D
CamperBot
@camperbot
Apr 09 2017 08:32
maxxero sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:cookie: 925 | @alpox |http://www.freecodecamp.com/alpox
maxxero
@maxxero
Apr 09 2017 08:33
and thanks @Alenero129 for your input as well :)
CamperBot
@camperbot
Apr 09 2017 08:33
maxxero sends brownie points to @alenero129 :sparkles: :thumbsup: :sparkles:
:cookie: 218 | @alenero129 |http://www.freecodecamp.com/alenero129
DoUSeeMeNow
@DoUSeeMeNow
Apr 09 2017 08:33
well excually nothing
actually
alpox
@alpox
Apr 09 2017 08:33

@Alenero129

so by doing contacts[i].hasOwnProperty(firstName) wouldn't I be checking to see if there is a variable within the object called "Akira"

you're right, you would check exactly that. But thats not what you want :-)

Rudy Hernandez
@rudolphh
Apr 09 2017 08:33
well do something, anything
DoUSeeMeNow
@DoUSeeMeNow
Apr 09 2017 08:33
well, i dont understand it ..
Rudy Hernandez
@rudolphh
Apr 09 2017 08:34
read it
DoUSeeMeNow
@DoUSeeMeNow
Apr 09 2017 08:34
i do but i dont get it
Rudy Hernandez
@rudolphh
Apr 09 2017 08:34
it wants an array with other arrays in it
DoUSeeMeNow
@DoUSeeMeNow
Apr 09 2017 08:34
ohh
..
i feel stupid
thanks!
Rudy Hernandez
@rudolphh
Apr 09 2017 08:34
don't feel stupid, easy to get confused at first
when they throw fancy words like 'multi-dimensional'
DoUSeeMeNow
@DoUSeeMeNow
Apr 09 2017 08:35
yes, im doing this for 1 day now, i got somethings from a friend of mine but i dont get it now
Rudy Hernandez
@rudolphh
Apr 09 2017 08:36
most of the time in these basic challenges, they practically give you the answer. sometimes its the actual answer and other times you just make some modifications to what they give
maxxero
@maxxero
Apr 09 2017 08:37
that's why I try to avoid looking at it I just read the tasks you need to complete at first and try to figure out myself
but lately it's hard to understand anything
DoUSeeMeNow
@DoUSeeMeNow
Apr 09 2017 08:37
The second elements in each of your sub-arrays must all be numbers
i dont get this one
Vicky Lai
@vickylai
Apr 09 2017 08:38
I'm trying to get "moonPhase" from this: https://darksky.net/dev/docs/forecast
I'm using json.daily.data.moonPhase - what am I doing wrong?
maxxero
@maxxero
Apr 09 2017 08:38
var myArray = [];
var i = 0;
 while(i < 5){
   myArray.push(i);
   i++;
 }
why is the while loop constructed as it is
alpox
@alpox
Apr 09 2017 08:38
@DoUSeeMeNow A subarray is one of the arrays in the main array:
[  ["test", 5]   ]
   ^ This is a subarray
maxxero
@maxxero
Apr 09 2017 08:38
why is the i++ at the end
so many questions
alpox
@alpox
Apr 09 2017 08:39
@DoUSeeMeNow Now, as you see, that subarray has the number 5 as its second element. Thats how it should be
DoUSeeMeNow
@DoUSeeMeNow
Apr 09 2017 08:39
oh gosh
can u all call me stupid
@alpox thanks
CamperBot
@camperbot
Apr 09 2017 08:39
douseemenow sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:cookie: 926 | @alpox |http://www.freecodecamp.com/alpox
alpox
@alpox
Apr 09 2017 08:39
@DoUSeeMeNow Np :-)
Dalton Escoe
@Alenero129
Apr 09 2017 08:39
I'm at a loss
maxxero
@maxxero
Apr 09 2017 08:40
hello
alpox
@alpox
Apr 09 2017 08:40
@Alenero129 Did you read my comment up there?
Rudy Hernandez
@rudolphh
Apr 09 2017 08:40
stop saying stupid, confused is the word. this isn't rock science lol
Dalton Escoe
@Alenero129
Apr 09 2017 08:40
@alpox Yeah. But I think I have the wrong idea still.
kickkick479
@kickkick479
Apr 09 2017 08:41
@vickylaixy Can you share what you have already done ?
Vicky Lai
@vickylai
Apr 09 2017 08:41
@kickkick479 It's currently a bit messy so I'm not sure that'll help, but here: http://codepen.io/vickylaixy/pen/jBXgeR?editors=1010
kickkick479
@kickkick479
Apr 09 2017 08:42
@vickylaixy TY. I m looking into it, though I m not sure I could spot the point.
CamperBot
@camperbot
Apr 09 2017 08:42
kickkick479 sends brownie points to @vickylaixy :sparkles: :thumbsup: :sparkles:
:cookie: 280 | @vickylaixy |http://www.freecodecamp.com/vickylaixy
Vicky Lai
@vickylai
Apr 09 2017 08:43
@kickkick479 The other json bits are working except for the sun and moon stuff.
DoUSeeMeNow
@DoUSeeMeNow
Apr 09 2017 08:43
@alpox what is wrong with this code? : var myList = [ ["Test", 5] [".test",4] ["poep", 2] ["lol", 1] ["stupid", 3] ];
alpox
@alpox
Apr 09 2017 08:44
@Alenero129 Your firstName parameter holds "Akira" and the prop holds "likes".
Your task is to find a contact in contacts which has as its firstName value the value "Akira".
If you found that contact which has the firstName "Akira", you have to take a look if this contact has the property (key) "likes" and return the value of this property from the function.
If that property/key did not exist, you return "No such property".
If you did not find any contact with the given firstName "Akira", you return "No such contact"
Markus Kiili
@Masd925
Apr 09 2017 08:44
@DoUSeeMeNow Array elements need to be separated by commas.
alpox
@alpox
Apr 09 2017 08:44
@DoUSeeMeNow ^^^^ :point_up:
DoUSeeMeNow
@DoUSeeMeNow
Apr 09 2017 08:45
so it should be : var myList = [ ["Test", 5],[".test",4],["poep", 2],["lol", 1],["stupid", 3] ];
alpox
@alpox
Apr 09 2017 08:45
@DoUSeeMeNow :clap:
Markus Kiili
@Masd925
Apr 09 2017 08:45
@DoUSeeMeNow Yes.
DoUSeeMeNow
@DoUSeeMeNow
Apr 09 2017 08:45
Thanks, u guys are sitting there like "he is such a noob" and yes i am xd
Markus Kiili
@Masd925
Apr 09 2017 08:46
@DoUSeeMeNow No, we don't think like that. Everyone is a beginner at some point.
alpox
@alpox
Apr 09 2017 08:46
@DoUSeeMeNow We don't think that way ;-) everone has to start somewhere with something.
If i came into pharmacy i wouldn't know a damn thing either :D
i cant understand the challenge :X
alpox
@alpox
Apr 09 2017 08:47
@sursider You have to look at both arrays and return a new array with only values which exists in only one of both arrays.
DoUSeeMeNow
@DoUSeeMeNow
Apr 09 2017 08:48
@Masd925 & @alpox thanks
CamperBot
@camperbot
Apr 09 2017 08:48
douseemenow sends brownie points to @masd925 and @alpox :sparkles: :thumbsup: :sparkles:
:warning: douseemenow already gave alpox points
:star2: 3812 | @masd925 |http://www.freecodecamp.com/masd925
alpox
@alpox
Apr 09 2017 08:48
@sursider This means you include only values of the arrays which are NOT included in the other array
Vidžius
@sursider
Apr 09 2017 08:48
@alpox noope, its something different
Markus Kiili
@Masd925
Apr 09 2017 08:50
@sursider That is how symmDiff of two arrays is calculated. For many arrays you first symmDiff the first two and the result with the third etc.
Dalton Escoe
@Alenero129
Apr 09 2017 08:50
@alpox I understand that but I just don't know how to code the process of going through the array and checking it. I think I'm even more confused than when I just started this challenge.
This is what I have so far:
for(var i =0;i<contacts.length;i++){ //Loop through contacts
if(contacts[i][firstName]===firstName){
if(contacts[i].hasOwnProperty(prop)===true){
return contacts[i][prop];
}
}
}
kickkick479
@kickkick479
Apr 09 2017 08:50
@vickylaixy Sorry for late reply.
var moon = json.daily.data[0].moonPhase; I think that can retrieve the moon phase.
Vidžius
@sursider
Apr 09 2017 08:50
@Masd925 oh ok... thanks
CamperBot
@camperbot
Apr 09 2017 08:50
sursider sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3813 | @masd925 |http://www.freecodecamp.com/masd925
alpox
@alpox
Apr 09 2017 08:50
@sursider I told only the symdiff for 2 arrays. Go with @Masd925 for the rest
Markus Kiili
@Masd925
Apr 09 2017 08:51
@Alenero129 Quotes needed here if(contacts[i][firstName]===firstName){
maxxero
@maxxero
Apr 09 2017 08:51
I need help with Profile Lookup challenge
Vicky Lai
@vickylai
Apr 09 2017 08:52
@kickkick479 Yes. Brilliant. Thank you!
CamperBot
@camperbot
Apr 09 2017 08:52
vickylaixy sends brownie points to @kickkick479 :sparkles: :thumbsup: :sparkles:
:cookie: 272 | @kickkick479 |http://www.freecodecamp.com/kickkick479
Dalton Escoe
@Alenero129
Apr 09 2017 08:52
@Masd925 The quotes didn't make a difference though
Vicky Lai
@vickylai
Apr 09 2017 08:52
Those darn brackets
Markus Kiili
@Masd925
Apr 09 2017 08:53
@Alenero129 You need the other two returns too there.
Dalton Escoe
@Alenero129
Apr 09 2017 08:53
Thanks for the continued assistace @alpox
CamperBot
@camperbot
Apr 09 2017 08:53
alenero129 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:cookie: 927 | @alpox |http://www.freecodecamp.com/alpox
alpox
@alpox
Apr 09 2017 08:53
@Alenero129 the for loop is right.
contacts[i][firstName] === firstName here you test if there is a key named "Akira" in the object - and compare the value of that property with "Akira", probably not what you wanted :-)
contacts[i].firstName === firstName should to the trick since with dot notation you actually look for a key "firstName".
kickkick479
@kickkick479
Apr 09 2017 08:53

@vickylaixy According to the API ref, the JSON format is like this.

    "data": [
      {
        "time": 1453363200,
        "summary": "Rain throughout the day.",
        "icon": "rain",
        "sunriseTime": 1453391560,
        "sunsetTime": 1453424361,
        "moonPhase": 0.43,

So you can access moonPhase, using array index.

Vicky Lai
@vickylai
Apr 09 2017 08:54
JavaScript every day or it starts falling through the cracks!
alpox
@alpox
Apr 09 2017 08:54
@Alenero129 The rest looks ok so far, except that you still have to include the rest of the returns
@Alenero129 You can remove the === true after the hasOwnProperty though since this is redundant
Dalton Escoe
@Alenero129
Apr 09 2017 08:55
Oh snap @alpox
You're right.
I had the right idea but I just can't syntax apparently
alpox
@alpox
Apr 09 2017 08:55
@Alenero129 That comes with time :-)
@Alenero129 contacts[i]["firstName"] would also work btw.
The dot notation is just an abbreviation for that
Dalton Escoe
@Alenero129
Apr 09 2017 08:56
I'll add the other returns.... And review this issue thoroughly so I don't spend another 3-4 hours on syntax issues
Why didn't it work without the quotation?
alpox
@alpox
Apr 09 2017 08:57
@Alenero129 Please think about when exactly you'll have to return No such contact Since that is the biggest issue people have with this exercise
@Alenero129 With the quotation you have a string. Without them, you take the value of your variable firstName - which is the string "Akira"
Dalton Escoe
@Alenero129
Apr 09 2017 08:58
@alpox haha. And here I thought those returns would've been simple.
@alpox What do you mean by key? I understand only that objects are made up of variables and the variables may or may not have value.
alpox
@alpox
Apr 09 2017 09:01
@Alenero129
{  "foo": "bar" }
   ^key   ^value
@Alenero129 objects themselves are variables.
What is in them are not really variables but there are values.
Objects consist of key/value pairs as i just showed
Left side of the : is a key and on the right side of : a value.
And you always access a value through its key
Dalton Escoe
@Alenero129
Apr 09 2017 09:03
Ahhhhh @alpox Much thanks for the clarification
CamperBot
@camperbot
Apr 09 2017 09:03
alenero129 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:warning: alenero129 already gave alpox points
alpox
@alpox
Apr 09 2017 09:05
@Alenero129 you're welcome :-)
Dalton Escoe
@Alenero129
Apr 09 2017 09:06
@alpox You were right about the return placements
alpox
@alpox
Apr 09 2017 09:06
@Alenero129 ;-)
HN
@haydennorthcott
Apr 09 2017 09:07
How do I display a screen shot of just the code camp code?
alpox
@alpox
Apr 09 2017 09:07
@haydennorthcott Don't do screen shots. Copy the code here.
@haydennorthcott in this matter:
``` <shift-enter>
<code> <shift-enter>
```
HN
@haydennorthcott
Apr 09 2017 09:08
Switch Statements: Am I supposed to use strict equality (===) statements on this challenge? I've used:
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line

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


  }

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

// Change this value to test
caseInSwitch(1);
thanks @alpox
CamperBot
@camperbot
Apr 09 2017 09:09
haydennorthcott sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:cookie: 928 | @alpox |http://www.freecodecamp.com/alpox
Fabalus
@Fabalus
Apr 09 2017 09:11
Find the Longest Word in a String, the tips are wrong
CamperBot
@camperbot
Apr 09 2017 09:11
find the longest word in a string the tips are wrong
nothing found
alpox
@alpox
Apr 09 2017 09:11
@haydennorthcott No, you do not have to use ===. They just pointed out that the values you put into a case are compared strictly with your val
@Fabalus They are not
Fabalus
@Fabalus
Apr 09 2017 09:12
what can i do
skip?
alpox
@alpox
Apr 09 2017 09:14
@Fabalus No you can try to solve it :-)
What is wrong with it as you think?
bilaal-s
@bilaal-s
Apr 09 2017 09:15
guys whats .html in the line
$(".message").html("Here is the message");
Markus Kiili
@Masd925
Apr 09 2017 09:15
@bilaal-s A jQuery method.
alpox
@alpox
Apr 09 2017 09:16
@bilaal-s It places some html content inside of the selected element(s)
bilaal-s
@bilaal-s
Apr 09 2017 09:16
@Masd925 is it equivelant to innerHtml?
alpox
@alpox
Apr 09 2017 09:16
@bilaal-s yes
bilaal-s
@bilaal-s
Apr 09 2017 09:16
@alpox awesome thanks! @Masd925 thanks
CamperBot
@camperbot
Apr 09 2017 09:16
bilaal-s sends brownie points to @alpox and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 929 | @alpox |http://www.freecodecamp.com/alpox
:star2: 3814 | @masd925 |http://www.freecodecamp.com/masd925
Dalton Escoe
@Alenero129
Apr 09 2017 09:17
@alpox I don't understand why I can't put else{return "No such contact";} outside the first if
for(var i =0;i<contacts.length;i++){ //Loop through contacts
if(contacts[i].firstName===firstName){
if(contacts[i].hasOwnProperty(prop)===true){
return contacts[i][prop];
}
else{
return "No such property";
}
}
else{
return "No such contact";
}
}
How do you paste code in that black window?
Markus Kiili
@Masd925
Apr 09 2017 09:19
@Alenero129 That could return No such contact after checking only one contact.
alpox
@alpox
Apr 09 2017 09:20
@Alenero129 When you return inside of any function, the whole function will be stopped at the point the code reaches the return - and it breaks all loops in which it currently is.
This means, you break everything in already the first iteration (for-loop-run)
Dalton Escoe
@Alenero129
Apr 09 2017 09:20
@Masd925 But it's still inside the for loop, I figured it'd just continue the loop
bilaal-s
@bilaal-s
Apr 09 2017 09:20
is innerHtml jquery syntax or javascript
alpox
@alpox
Apr 09 2017 09:20
@bilaal-s native javascript
Markus Kiili
@Masd925
Apr 09 2017 09:20
@Alenero129 No, the returns ends the function.
bilaal-s
@bilaal-s
Apr 09 2017 09:21
@alpox thank you
CamperBot
@camperbot
Apr 09 2017 09:21
bilaal-s sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:warning: bilaal-s already gave alpox points
maxxero
@maxxero
Apr 09 2017 09:27
can I get help with Profile Lookup challenge please?
WAINGOR
@WAINGOR
Apr 09 2017 09:28
Hi all... I am stuck at Ceasars's Cipher.. does anybody know where I am going wrong?

function rot13(str) { // LBH QVQ VG!
  //haal input terug, maar dan ontcijferd. 


  var alfabet = [];
for (var i = 65; i<91; i++) {
var gepusht = String.fromCharCode(i);
alfabet.push(gepusht);
 }

for (var j=65; j<91; j++) {
var gepusht1= String.fromCharCode(j);
alfabet.push(gepusht1);
 }
console.log(alfabet);


  var maakArray = str.split("");
  for (var k=0; k<maakArray.length; k++) {

    if (/^[a-zA-Z]+$/.test(maakArray[k])) {
        var maakCharCode = maakArray[k].charCodeAt(0); 
        var ontCipherIndex = maakCharCode -65 + 13;
        var ontCipherLetter = alfabet[ontCipherIndex];
        maakArray[k] = alfabet[ontCipherIndex];

        }
  }




}




// Change the inputs below to test
rot13("SERR PBQR PNZC");
Dalton Escoe
@Alenero129
Apr 09 2017 09:29
thanks for the advice @alpox and @Masd925
I'm still trying to figure out where to put it or if I should try something else
CamperBot
@camperbot
Apr 09 2017 09:29
alenero129 sends brownie points to @alpox and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3815 | @masd925 |http://www.freecodecamp.com/masd925
:warning: alenero129 already gave alpox points
Dalton Escoe
@Alenero129
Apr 09 2017 09:29
@maxxero That's where I am
Rudy Hernandez
@rudolphh
Apr 09 2017 09:30
i would comment on your code line by line and then see if you're doing what you want it to do @WAINGOR
maxxero
@maxxero
Apr 09 2017 09:30
@Alenero129 yeah but you got something already
and I haven't
Markus Kiili
@Masd925
Apr 09 2017 09:30
@Alenero129 You need to put it after the loop block. You return inside the loop if you find the contact, and after the loop if you don't.
bilaal-s
@bilaal-s
Apr 09 2017 09:30
@WAINGOR hello! Try testing individual components of your code in repl.it and see if you get the expected output! also, nice to see your using dutch to code xD
@WAINGOR for example, your alfabet array, does it look like you expect it to?
WAINGOR
@WAINGOR
Apr 09 2017 09:32
Lol I figured it out
alpox
@alpox
Apr 09 2017 09:32
@Alenero129 You'll have to put it after the for loop - because then you already searched through all the contacts and didn't find anything
Dalton Escoe
@Alenero129
Apr 09 2017 09:32
@Masd925 I feel really dumb now :smile:
WAINGOR
@WAINGOR
Apr 09 2017 09:32
@bilaal-s I didnt put in a return statement lol
bilaal-s
@bilaal-s
Apr 09 2017 09:32
@WAINGOR nice ^_^ good job
WAINGOR
@WAINGOR
Apr 09 2017 09:32
@bilaal-s thanks for looking into my code bro
CamperBot
@camperbot
Apr 09 2017 09:32
waingor sends brownie points to @bilaal-s :sparkles: :thumbsup: :sparkles:
:cookie: 194 | @bilaal-s |http://www.freecodecamp.com/bilaal-s
Dalton Escoe
@Alenero129
Apr 09 2017 09:34
I get it. It does the check at the beginning of the loop. If the check fails, it simply ends.
Daan van de Ven
@DaanvdVen
Apr 09 2017 09:34
Hey guys can i get your help on this problem?

var Bike = function() {
var gear = 0;

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

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

Dalton Escoe
@Alenero129
Apr 09 2017 09:35
@maxxero What do you have so far?
Daan van de Ven
@DaanvdVen
Apr 09 2017 09:36
that is what i have gear should be 3 after .setGear(3) but it doesn't work
kickkick479
@kickkick479
Apr 09 2017 09:37
@DaanvdVen I'm not sure what your matter is exactly. But gear += har; looks wired a bit.
alpox
@alpox
Apr 09 2017 09:37
@DaanvdVen setGear sounds like you should set the gear and not increase it :-/ :D
maxxero
@maxxero
Apr 09 2017 09:38
 for(var i=0; i<contacts.length; i++){

    }
this
i got so far
I dont even know what I am doing xd
alpox
@alpox
Apr 09 2017 09:38
@maxxero Well, but that part is already right :D
Dalton Escoe
@Alenero129
Apr 09 2017 09:38
@maxxero You're on the right track
maxxero
@maxxero
Apr 09 2017 09:39
so for that loop
Daan van de Ven
@DaanvdVen
Apr 09 2017 09:39
@alpox thank you, that was indeed the problem xD
CamperBot
@camperbot
Apr 09 2017 09:39
daanvdven sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:cookie: 930 | @alpox |http://www.freecodecamp.com/alpox
CodeGeek3
@codeGeek3
Apr 09 2017 09:39
hello every body
maxxero
@maxxero
Apr 09 2017 09:39
I need to check if firstName is an actual contact;s firstName and the givben property (prop) is a property of that contact
for that loop
?
Dalton Escoe
@Alenero129
Apr 09 2017 09:40
I have 3% battery life so unfortunately I have to go. Bed time I guess that means bed time.
kickkick479
@kickkick479
Apr 09 2017 09:40
@codeGeek3 welcome back
Dalton Escoe
@Alenero129
Apr 09 2017 09:40
@maxxero Yes. Exactly
maxxero
@maxxero
Apr 09 2017 09:40
should i use if for it?
Daan van de Ven
@DaanvdVen
Apr 09 2017 09:41
@maxxero you can say instead of contacts.length contacts.length + 1 and when i == contracts.length return no such contact
maxxero
@maxxero
Apr 09 2017 09:42
what
lol
Daan van de Ven
@DaanvdVen
Apr 09 2017 09:42
if (i == contract.lenght) {
maxxero
@maxxero
Apr 09 2017 09:42
dont give me solution
Daan van de Ven
@DaanvdVen
Apr 09 2017 09:42
i dont
Dalton Escoe
@Alenero129
Apr 09 2017 09:43
@maxxero to check firstName, should see if it's equal to the one in the array
alpox
@alpox
Apr 09 2017 09:43
@DaanvdVen length
maxxero
@maxxero
Apr 09 2017 09:43
so
CodeGeek3
@codeGeek3
Apr 09 2017 09:43
@kickkick479 thank ^^
CamperBot
@camperbot
Apr 09 2017 09:43
codegeek3 sends brownie points to @kickkick479 :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @kickkick479 |http://www.freecodecamp.com/kickkick479
maxxero
@maxxero
Apr 09 2017 09:43
if(contacts.firstName == what?
oh wait
Dalton Escoe
@Alenero129
Apr 09 2017 09:44
That wouldn't work. Remember you're looping through the object.
maxxero
@maxxero
Apr 09 2017 09:44
if(firstName == contacts.firstName) {?
CodeGeek3
@codeGeek3
Apr 09 2017 09:44
some why these two equivalent code don't do the same thing?
//this work
var viewRects = document.getElementsByClassName('viewRect');

var viewRectUpdate = () => {
    var curr_vsbl = null;
    var next_vsbl = null;
    for (var i = viewRects.length; i--;) {

        curr_vsbl = viewRects[i].getElementsByClassName('visible')[0];
        next_vsbl = curr_vsbl.nextElementSibling;
        curr_vsbl.className = '';
        (next_vsbl ? next_vsbl : viewRects[i].firstElementChild).className = 'visible';
    }
}

//but this does not, why?
var viewRects = document.getElementsByClassName('viewRect');

var viewRectUpdate = () => {
    var curr_vsbl = null;
    var next_vsbl = null;
    for (var i = viewRects.length; i--;) {

        curr_vsbl = viewRects[i].getElementsByClassName('visible')[0];
        curr_vsbl.className = ''; //curr_vsbl is undefined, why?

        (next_vsbl = curr_vsbl.nextElementSibling ? next_vsbl : viewRects[i].firstElementChild).className = 'visible';
    }
}
Dalton Escoe
@Alenero129
Apr 09 2017 09:46
@maxxero Basically. if(firstName === contacts[i].firstName)
maxxero
@maxxero
Apr 09 2017 09:46
omg
this makes me want to rage quit so hard
Dalton Escoe
@Alenero129
Apr 09 2017 09:47
Just remember that you're looping through contacts so you have to use index contacts[i]
I gotta go. Later folks. Enjoy troubleshooting, @maxxero
Take care
maxxero
@maxxero
Apr 09 2017 09:48
@Alenero129 ok bye
maxxero
@maxxero
Apr 09 2017 09:53
@alpox is this any good?
function lookUpProfile(firstName, prop){
// Only change code below this line

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

       return contacts[i].hasOwnProperty(prop);
       }

    }
heroiczero
@heroiczero
Apr 09 2017 09:55
@maxxero return contacts[i].hasOwnProperty(prop); this will return a true or false
maxxero
@maxxero
Apr 09 2017 09:55
yeah i realised
but how to make it return value
CodeGeek3
@codeGeek3
Apr 09 2017 09:55
@heroiczero hey
maxxero
@maxxero
Apr 09 2017 09:55
of the property
@codeGeek3 Hello :)
kickkick479
@kickkick479
Apr 09 2017 09:58
@codeGeek3 I did not test ur code, cuz I do not have HTML codes with that. Although, I guess (next_vsbl = curr_vsbl.nextElementSibling ? next_vsbl : viewRects[i].firstElementChild).className = 'visible'; do not need next_vsbl assignment.
maxxero
@maxxero
Apr 09 2017 09:59
 for(var i=0; i<contacts.length; i++){
    if(firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {

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

    }
kickkick479
@kickkick479
Apr 09 2017 09:59
I mean ,(curr_vsbl.nextElementSibling ? next_vsbl : viewRects[i].firstElementChild).className = 'visible'; how does this work ?
CodeGeek3
@codeGeek3
Apr 09 2017 10:00
@kickkick479 the problem is not there
//this work
var viewRects = document.getElementsByClassName('viewRect');

var viewRectUpdate = () => {
    var curr_vsbl;
    var next_vsbl;
    for (var i = viewRects.length; i--;) {


        curr_vsbl = viewRects[i].getElementsByClassName('visible')[0];  //everything work
        curr_vsbl.className = '';

        next_vsbl = curr_vsbl.nextElementSibling;
        (next_vsbl ? next_vsbl : viewRects[i].firstElementChild).className = 'visible';
    }
}

//but this does not, why?
var viewRects = document.getElementsByClassName('viewRect');

var viewRectUpdate = () => {
    var curr_vsbl;
    var next_vsbl;
    for (var i = viewRects.length; i > 0; i--) {

        curr_vsbl = viewRects[i].getElementsByClassName('visible')[0];//undefined, why???
        curr_vsbl.className = ''; 

        (next_vsbl = curr_vsbl.nextElementSibling ? next_vsbl : viewRects[i].firstElementChild).className = 'visible';
    }
}
kickkick479
@kickkick479
Apr 09 2017 10:00
OK. What part?
CodeGeek3
@codeGeek3
Apr 09 2017 10:00
look inside the loop
@kickkick479 I changed only one line
kickkick479
@kickkick479
Apr 09 2017 10:01
for (var i = viewRects.length; i--;) { I missed conditional part?
CodeGeek3
@codeGeek3
Apr 09 2017 10:01
//this work
var viewRects = document.getElementsByClassName('viewRect');

var viewRectUpdate = () => {
    var curr_vsbl;
    var next_vsbl;
    for (var i = viewRects.length; i--;) {


        curr_vsbl = viewRects[i].getElementsByClassName('visible')[0];  //everything work
        curr_vsbl.className = '';

        next_vsbl = curr_vsbl.nextElementSibling;
        (next_vsbl ? next_vsbl : viewRects[i].firstElementChild).className = 'visible';
    }
}

//but this does not, why?
var viewRects = document.getElementsByClassName('viewRect');

var viewRectUpdate = () => {
    var curr_vsbl;
    var next_vsbl;
    for (var i = viewRects.length; i > 0; i--) {

        curr_vsbl = viewRects[i].getElementsByClassName('visible')[0];//undefined, why???
        curr_vsbl.className = ''; 

        //next_vsbl = curr_vsbl.nextElementSibling;
        (next_vsbl = curr_vsbl.nextElementSibling ? next_vsbl : viewRects[i].firstElementChild).className = 'visible';
    }
}
Opps
kickkick479
@kickkick479
Apr 09 2017 10:02
In first viewRectUpdate
CodeGeek3
@codeGeek3
Apr 09 2017 10:02
in the seconde code I just removed the line next_vsbl = next_vsbl = curr_vsbl.nextElementSibling
kickkick479
@kickkick479
Apr 09 2017 10:03
I need test the code. Can you tell me what the stage name is?
CodeGeek3
@codeGeek3
Apr 09 2017 10:04
It is on local
kickkick479
@kickkick479
Apr 09 2017 10:04
OK
CodeGeek3
@codeGeek3
Apr 09 2017 10:05
I will be right back
@kickkick479 I am back

var viewRects = document.getElementsByClassName('viewRect');

var viewRectUpdate = () => {
    var curr_vsbl;
    var next_vsbl;
    for (var i = viewRects.length; i--;) {

        curr_vsbl = viewRects[i].getElementsByClassName('visible')[0];
        curr_vsbl.className = '';

        /*REPLACE THIS BLOCK BY*/
        next_vsbl = curr_vsbl.nextElementSibling;
        (next_vsbl ? next_vsbl : viewRects[i].firstElementChild).className = 'visible';

        /*THIS BLOCK*/
        /* (next_vsbl = curr_vsbl.nextElementSibling ? next_vsbl : viewRects[i].firstElementChild).className = 'visible';*/
    }
}
tanxingli
@tanxingli
Apr 09 2017 10:09

// Setup
var myArray = [];

// Only change code below this line.

for (var i = 1;i < 6;i++){
myArray.push(i);

}

CodeGeek3
@codeGeek3
Apr 09 2017 10:09
@kickkick479 I think it is much more clear, HOw to put it in CodePen?
Rudy Hernandez
@rudolphh
Apr 09 2017 10:10
can you do curr_vsbl.className?
tanxingli
@tanxingli
Apr 09 2017 10:10
this is not for?
maxxero
@maxxero
Apr 09 2017 10:10
do I need 2 for loops for Profile lookup challenge
kickkick479
@kickkick479
Apr 09 2017 10:10
@codeGeek3 One sec
maxxero
@maxxero
Apr 09 2017 10:10
or just 1 will do it?
heroiczero
@heroiczero
Apr 09 2017 10:10
@maxxero you could use one
tanxingli
@tanxingli
Apr 09 2017 10:10
is not for?
Vered Rekanati
@veredrec
Apr 09 2017 10:10
Hi! My Simon game is showing the colors that the computer chose in a funny way... Any ideas how I fix this or what is causing the problem? Thanks! http://codepen.io/veredrec/pen/YZrYvO?editors=0011
Rudy Hernandez
@rudolphh
Apr 09 2017 10:11
i'm thinking .remove no?
heroiczero
@heroiczero
Apr 09 2017 10:12
@veredrec it looks fine to me. where is the color problem?
CodeGeek3
@codeGeek3
Apr 09 2017 10:12
@veredrec hey
Rudy Hernandez
@rudolphh
Apr 09 2017 10:12
or .removeClass
CodeGeek3
@codeGeek3
Apr 09 2017 10:12
@veredrec How did you link your codePen ?
Rudy Hernandez
@rudolphh
Apr 09 2017 10:12
nvm moving on
Vered Rekanati
@veredrec
Apr 09 2017 10:13
@rudolphh it doesn't repeat the colors correctly, so it shows the first color twice and then slowly the others or something like that...
heroiczero
@heroiczero
Apr 09 2017 10:13
@codeGeek3 just paste your link here
Rudy Hernandez
@rudolphh
Apr 09 2017 10:13
@veredrec its because Simon didn't say... duh
Vered Rekanati
@veredrec
Apr 09 2017 10:13
@codeGeek3 yes, copied and pasted the link
@rudolphh :)
@heroiczero sorry - this one was meant to you... - it doesn't repeat the colors correctly, so it shows the first color twice and then slowly the others or something like that...
CodeGeek3
@codeGeek3
Apr 09 2017 10:16
@heroiczero hey
HOw can I add image ?
maxxero
@maxxero
Apr 09 2017 10:16
@heroiczero so I have this so far

//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

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




    if(firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {


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

    }


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Rudy Hernandez
@rudolphh
Apr 09 2017 10:16
i see what you mean @veredrec says error in console.log but that must be from you
maxxero
@maxxero
Apr 09 2017 10:17
so for lookUpProfile("Akira", "likes"); it returns ["Pizza", "Coding", "Brownie Points"]
but for lookUpProfile("Harry", "likes"); it returns "No such contact"
Vered Rekanati
@veredrec
Apr 09 2017 10:17
@rudolphh yes, in some cases it doesn't recognize the user correctly and in others it repeats the first color twice. Not sure why...
heroiczero
@heroiczero
Apr 09 2017 10:18
Rudy Hernandez
@rudolphh
Apr 09 2017 10:21
just curious is the background image supposed to shift a bit all the time by design?
heroiczero
@heroiczero
Apr 09 2017 10:21
@maxxero When it goes through your loop the first time and check if (Harry != "Akira") it is true and returns "no such contacts". Gotta make it so it goes though each one without returning unless its the end of the loop
AminaKhan13
@AminaKhan13
Apr 09 2017 10:22

Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

function nextInLine(arr, item) {
// Your code here
arr = [1,2,3,4,5];
arr.push(item);
var oneDown = arr.shift();
return oneDown; // Change this line
}

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

Vered Rekanati
@veredrec
Apr 09 2017 10:22
@rudolphh are you talking about my game? No, I'll change it...
AminaKhan13
@AminaKhan13
Apr 09 2017 10:22
whats wrong with me code ?
please can someon help me
Rudy Hernandez
@rudolphh
Apr 09 2017 10:23
question @veredrec you have var user as a global, and in several of these functions its being reset to an empty array. i'm wondering why
CodeGeek3
@codeGeek3
Apr 09 2017 10:23
@heroiczero now it's ok
heroiczero
@heroiczero
Apr 09 2017 10:23
@AminaKhan13 arr = [1,2,3,4,5]; why is this in your function
Vered Rekanati
@veredrec
Apr 09 2017 10:23
@rudolphh because each time I need to empty the array in order to check if the user repeats all steps correctly... I think...
CodeGeek3
@codeGeek3
Apr 09 2017 10:24
@heroiczero you can test
@heroiczero look at the js code
Rudy Hernandez
@rudolphh
Apr 09 2017 10:24
maybe rename to userSteps, kinda confusing
AminaKhan13
@AminaKhan13
Apr 09 2017 10:24
@heroiczero because they asked us to add an array
maxxero
@maxxero
Apr 09 2017 10:25
@heroiczero so how do I achieve it
WAINGOR
@WAINGOR
Apr 09 2017 10:25

Hi all I finished Caesars Cipher (basic algo challenges) and I was wondering: does anybody know if there is a more clean/faster way to get the right result?


function rot13(str) { // LBH QVQ VG!
  //haal input terug, maar dan ontcijferd. 

// maak alfabet (*2)
  var alfabet = [];
for (var i = 65; i<91; i++) {
var gepusht = String.fromCharCode(i);
alfabet.push(gepusht);
 }

for (var j=65; j<91; j++) {
var gepusht1= String.fromCharCode(j);
alfabet.push(gepusht1);
 }
console.log(alfabet);



  var maakArray = str.split("");
  for (var k=0; k<maakArray.length; k++) {

    if (/^[a-zA-Z]+$/.test(maakArray[k])) {
        var maakCharCode = maakArray[k].charCodeAt(0); 
        var ontCipherIndex = maakCharCode -65 + 13;
        var ontCipherLetter = alfabet[ontCipherIndex];
        maakArray[k] = alfabet[ontCipherIndex];

        }
  }

  var antwoord = maakArray.join('');

  return antwoord;



}




// Change the inputs below to test
rot13("SERR PBQR PNZC");

just to be clear... this code works just fine ;)

heroiczero
@heroiczero
Apr 09 2017 10:25
@AminaKhan13 are you sure?
WAINGOR
@WAINGOR
Apr 09 2017 10:25
I just wanna know if it can be done more efficient
maxxero
@maxxero
Apr 09 2017 10:25
@heroiczero should I remove all the returns?
AminaKhan13
@AminaKhan13
Apr 09 2017 10:25
@heroiczero okay i commented it out and its coming correct. Thanks so much !! :+1:
CamperBot
@camperbot
Apr 09 2017 10:25
aminakhan13 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1108 | @heroiczero |http://www.freecodecamp.com/heroiczero
alpox
@alpox
Apr 09 2017 10:26
@WAINGOR There are probably better solutions than this too but:
function rot13(str) {
  return str.split('').map(function(sub) {
    if(!/[A-Z]/.exec(sub)) return sub;
    var ch = sub.charCodeAt(0);
    ch += 13;
    if(ch > 90) ch = ch - 90 + 64;
    return String.fromCharCode(ch);
  }).join('');
}
CodeGeek3
@codeGeek3
Apr 09 2017 10:27
@heroiczero after doing the replacement it does not work
var viewRectUpdate = () => {
    var curr_vsbl;
    var next_vsbl;
    for (var i = viewRects.length; i--;) {

        curr_vsbl = viewRects[i].getElementsByClassName('visible')[0];
        curr_vsbl.className = '';

        /*REPLACE THIS BLOCK BY*/
        next_vsbl = curr_vsbl.nextElementSibling;
        (next_vsbl ? next_vsbl : viewRects[i].firstElementChild).className = 'visible';

        /*THIS BLOCK*/
        /* (next_vsbl = curr_vsbl.nextElementSibling ? next_vsbl : viewRects[i].firstElementChild).className = 'visible';*/
    }
}
heroiczero
@heroiczero
Apr 09 2017 10:27
@maxxero just make it so it returns "No such contact after the looping into each array element
Spyrantis Theodoros
@thodorisanta
Apr 09 2017 10:29

lets say that i have 3 elements in a div like :smile:

<div class="XorO">
        <p>Would you like to be X or O?</p>
        <button class="choose-x">X</button>
        <button class="choose-o">O</button>
        <button class="back-button">Back</button>
    </div>

how can i make the 3rd button <button class="back-button">Back</button> to be in a different row without the use of bootstrap?

maxxero
@maxxero
Apr 09 2017 10:29
@heroiczero i dont get it
Rudy Hernandez
@rudolphh
Apr 09 2017 10:29
@WAINGOR
function rot13(str) { // LBH QVQ VG!

  let charNum = 0; 

  str = str.replace(/[A-Z]/g, ((item) => {
    charNum = item.charCodeAt(0);
    if(charNum < 78){ charNum += 13; }
    else { charNum -= 13; }
    return String.fromCharCode(charNum);
  }));

  return str;
}
Markus Kiili
@Masd925
Apr 09 2017 10:31
@WAINGOR One remainder operation could do the charcode mapping.
Prateek Goel
@prateekgoel
Apr 09 2017 10:32
@thodorisanta you can use display:block; on .back-button class
heroiczero
@heroiczero
Apr 09 2017 10:33

@maxxero ok your code currently is going through a if/else statement and in

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

try commenting it out and see what happens. it can go through each element of the loop through the if statement.

Grzegorz Sumara
@Gedokawa
Apr 09 2017 10:36
Hi everyone

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

}

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

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

kickkick479
@kickkick479
Apr 09 2017 10:37
@codeGeek3 According to JS operator precedence, Conditional(... ? ... : ... ) has prior precedence to Assignment(=). So (next_vsbl = curr_vsbl.nextElementSibling ? next_vsbl : viewRects[i].firstElementChild).className = 'visible'; does not work as you expected. Separate the assignment and the condition.
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
maxxero
@maxxero
Apr 09 2017 10:37
i commented out the first esle if and it works
kickkick479
@kickkick479
Apr 09 2017 10:37
@Gedokawa for(var j=0; j<arr[i].length; j++){ wrong condition.
Grzegorz Sumara
@Gedokawa
Apr 09 2017 10:38
what correct condiction
Rudy Hernandez
@rudolphh
Apr 09 2017 10:38
@veredrec the best advice i can give for now would be to simplify your code down for one. your click handlers are repeated code with one (or two) line differences. you can refactor that down with a function callback that takes a parameter or two. then go through the logic of the game step by agonizing step. you'll get it
maxxero
@maxxero
Apr 09 2017 10:38
@heroiczero but how do I make it work and keep the no such property
heroiczero
@heroiczero
Apr 09 2017 10:39
@maxxero it is because you are not escaping the loop with a return you have to code it so that it returns it after looping though each one not prematurely return "No such Contact"; or `no such property
kickkick479
@kickkick479
Apr 09 2017 10:39
@Gedokawa it depneds on how many time you wanna repeat it. which array length? i or j
Vered Rekanati
@veredrec
Apr 09 2017 10:39
@rudolphh I'll try. Thanks!
CamperBot
@camperbot
Apr 09 2017 10:39
veredrec sends brownie points to @rudolphh :sparkles: :thumbsup: :sparkles:
:cookie: 163 | @rudolphh |http://www.freecodecamp.com/rudolphh
Grzegorz Sumara
@Gedokawa
Apr 09 2017 10:39
@kickkick479 multiplyAll([[1,2],[3,4],[5,6,7]]);
multiplyAll([[1],[2],[3]]); should return 6
multiplyAll([[1,2],[3,4],[5,6,7]]) should return 5040
multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]);) should return 54
Rudy Hernandez
@rudolphh
Apr 09 2017 10:40
np, don't hesitate to repost once you do. i'd like to see. thanks for sharing @veredrec
CamperBot
@camperbot
Apr 09 2017 10:40
rudolphh sends brownie points to @veredrec :sparkles: :thumbsup: :sparkles:
:cookie: 351 | @veredrec |http://www.freecodecamp.com/veredrec
maxxero
@maxxero
Apr 09 2017 10:40
@heroiczero so make 2 more loops 1 for no such property and 1 for no such contact?
kickkick479
@kickkick479
Apr 09 2017 10:40
@Gedokawa Sorry I am wrong. u right.
heroiczero
@heroiczero
Apr 09 2017 10:40
@Gedokawa
  var product = 1;
  // Only change code below this line
  for(var i=0; i<arr.length; i++){
    for(var j=0; j<arr[i].length; j++){
      //YOU NEED TO MULTIPLY YOUR product HERE
    }
  }
  // Only change code above this line
kickkick479
@kickkick479
Apr 09 2017 10:41
Simply multiply all numbers inside array. You can access inside array's value like arr[0][1] , which mean 2 when [[1,2],[3,4],[5,6,7]] is given.
Grzegorz Sumara
@Gedokawa
Apr 09 2017 10:42
@kickkick479
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i=0; i<arr.length; i++){
for(var j=0; j<arr[i].length; j++){
console.log(arr[i][j]);
}
}
heroiczero
@heroiczero
Apr 09 2017 10:42
@maxxero you could do it that way or you could do it more efficiently with one for loop but just make it work for the first time around
Grzegorz Sumara
@Gedokawa
Apr 09 2017 10:42
but what about var product = 1; and return product ?
alpox
@alpox
Apr 09 2017 10:43
>.< now i have a oneliner of Ceasars cipher... omg :D
kickkick479
@kickkick479
Apr 09 2017 10:43
@Gedokawa u should multiply current product value and arr[i][j] ,and then re-assign it to product.
Keon Samuel
@keonsam
Apr 09 2017 10:44

function findElement(arr, func) {
  var num=0;
    var isItTrue = func;
   num = arr.filter(isItTrue);
  var finalNum= num[0];

  return finalNum;
}

findElement([1, 2, 3, 4], function(num){ return num % 2 === 0; });
heroiczero
@heroiczero
Apr 09 2017 10:44
@Gedokawa need to changeconsole.log(arr[i][j]); you should be using arr[i][j] but need to use product and *=
Keon Samuel
@keonsam
Apr 09 2017 10:44
I want a more flash algorithm.
Grzegorz Sumara
@Gedokawa
Apr 09 2017 10:44
@kickkick479 Thank you but it is hard for me
CamperBot
@camperbot
Apr 09 2017 10:44
gedokawa sends brownie points to @kickkick479 :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @kickkick479 |http://www.freecodecamp.com/kickkick479
kickkick479
@kickkick479
Apr 09 2017 10:45
^ read heroiczero's tip
alpox
@alpox
Apr 09 2017 10:45
@keonsam flash?
kickkick479
@kickkick479
Apr 09 2017 10:46
x *= y; is equal to x = x * y;
Grzegorz Sumara
@Gedokawa
Apr 09 2017 10:46
I know
CodeGeek3
@codeGeek3
Apr 09 2017 10:47
I did all you say to do



var viewRects = document.getElementsByClassName('viewRect');

var viewRectUpdate = () => {
    var currImage_vsbl;
    var nextImage_vsbl;
    for (var i = viewRects.length-1;i >= 0; i--) {

        currImage_vsbl = viewRects[i].getElementsByClassName('visible')[0];
        currImage_vsbl.className = ''; // Problem appear here after replacement

        /*REPLACE THIS BLOCK BY*/
        nextImage_vsbl = currImage_vsbl.nextElementSibling;
        (nextImage_vsbl ? nextImage_vsbl : viewRects[i].firstElementChild).className = 'visible';

        /*THIS BLOCK*/
        /* (nextImage_vsbl = currImage_vsbl.nextElementSibling ? nextImage_vsbl : viewRects[i].firstElementChild).className = 'visible';*/
    }
}

//--------------------fonctions de controle
var idInterval;
var play = () => idInterval = idInterval || setInterval(viewRectUpdate, 100);

var pause = () => (clearInterval(idInterval), idInterval = null);

var stop = () => {
    pause();
    for (var i = viewRects.length-1; i >= 0; i--) {
        viewRects[i].getElementsByClassName('visible')[0].className = '';
        viewRects[i].firstElementChild.className = 'visible'
    }
}
but can't still explain
Keon Samuel
@keonsam
Apr 09 2017 10:47
flashy
heroiczero
@heroiczero
Apr 09 2017 10:48
@Gedokawa so did you answer correctly? if you didn't, I could try to explain the assignment more.
Grzegorz Sumara
@Gedokawa
Apr 09 2017 10:48
Yes I did
alpox
@alpox
Apr 09 2017 10:49

@keonsam
like...

function findElement(arr, func) {
    return arr.find(func);
}

? :-)

maxxero
@maxxero
Apr 09 2017 10:49

//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

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

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


       for(var j=0; j<contacts.length; j++){

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

       }}


         for(var k=0; k<contacts.length; k++){

         if(contacts[i].hasOwnProperty(prop) === false){
         return "No such property";
         }}


  }


// Only change code above this line


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