These are chat archives for FreeCodeCamp/HelpJavaScript

16th
Jun 2017
Diego Mayer
@Chrono79
Jun 16 2017 00:02
@Duffy125 use == or === to compare (unless the table specifies <= or >=), = is used to assign values
Duffy125
@Duffy125
Jun 16 2017 00:05

function golfScore(par, strokes) {
// Only change code below this line
if (strokes ==1)
{return "Hole-in-one!";}
else if(strokes <=par-2)
{return "Eagle";}
else if (strokes==par - 1 )
{return "Birdie";}
else if (strokes==par)
{return "Par";}
else if (strokes == par +1)
{return "Bogey";}
else if (strokes == par +2)
{ return "Double Bogey";}
else if(strokes >= par + 3)
{return " Go Home!";}

return (par,strokes);

its saying the Go Home is wrong
Diego Mayer
@Chrono79
Jun 16 2017 00:06
@Duffy125 you have a space before Go, delete it
Duffy125
@Duffy125
Jun 16 2017 00:07
haha yep that it thanks
Diego Mayer
@Chrono79
Jun 16 2017 00:07
:+1:
click more info below to see how to format your code for the chat room (that'll make it easier to read)
CamperBot
@camperbot
Jun 16 2017 00:07
:bulb: to format code use backticks! ``` more info
Lance Ward
@Lanceward410
Jun 16 2017 00:13
Damnn I was stumped, like REALLY stuck on the first handful of algorithms
For Js... but now I've spent so much time looking for answers and trying/failing to do these that I've learned so many new things and this was the first one I just breezed through

function confirmEnding(str, target) {

 if ( str.substr((str.length - target.length), target.length) === target) { return true; } else {
   return false;
 }

}

confirmEnding("Bastian dog", "dog");
so happy
Lance Ward
@Lanceward410
Jun 16 2017 00:20
@Chrono79 What is it exactly you want me to do with it? I see you've got the correct answer
Diego Mayer
@Chrono79
Jun 16 2017 00:20
@Lanceward410 see how they don't return true or false there? And what you see is your own solution
Lance Ward
@Lanceward410
Jun 16 2017 00:21
@Chrono79 I see, I might as well just return the whole statement
Diego Mayer
@Chrono79
Jun 16 2017 00:21
exactly
Keon Samuel
@keonsam
Jun 16 2017 00:21
@florind2014 you want what?
Lance Ward
@Lanceward410
Jun 16 2017 00:21
@Chrono79 Well thanks for the good feedback!
CamperBot
@camperbot
Jun 16 2017 00:21
lanceward410 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4293 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 16 2017 00:21
:+1:
Lance Ward
@Lanceward410
Jun 16 2017 00:23
What do you think of my next one
function repeatStringNumTimes(str, num) {
  // repeat after me
var longstr = "";
  while (num > 0) {
    num--;
    longstr += str;
  }
  return longstr;
}

repeatStringNumTimes("abc", 3);
Diego Mayer
@Chrono79
Jun 16 2017 00:24
@Lanceward410 looks ok
there is more than one way of solving the challenges, but that one is fine
Lance Ward
@Lanceward410
Jun 16 2017 00:26
Yeah, for a couple I had to look up help and I found a detailed outline of multiple solutions for each... After reading that, I understood the syntax and mindset I need much better. It's been tremendously easier for me to think of solutions since I looked up those answers
Lifu Tao
@LifuTao
Jun 16 2017 00:32
@Lanceward410 it's unconventional but it works
But try to figure it out yourself before looking up solutions
Lance Ward
@Lanceward410
Jun 16 2017 00:34
@LifuTao Don't worry my keen eye for detail makes that learning style very worthwhile... How could I make my last code more simple?
Lifu Tao
@LifuTao
Jun 16 2017 00:36
var longStr="";
for(var i=0;i<num;i++)
{
longStr+=str;
}
return longStr;
@Lanceward410 , as of now using a while loop for this is good, but I think learning your way around the for loop will really benefit you as you deal with more complex situations
Stuhl
@Stuhl
Jun 16 2017 00:38
@LifuTao You always write without spaces between code ? It's harder to read that way mate
Lance Ward
@Lanceward410
Jun 16 2017 00:38
I think the while method is simpler :D
Eric Hasegawa
@EricHasegawa
Jun 16 2017 00:39
I'm on the "Finding the Longest Word in a String" challenge, can anyone help me out?
Lance Ward
@Lanceward410
Jun 16 2017 00:40
@EricHasegawa Use a for loop to check/compare each word's length
Lifu Tao
@LifuTao
Jun 16 2017 00:40
@Stuhl yeah I always write without spaces, in my C++ class the teacher said it was up to us to space or not
Eric Hasegawa
@EricHasegawa
Jun 16 2017 00:40
@Lanceward410 Okay I'll try that
Stuhl
@Stuhl
Jun 16 2017 00:42
@LifuTao Yeah but honestly it looks better with some space, because it creates less visual noise
Especially the for loop is a bit hard to look at and in more complex code, it would be messy to maintain and understand
Lance Ward
@Lanceward410
Jun 16 2017 00:44
Now if someone writes code without ever hitting Enter.... THAT is messy
Lifu Tao
@LifuTao
Jun 16 2017 00:44
@Stuhl I see what you're saying
Jeremy Rollinson
@rollinsons
Jun 16 2017 00:47
Question for the room....I'm finding that progressing through the levels is not "fixing" the core JS concepts in my mind. I think I need to undertake more exercises at each level in order to better build the muscle memory. My thinking is that, in the same way a musician practices basic scales over and over each day, I can do the same with JS. Does anyone have a good resource of this kind?
Long Nguyen
@longnt80
Jun 16 2017 00:48

@Lanceward410

Now if someone writes code without ever hitting Enter.... THAT is messy

it's called minified I think

@rollinsons w3school, they have exercises
Lance Ward
@Lanceward410
Jun 16 2017 00:50
@rollinsons https://www.w3schools.com/js/js_string_methods.asp has just about every bit of knowledge there is to know about beginner code. It has a "try it yourself" for every single method, and even if you don't use that, just the pure exposure to all of the content every time you go searching for something helps me learn more
emorgan05
@emorgan05
Jun 16 2017 00:50
Hi All, I'm doing the Profile lookup, and I'm getting a warning about an infinite loop. Any suggestions?
Long Nguyen
@longnt80
Jun 16 2017 00:50
@rollinsons if you want to read more, there's also MDN
emorgan05
@emorgan05
Jun 16 2017 00:50

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

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

Diego Mayer
@Chrono79
Jun 16 2017 00:50
@emorgan05 where are you using i? contacts is an array
Jeremy Rollinson
@rollinsons
Jun 16 2017 00:51
Thanks @longnt80 @Lanceward410 , I'll check out W3.
CamperBot
@camperbot
Jun 16 2017 00:51
rollinsons sends brownie points to @longnt80 and @lanceward410 :sparkles: :thumbsup: :sparkles:
:cookie: 380 | @longnt80 |http://www.freecodecamp.com/longnt80
:cookie: 252 | @lanceward410 |http://www.freecodecamp.com/lanceward410
emorgan05
@emorgan05
Jun 16 2017 00:51
I was using i in the while statement to say, only if we have stuff left in the array
Dhrumit Thakkar
@Dhrumit14
Jun 16 2017 00:51
Hello
javascript is keep printing the value instead of changing the previous one
does any body know what's the solution for it ?
Diego Mayer
@Chrono79
Jun 16 2017 00:51
@emorgan05 to access a single contact you should use i contacts[i] <- like that
hasOwnProperty returns a boolean value
@Dhrumit14 show your code
emorgan05
@emorgan05
Jun 16 2017 00:53
@Chrono79 Right, but I was trying to cycle through the list of contacts and stop when I finish the list. That's why I put while i < array.length
Diego Mayer
@Chrono79
Jun 16 2017 00:54
@emorgan05 your code does the same each loop if you don't use i inside
Dhrumit Thakkar
@Dhrumit14
Jun 16 2017 00:54
@Chrono79

$(document).ready(function() {

function codeAddress() {
    var changeTemp = document.getElementById("CtoF").innerHTML;
    console.log(changeTemp);
    window.onload = codeAddress;
    $("#CtoF").on("click", function() {
        if (changeTemp === "℃") {
            changeTemp = "℉";
        } else {
            changeTemp = "℃";
        }
        document.getElementById("CtoF").innerHTML = changeTemp;
        console.log(changeTemp);
    });

}
var cityName = $("#weatherSearch").val();
var key = "d1533e8cd0767e04eca3f7b99ffe166a";

$("#weatherMe").on("click", function() {

    console.log(cityName);
    $.getJSON('http://api.openweathermap.org/data/2.5/weather?' + '&q=' + cityName + '&APPID=' + key, function(json) {
        var TempInKelvin = json.main.temp;
        console.log(TempInKelvin);
        var Pressure = json.main.pressure;
        console.log(Pressure);
        var Humadity = json.main.humidity;
        console.log(Humadity);
        var MinTempInKelvin = json.main.temp_min;
        console.log(MinTempInKelvin);
        var MaxTempInKelvin = json.main.temp_max;
        console.log(MaxTempInKelvin);

        // var Condition = [];
        var Condition = json.weather[0].description;
        console.log(Condition);

        var image = new Image();
        image.src = "Temp.jpg";
        image.height = 100;
        image.width = 100;

        if (TempInKelvin === '') {
            TempInKelvin = 'unknown';

        } else if (changeTemp === "℃") {
            var TemInCelcius = TempInKelvin - 273.15;
            $(".temp").append(image, +TemInCelcius + "℃");

        } else {
            var TempInFahrenheit = ((9 / 5) * (TempInKelvin - 273) + 32);
            $(".temp").append(image, +TempInFahrenheit + "℉");

        }

    });


});

});

Eric Hasegawa
@EricHasegawa
Jun 16 2017 00:55
@Lanceward410 I'm still quite lost, can you help?
Dhrumit Thakkar
@Dhrumit14
Jun 16 2017 00:55

@Chrono79

Plesae consider this one

$(document).ready(function() {

var changeTemp = document.getElementById("CtoF").innerHTML;
console.log(changeTemp);
window.onload = codeAddress;
$("#CtoF").on("click", function() {
    if (changeTemp === "℃") {
        changeTemp = "℉";
    } else {
        changeTemp = "℃";
    }
    document.getElementById("CtoF").innerHTML = changeTemp;
    console.log(changeTemp);
});


var cityName = $("#weatherSearch").val();
var key = "d1533e8cd0767e04eca3f7b99ffe166a";

$("#weatherMe").on("click", function() {

    console.log(cityName);
    $.getJSON('http://api.openweathermap.org/data/2.5/weather?' + '&q=' + cityName + '&APPID=' + key, function(json) {
        var TempInKelvin = json.main.temp;
        console.log(TempInKelvin);
        var Pressure = json.main.pressure;
        console.log(Pressure);
        var Humadity = json.main.humidity;
        console.log(Humadity);
        var MinTempInKelvin = json.main.temp_min;
        console.log(MinTempInKelvin);
        var MaxTempInKelvin = json.main.temp_max;
        console.log(MaxTempInKelvin);

        // var Condition = [];
        var Condition = json.weather[0].description;
        console.log(Condition);

        var image = new Image();
        image.src = "Temp.jpg";
        image.height = 100;
        image.width = 100;

        if (TempInKelvin === '') {
            TempInKelvin = 'unknown';

        } else if (changeTemp === "℃") {
            var TemInCelcius = TempInKelvin - 273.15;
            $(".temp").append(image, +TemInCelcius + "℃");

        } else {
            var TempInFahrenheit = ((9 / 5) * (TempInKelvin - 273) + 32);
            $(".temp").append(image, +TempInFahrenheit + "℉");

        }

    });


});

});

Lance Ward
@Lanceward410
Jun 16 2017 00:56
@EricHasegawa Establish a variable "longestword" equal to 0.
Eric Hasegawa
@EricHasegawa
Jun 16 2017 00:56
@Lanceward410 Okay done
Lance Ward
@Lanceward410
Jun 16 2017 00:56
@EricHasegawa Use your loop to check whether each word in your string is longer than longestWord. If it is larger, then longestWord should change.
Eric Hasegawa
@EricHasegawa
Jun 16 2017 00:57
@Lanceward410 How do I set that up
Diego Mayer
@Chrono79
Jun 16 2017 00:57
@Dhrumit14 are you using codepen?, if so, paste the link
Lance Ward
@Lanceward410
Jun 16 2017 00:57
@EricHasegawa You will probably use this for many later applications, so I'll tell you this: .split(" ") will break your string up into an array of words. I can't really give you the answer, but that is a basic outline of a solution
Eric Hasegawa
@EricHasegawa
Jun 16 2017 00:58
@Lanceward410 I know that I'll have to use that in here, I just don't know how
Lance Ward
@Lanceward410
Jun 16 2017 00:59
@EricHasegawa If you store your split up array in another variable (maybe call it "arr") It may make it easier to work with
arr[0] is the first word in the string. arr[1] is the second word. You will replace this with arr[i] in your for loop to indicate that your code is going to run on each word in the array one by one.
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:03
@Lanceward410 Here's my code so far

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

var longestWord = 0;

for ( i=0; i <= splitString.length; i++ )

if (splitString.length > longestWord) {

  return splitString.length; 
}

else { return longestWord;
}

}

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

pahosler
@pahosler
Jun 16 2017 01:03
Lance Ward
@Lanceward410
Jun 16 2017 01:05
@EricHasegawa In your for loop parameters, make i less than (<) not Less than/equal to (<=). This is because the array starts at 0, and if you account for that then the last item in your array will technically be @ position (array.length - 1)
@EricHasegawa And since you want the for loop to SAVE the value of the longest word, not simply return any one value, you should use a different method inside your if/else statement
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:07
@Lanceward410 What do you mean?
Lifu Tao
@LifuTao
Jun 16 2017 01:07
@EricHasegawa or just do for(i=0;i<splitString.length;i++)
thats what i do
Lance Ward
@Lanceward410
Jun 16 2017 01:08
@EricHasegawa So if splitArray[i] is greater than longestWord, you want longestWord to change. So you could assign it like this: longestWord = splitArray[i];
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:08
@Lanceward410 What would splitArray be in my current code
Lance Ward
@Lanceward410
Jun 16 2017 01:08
Then when the for loop is finished running, your variable "longestWord" should hold a value equal to the longest word in the array
wait I mean splitString[i].length, I'm sorry
Dhrumit Thakkar
@Dhrumit14
Jun 16 2017 01:09
Weather.png
@LifuTao
Lance Ward
@Lanceward410
Jun 16 2017 01:09
Not splitArray[i]
Dhrumit Thakkar
@Dhrumit14
Jun 16 2017 01:10
@LifuTao For each click it's printing separate result instead of updating the previous one
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:11
@Lanceward410 My code still isn't working at all,
Diego Mayer
@Chrono79
Jun 16 2017 01:11
@Dhrumit14 that's because you used append
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:11
@Lanceward410
'''
CamperBot
@camperbot
Jun 16 2017 01:11
:bulb: to format code use backticks! ``` more info
Dhrumit Thakkar
@Dhrumit14
Jun 16 2017 01:11
@Chrono79 What should I use instead of append
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:12
@Lanceward410
Diego Mayer
@Chrono79
Jun 16 2017 01:12
html?
Lance Ward
@Lanceward410
Jun 16 2017 01:12
shift+enter
Lifu Tao
@LifuTao
Jun 16 2017 01:12
@Dhrumit14 I completed the project you completed, I'll link it and you I'll explain it
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:12
function findLongestWord(str) {
  var splitString = str.split(' ');

  var longestWord = 0;

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

    if (splitString[i].length > longestWord) {

      splitString[i] = longestWord;

    } else { 

    return longestWord; 
    }
       }





}

findLongestWord("The quick brown fox jumped over the lazy dog");
function findLongestWord(str) {
  var splitString = str.split(' ');

  var longestWord = 0;

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

    if (splitString[i].length > longestWord) {

      splitString[i] = longestWord;

    } else { 

    return longestWord; 
    }
       }





}

findLongestWord("The quick brown fox jumped over the lazy dog");
@Lanceward410 My bad hahah I was having trouble formatting the code
Dhrumit Thakkar
@Dhrumit14
Jun 16 2017 01:13
@Chrono79 : I tried it
Lifu Tao
@LifuTao
Jun 16 2017 01:13
@EricHasegawa you didn't declare i as a variable
Stephen James
@sjames1958gm
Jun 16 2017 01:13
@EricHasegawa YOu need to update longest word (which means longestWord = ?
Also, your retrun should be after the loop
Diego Mayer
@Chrono79
Jun 16 2017 01:13
@Dhrumit14 and?
Dhrumit Thakkar
@Dhrumit14
Jun 16 2017 01:13
it din work
@LifuTao oh okay
Diego Mayer
@Chrono79
Jun 16 2017 01:13
link to your codepen
Dhrumit Thakkar
@Dhrumit14
Jun 16 2017 01:14
I am not using codepen
Lance Ward
@Lanceward410
Jun 16 2017 01:14
@EricHasegawa So there's a problem. Within the if statement, you are setting a word equal to a number. You want to be setting that number equal to the length of that word
Dhrumit Thakkar
@Dhrumit14
Jun 16 2017 01:14
$(".temp").html(image, +TemInCelcius + "℃"); @Chrono79
Diego Mayer
@Chrono79
Jun 16 2017 01:14
then do it, it's easier to see what your code does
Lance Ward
@Lanceward410
Jun 16 2017 01:15
@EricHasegawa The order that you place the variables in counts. You are very close to the answer
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:15
@Lanceward410 I'm not sure how to get it working
Stephen James
@sjames1958gm
Jun 16 2017 01:16
@EricHasegawa Only in special circumstances do you want to return inside a loop.
@EricHasegawa
splitString[i] = longestWord;
should be
longestWord = splitString[i].length;
Joseph
@revisualize
Jun 16 2017 01:16
This is not one of them.
Lance Ward
@Lanceward410
Jun 16 2017 01:16
splitString[i].length *
Stephen James
@sjames1958gm
Jun 16 2017 01:17
@Lanceward410 THanks
@revisualize :)
Lifu Tao
@LifuTao
Jun 16 2017 01:17
 $("#inCelsius").click(function(){
    $("#temperature").html(tempInCelsius+"°C");  
    });
Joseph
@revisualize
Jun 16 2017 01:17
Ive been on this bus for an hour. This sucks.
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:18
@sjames1958gm I'm not sure how else I'd set it up
Joseph
@revisualize
Jun 16 2017 01:18
I am 25min away via bike.
5 miles.
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:18
@Lanceward410 I really don't know how to progress
Joseph
@revisualize
Jun 16 2017 01:18
Grrrrr....
Lifu Tao
@LifuTao
Jun 16 2017 01:18
So I had a button with the id #inCelsius and on click of the button, the id element inside of the button "temperature" 's HTML changes
Lance Ward
@Lanceward410
Jun 16 2017 01:19
@EricHasegawa What don't you understand from the last couple messages specifically? I can help clear it up
Dhrumit Thakkar
@Dhrumit14
Jun 16 2017 01:19
@LifuTao @Chrono79 : If I use .html than I'm not getting image
$(".temp").html(image + TempInFahrenheit + "℉");
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:20
@Lanceward410 I don't know what order to place my variables in, or where my return should be, or why the code isn't working in general
Jeremy Rollinson
@rollinsons
Jun 16 2017 01:20
Thanks @pahosler , I have signed up for that site, very helpful :)
CamperBot
@camperbot
Jun 16 2017 01:20
rollinsons sends brownie points to @pahosler :sparkles: :thumbsup: :sparkles:
:cookie: 373 | @pahosler |http://www.freecodecamp.com/pahosler
Lance Ward
@Lanceward410
Jun 16 2017 01:21
@EricHasegawa Okay so, when assigning variables, you always put the variable you are changing first. So when I set x equal to 2, I write x = 2 . Do NOT write 2 = x
pahosler
@pahosler
Jun 16 2017 01:21
I enjoy it :D
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:23
@Lanceward410 Okay I fixed that
Lifu Tao
@LifuTao
Jun 16 2017 01:23
@Dhrumit14 so if you want the image you have to change the href (link ) of it using $(#element).attr(src,"link")
Lance Ward
@Lanceward410
Jun 16 2017 01:23
@EricHasegawa The return method ends a function and returns it to the beginning. Your code will execute in the order that you type it in. If you want to use a FOR LOOP to find the longest word, then RETURN thte longest word, you must place the RETURN on the OUTSIDE of the for loop.
Lifu Tao
@LifuTao
Jun 16 2017 01:24
html just basically changes the wording
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:24
@Lanceward410
function findLongestWord(str) {
   var longestWord = 0;

  var splitString = str.split(' ');

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

    if (splitString[i].length > longestWord.length) {

      longestWord = splitString[i].length;


    }
       }

  return longestWord;




}

findLongestWord("The quick brown fox jumped over the lazy dog");
Now my if statement seems wrong
Abhilash Kumar
@apravink
Jun 16 2017 01:25
Hi
Stephen James
@sjames1958gm
Jun 16 2017 01:25
@EricHasegawa longestWord is a number, don't use .length
Lance Ward
@Lanceward410
Jun 16 2017 01:25
@EricHasegawa Lool yes. So, longestWord is already a number
Abhilash Kumar
@apravink
Jun 16 2017 01:25
I'm trying to dynamically adjust my href on a <a> tag but i get the following error
Unsafe JavaScript attempt to initiate navigation for frame with URL 'https://www.wikipedia.org/' from frame with URL 'https://s.codepen.io/boomerang/iFrameKey-8327d59c-11ad-7f21-c76a-6604a4156689/index.html?editors=1011'. The frame attempting navigation is sandboxed and is trying to navigate a popup, but is not the popup's opener and is not set to propagate sandboxing to popups.
Eric Hasegawa
@EricHasegawa
Jun 16 2017 01:26
@Lanceward410 @sjames1958gm Hahaha that was dumb of me, thank you guys for the help it's working now!
CamperBot
@camperbot
Jun 16 2017 01:26
erichasegawa sends brownie points to @lanceward410 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 254 | @lanceward410 |http://www.freecodecamp.com/lanceward410
:star2: 7782 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Abhilash Kumar
@apravink
Jun 16 2017 01:26
Does anyone know what this means?. I tried googling it but I dont quite understand the stack overflow answers
Stephen James
@sjames1958gm
Jun 16 2017 01:26
@EricHasegawa :+1:
@apravink It has to do with navigation from inside an iframe. You need to open a new window when doing that using.
You need target="_blank" in your <a>
It is a security mechism
Abhilash Kumar
@apravink
Jun 16 2017 01:29
Thanks @sjames1958gm
CamperBot
@camperbot
Jun 16 2017 01:29
apravink sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7783 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 16 2017 01:29
@apravink you're welcome
Lance Ward
@Lanceward410
Jun 16 2017 01:29
@EricHasegawa It is all this difficulty that helps us learn best. There are thousands of potential errors to make while coding, but rest assured knowing that you usually won't make the same one multiple times. This is the magic of compounded learning.
Duffy125
@Duffy125
Jun 16 2017 01:29

var count = 0;

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

what am i missing
Lance Ward
@Lanceward410
Jun 16 2017 01:30
@Duffy125 the return function ENDS your code. You want it to keep running after the count is increased or decreased.
wait
mackyking
@mackyking
Jun 16 2017 01:31
I need help...
I can't get the golf code...
Lance Ward
@Lanceward410
Jun 16 2017 01:32
I read your code all wrong nevermind.
Paul Christian L. Catoera
@poncatoera
Jun 16 2017 01:32
anyone can help me? how do i rename multiple files in a folder to their modified date but minus 5 minutes?
mackyking
@mackyking
Jun 16 2017 01:33

‛‛‛ function golfScore(par, strokes) {
// Only change code below this line

return "Change Me";
// Only change code above this line
}

// Change these values to test
golfScore(5, 4); ‛‛‛

Duffy125
@Duffy125
Jun 16 2017 01:33
I have a felling its something with return but i cant point it out
Mitchell Wilson
@mitchew
Jun 16 2017 01:33
Is there someone available to review my code for "Symmetric Difference". It isn't working as intended.
Abhilash Kumar
@apravink
Jun 16 2017 01:33
@sjames1958gm Now I have a new error :I
Mixed Content: The page at 'https://codepen.io/abhiwan/pen/VWaXNv?editors=1011' was loaded over HTTPS, but requested an insecure resource 'http://en.wikipedia.org/?callback=?&curid=45692901'. This request has been blocked; the content must be served over HTTPS.
Paul Christian L. Catoera
@poncatoera
Jun 16 2017 01:33
anyone can help me? how do i rename multiple files in a folder to their modified date but minus 5 minutes?
Stephen James
@sjames1958gm
Jun 16 2017 01:33
@apravink Change your http to https
Abhilash Kumar
@apravink
Jun 16 2017 01:34
@sjames1958gm Cant believe i didnt try that!. Thanks!!
CamperBot
@camperbot
Jun 16 2017 01:34
apravink sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: apravink already gave sjames1958gm points
Lance Ward
@Lanceward410
Jun 16 2017 01:34
@Duffy125 Oo! yes it is
Stephen James
@sjames1958gm
Jun 16 2017 01:34
@mackyking This challenge is a series of if / else if/ else if comparing strokes to par per the table (special case is strokes === 1)
Lance Ward
@Lanceward410
Jun 16 2017 01:35
@Duffy125 So by returning count + "bet"; Your final answer would come out as "5bet". You want to make it so there's a space in between the count and the decision.
Stephen James
@sjames1958gm
Jun 16 2017 01:35
@Duffy125 Your output looks like 5Bet when it should be 5 Bet
Diego Mayer
@Chrono79
Jun 16 2017 01:35
@Duffy125 you need a space between count and the string
And in the code you pasted it, it's missing a } at the end
mackyking
@mackyking
Jun 16 2017 01:36
Can you give me the correct syntax for this golf code? Please...
Thanks @sjames1958gm
CamperBot
@camperbot
Jun 16 2017 01:36
mackyking sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7784 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 16 2017 01:40

@mackyking

if (condition) {
   return "String";
} else if (condition) {
}

where the conditions are the comparisons of strokes to par.
Return the appropriate "String"

Duffy125
@Duffy125
Jun 16 2017 01:44
So I did all that still not passing
Lance Ward
@Lanceward410
Jun 16 2017 01:45
like 10 of my eyelashes just fell out
Duffy125
@Duffy125
Jun 16 2017 01:46

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";
}else {
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');

Lance Ward
@Lanceward410
Jun 16 2017 01:47
@Duffy125 Add the space INSIDE of the "Bet" and "Hold" quotes. It's very case sensitive and only what is within the quotes will be returned in the string
e.g. "Hello" + " " + "World" equals "Hello World"
Duffy125
@Duffy125
Jun 16 2017 01:48
yeah I though you meet of the + not the "
Lance Ward
@Lanceward410
Jun 16 2017 01:48
Unless I'm just blind and you already have them
Does it work after that?
Frank McCroy
@fmccroy
Jun 16 2017 01:49
I am working on the Weather challenge, and am trying to send a request to the darksky API, but nothing shows up on my screen, and my console shows this error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.darksky.net/forecast/37b20e267924f791637d860e18fb91b1/30.332184,-81.655647. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). How do I allow the request so that I can do what I need? I use Firefox for my browser, but Chrome shows the same error.
Duffy125
@Duffy125
Jun 16 2017 01:49
yes that was a pass. thank you. hope your your eyes are not dead
Kyle Holm
@thekholm80
Jun 16 2017 01:50
@fmccroy have you tried using https://crossorigin.me/ then your url?
Lance Ward
@Lanceward410
Jun 16 2017 01:50
Sweet, that means they're still good for another day.
Frank McCroy
@fmccroy
Jun 16 2017 01:51
@thekholm80 After Googling the problem, that was never mentioned. Will I need the extra URL every time I try to use an API?
Kyle Holm
@thekholm80
Jun 16 2017 01:51
not every time, just often when using APIs in codepen
every api has their own Access-Control-Allow-Origin policy
Frank McCroy
@fmccroy
Jun 16 2017 01:53
Would it work better in a different editor, like Brackets, or it’s caused by the API itself?
Kyle Holm
@thekholm80
Jun 16 2017 01:53
the problem is the request originates in your browser, then gets forwarded through codepen on to the api
so the end points don't match
unless I completely misunderstand the process, anyway
Frank McCroy
@fmccroy
Jun 16 2017 01:55
That sucks.. so somewhere one of the sites thinks there is a security issue. The link you gave made my code work, thanks!
Kyle Holm
@thekholm80
Jun 16 2017 01:56
:+1:
Frank McCroy
@fmccroy
Jun 16 2017 01:56
err.. thanks @thekholm80. Can’t forget the brownie points :)
CamperBot
@camperbot
Jun 16 2017 01:56
fmccroy sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1074 | @thekholm80 |http://www.freecodecamp.com/thekholm80
Kyle Holm
@thekholm80
Jun 16 2017 01:56
if it makes you feel better, when I make api calls from one port on my computer to another I have to allow cross origin requests lol
Stephen James
@sjames1958gm
Jun 16 2017 01:57
@fmccroy Are you using jquery?
Frank McCroy
@fmccroy
Jun 16 2017 01:57
Is there something you can add to your code to do that, or you have to use the other site as well?
@sjames1958gm Yes, using Jquery.
Stephen James
@sjames1958gm
Jun 16 2017 01:58
@fmccroy You can use a mechanism called JSONP which circumvents CORS, if the API supports it.
Add &callback=? to your URL
Kyle Holm
@thekholm80
Jun 16 2017 01:58
i can allow it in my web server settings @fmccroy
Stephen James
@sjames1958gm
Jun 16 2017 01:59
@fmccroy It is the server that sets the header that your browser checks before accepting the API response.
Otto Cedeno
@ottocedeno
Jun 16 2017 02:11
Stuck on the "Stand in Line" test in Javascript path. Anyone else get stuck here?
Stephen James
@sjames1958gm
Jun 16 2017 02:13
@ottocedeno
You should be using your two parameter arr, item in the function.
You can show your code.
Otto Cedeno
@ottocedeno
Jun 16 2017 02:14

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

return item; // Change this line
}

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

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

stuck on the part where it asks "return the element that was removed"
Stephen James
@sjames1958gm
Jun 16 2017 02:16
@ottocedeno Close - arr.shift returns the value that was removed - you need to return that value.
Mai Thinh
@mthinh
Jun 16 2017 02:17

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

}
}
}
// Only change code above this line

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

should I use For loop for this ?
pls help me
Stephen James
@sjames1958gm
Jun 16 2017 02:17

@ottocedeno
You can assign the return from arr.shift() to item since you return item

arr.shift(0);// Your code here
return item; // Change this line

or replace the above with

return arr.shift();
Diego Mayer
@Chrono79
Jun 16 2017 02:17
@mthinh yes
Otto Cedeno
@ottocedeno
Jun 16 2017 02:18
@sjames1958gm so the "return arr.shift()" should replace my current return
Stephen James
@sjames1958gm
Jun 16 2017 02:18
@mthinh Yes, a for loop is needed so you can check each contact in the array per the instructions
Diego Mayer
@Chrono79
Jun 16 2017 02:18
@ottocedeno shift doesn't use arguments, it will ignore what you put inside the parentheses
Stephen James
@sjames1958gm
Jun 16 2017 02:18
@ottocedeno Yes, but you need to only have one arr.shift(), so if you do remove the other
Otto Cedeno
@ottocedeno
Jun 16 2017 02:20
Ah got it. so putting the arr.shift() in return serves two fold, 1) doing the actual shift part, but then 2) returning the value that was shifted out.
very tricky lesson. Probably the hardest one yet.
mackyking
@mackyking
Jun 16 2017 02:27
@sjames1958gm what value should i put in this open and clos parenthesis? if (what condition?) {
return "String";
} else if (condition) {
}
Michael N. Manteo
@michaelmanteo
Jun 16 2017 02:28
'code' var test = "test ": 'code'
Mai Thinh
@mthinh
Jun 16 2017 02:34

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

function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i =0; i < contacts.length; i++){
if(contacts[i]["firstName"] === firstName && contacts[i][prop] === true){
console.log(contacts[i][prop]);

}else if(contacts[i]["firstName"] === firstName && contacts[i][prop]=== false ){
console.log('No such property');
}else{
console.log('No such contact');
}

}
}

// Only change code above this line

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

what did I do wrong ?
Diego Mayer
@Chrono79
Jun 16 2017 02:37
@mthinh contacts[i][prop] === true <- that's wrong
Your function should return instead of console.log and think about when you can return No such contact
Mai Thinh
@mthinh
Jun 16 2017 02:37
@Chrono79 what i have to deal with that ?
Diego Mayer
@Chrono79
Jun 16 2017 02:38
@mthinh use hasOwnProperty
Piyush Tiwari
@piyush805
Jun 16 2017 02:38

#252 Caesars Cipher

In String.fromCharCode(num1[, ...[, numN]]), all these numbers can be in an array? Will it return same?
Or do I need to store it in by for loop for each array element and join('')?

 var code_old=[];                       //Storing old alphabet codes in code_old
  for (var i=0; i < str.length; i++) {
    code_old[i]=str.charCodeAt(i);
  }                                      //Changing ONLY alphabets code by reducing 13 else unchanged
  for (i=0;i<str.length;i++){
    if(code_old[i] > 64 && code_old[i] < 92)
      code_old[i] -= 13;
    else
      code_old[i] -= 0;    
  }
    var str2;
    return str2.fromCharCode(code_old);
    //var arr; 
    //var a;
  //for (i=0;i<str.length;i++){
   //a=str2.fromCharCode(code_old.shift());
   //arr.push(str2.fromCharCode(code_old.shift())); 
  //}
  //return arr.join('');
 // return newstr;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Mai Thinh
@mthinh
Jun 16 2017 02:38
@Chrono79 thank you very much
CamperBot
@camperbot
Jun 16 2017 02:38
mthinh sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4294 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 16 2017 02:39
@piyush805 you could use spread operator, an array won't work, unless you use map or something like that
Piyush Tiwari
@piyush805
Jun 16 2017 02:39
@Chrono79 Store in spread operator and join?
Diego Mayer
@Chrono79
Jun 16 2017 02:40
no
var arr = [1, 2, 3];
console.log(...arr); // 1, 2, 3
You can use String.fromCharCode(...arr);
Note it's String, the class, not any string
Piyush Tiwari
@piyush805
Jun 16 2017 02:44
@Chrono79 It says 'spread/rest operator' is only available in ES6(use 'esversion 6').
Diego Mayer
@Chrono79
Jun 16 2017 02:45
@piyush805 then write 'esversion: 6'; at the top
Piyush Tiwari
@piyush805
Jun 16 2017 02:49
@Chrono79 It still has warning on it, but at least it is giving some output.
Diego Mayer
@Chrono79
Jun 16 2017 02:50
@piyush805 you can solve it with only one loop, why don't you replace each letter with its decoded version?
mackyking
@mackyking
Jun 16 2017 02:50
@sjames1958gm what value should i put in this open and clos parenthesis? if (what condition?) {
return "String";
} else if (condition) {
}
Abhishek Tiwari
@fillopfy
Jun 16 2017 02:50
var reg=/[&<>"']/gi;
  var re={"&":"&amp;",
          "<":"&lt;",
          ">":"&gt;",
          "\"":"&quot;",
          "\'":"&apos;"
         };


  return str.replace(reg,re[reg]);
what is wrong with this code
Piyush Tiwari
@piyush805
Jun 16 2017 02:51
@Chrono79 Letters with code<13 are problem as of now
Diego Mayer
@Chrono79
Jun 16 2017 02:51
@piyush805 rethink what you have to do, if the charcode is 65 and you subtract 13 the new code will fall outside of the capital letters range
Aizaz Shahid
@aizazshahid
Jun 16 2017 02:52
@cmccormack are you there ?
Piyush Tiwari
@piyush805
Jun 16 2017 02:52
@Chrono79 yeah
Abhishek Tiwari
@fillopfy
Jun 16 2017 02:52
@forwebtech hey can you check what is wrong with my code
Aizaz Shahid
@aizazshahid
Jun 16 2017 02:52
@fillopfy sure ? where is your code ?
Abhishek Tiwari
@fillopfy
Jun 16 2017 02:53
var reg=/[&<>"']/gi;
  var re={"&":"&amp;",
          "<":"&lt;",
          ">":"&gt;",
          "\"":"&quot;",
          "\'":"&apos;"
         };


  return str.replace(reg,re[reg]);
Aizaz Shahid
@aizazshahid
Jun 16 2017 02:54
@fillopfy i think re[reg] that's the problem. wait let me run it.
Mai Thinh
@mthinh
Jun 16 2017 02:54

@Chrono79 function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i =0; i < contacts.length; i++){
if(contacts[i]["firstName"]=== firstName){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}else{
return 'No such property';
}

} else{
return 'No such contact';
}

}
}

what i miss here? i only do right 2 case
Abhishek Tiwari
@fillopfy
Jun 16 2017 02:55
@forwebtech but logically, it should replace it
Aizaz Shahid
@aizazshahid
Jun 16 2017 02:55
@fillopfy well but reg is your regex not the property name :)
Diego Mayer
@Chrono79
Jun 16 2017 02:55
@mthinh why are you returning No such contact at the first mismatch?
Your loop won't run more than once like that
Aizaz Shahid
@aizazshahid
Jun 16 2017 02:56

@fillopfy put the callback method at the

replace( ... ,   (match)=>{
  console.log(match);
})

try to do that

Abhishek Tiwari
@fillopfy
Jun 16 2017 02:56
@forwebtech but after searching for reg in str, the value of reg should go inside re and it should return its equivalent prop
@forwebtech i didnt understand this arrow marks, what is it
Luis Felipe López G.
@luishendrix92
Jun 16 2017 02:57
it's a lighweight version of something like RxJS
Aizaz Shahid
@aizazshahid
Jun 16 2017 02:57
@fillopfy or
replace( ... ,   function(match) {
  console.log(match);
})
@fillopfy => that is a arrow function, ES6 syntax, forget it stick with older one :)
@fillopfy you can use the match as your property name.
Abhishek Tiwari
@fillopfy
Jun 16 2017 02:59
@forwebtech ok let me try doing that challenge
Mai Thinh
@mthinh
Jun 16 2017 03:02
@Chrono79 where you I return 'no such contact' ?
where should I ?
mackyking
@mackyking
Jun 16 2017 03:02
@sjames1958gm what value should i put in this open and clos parenthesis? if (what condition?) {
return "String";
} else if (condition) {
}
Diego Mayer
@Chrono79
Jun 16 2017 03:03
@mthinh When you didn't find a matching contact in the whole list
@mackyking compare strokes against the first column in the table and return the string at the second column
Joseph
@revisualize
Jun 16 2017 03:05
Hey.
mackyking
@mackyking
Jun 16 2017 03:05
@Chrono79 Sample syntax line please...
Diego Mayer
@Chrono79
Jun 16 2017 03:06
if (strokes == someValue) {
  return "someString";
} else if ...
Piyush Tiwari
@piyush805
Jun 16 2017 03:14
@Chrono79 thanks
CamperBot
@camperbot
Jun 16 2017 03:14
piyush805 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4295 | @chrono79 |http://www.freecodecamp.com/chrono79
Mai Thinh
@mthinh
Jun 16 2017 03:19
@Chrono79 sorry , but i still dont know where to put return 'No such contact' : (

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

}
}


} 

}

Diego Mayer
@Chrono79
Jun 16 2017 03:20
@mthinh you're only sure it wasn't in the contact list after you looked over all contacts (and didn't find it), and in the code, that is after the loop
meslance
@meslance
Jun 16 2017 03:21
Can someone explain to me what they are asking for in "Accessing Objects Properties with Variables"?
Mai Thinh
@mthinh
Jun 16 2017 03:22
@Chrono79 thank you , i finally understand :D
CamperBot
@camperbot
Jun 16 2017 03:22
mthinh sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: mthinh already gave chrono79 points
nit007
@nit007
Jun 16 2017 03:23
stuck with counting cards problem , any suggestions ? posting my code
Diego Mayer
@Chrono79
Jun 16 2017 03:31
@meslance see the checkmarks it's not so hard
playerNumber should contain a number, the number that has "Montana" as a value in testObj
Then use that var between brackets to get "Montana" from your object
Aizaz Shahid
@aizazshahid
Jun 16 2017 03:33
@Chrono79 do you try codewars ?
Diego Mayer
@Chrono79
Jun 16 2017 03:34
@forwebtech yes I do, I did (solved) a lot of katas
Aizaz Shahid
@aizazshahid
Jun 16 2017 03:35
so Decode the Morse code, advanced ? done that
Diego Mayer
@Chrono79
Jun 16 2017 03:36
@forwebtech Let me see
meslance
@meslance
Jun 16 2017 03:36
@Chrono79 Yeah probably. Brain is just fried from today I guess.
Diego Mayer
@Chrono79
Jun 16 2017 03:36
@forwebtech Yes, I did that
Aizaz Shahid
@aizazshahid
Jun 16 2017 03:37
@Chrono79 well i have solved it, how should i share ? i don't see any links of my solution ?
heidisdad2
@heidisdad2
Jun 16 2017 03:38
hey guyswha ts up
Joseph
@revisualize
Jun 16 2017 03:38
@Chrono79 Go comment about how awesome my idea is: freeCodeCamp/freeCodeCamp#15388
heidisdad2
@heidisdad2
Jun 16 2017 03:38
it seems as though i did one of the sections correctly but its not working for some reason
var value = 1;
function factorialize(num) {
  if(num<1){
    return value;
  }else{

  for(i=num; i>0; i--){
    num = value *=i;

    }
  return num;
  }
}
factorialize(0);
Aizaz Shahid
@aizazshahid
Jun 16 2017 03:39
@revisualize great idea :+1:
Joseph
@revisualize
Jun 16 2017 03:39
@heidisdad2 Global variables are NOT reset between the test runs.
heidisdad2
@heidisdad2
Jun 16 2017 03:40
what do you mean? my code works
Joseph
@revisualize
Jun 16 2017 03:40
value should be inside of your function.
Aizaz Shahid
@aizazshahid
Jun 16 2017 03:40

but @revisualize did you read that :

Hi @revisualize
The issue tracker is for reporting bugs only. If this is a request for help with a challenge, please use the help chat room or try looking through the forum for help with a specific challenge.
If this is the case, please close this issue.
Happy Coding.

Joseph
@revisualize
Jun 16 2017 03:41
@forwebtech That's some dumb automated bullship.
heidisdad2
@heidisdad2
Jun 16 2017 03:41
@revisualize let me give that a shot.. but i passed all the tests
Diego Mayer
@Chrono79
Jun 16 2017 03:41
@revisualize The bot didn't like it :P
Aizaz Shahid
@aizazshahid
Jun 16 2017 03:41
@revisualize but that is for issues, not for instructions.
@Chrono79 did you check my solution ?
Diego Mayer
@Chrono79
Jun 16 2017 03:42
@forwebtech not yet
heidisdad2
@heidisdad2
Jun 16 2017 03:42
@revisualize yes you were correct i moved the variable and it let me pass.. but when i was doing the test before i tried it your way all the tests were passed.
pursuitgit
@pursuitgit
Jun 16 2017 03:43
HI friends can anyone help me with the truncate a string challenge? I've got the first two tests to pass but can't get the last 4 to pass.

function truncateString(str, num) {
  // Clear out that junk in your trunk
  if (str.length >= num) {
      str = str.substring(0, num-3);
      return str + "...";
  }
  else {
    return false;
  }
}

truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length);
my code ^ :D
Aizaz Shahid
@aizazshahid
Jun 16 2017 03:43
@Chrono79 ok, when you will have time, then check it if any refactoring possible.
pursuitgit
@pursuitgit
Jun 16 2017 03:43
just looking for direction if anyone can help, not an answer
Diego Mayer
@Chrono79
Jun 16 2017 03:43
@forwebtech At this hour I can't even look at my own code ;)
But I promise I'll check yours some other time
Aizaz Shahid
@aizazshahid
Jun 16 2017 03:44
@Chrono79 thanks, and np !
CamperBot
@camperbot
Jun 16 2017 03:44
forwebtech sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4296 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 16 2017 03:44
@pursuitgit shouldn't you check if num <= 3 somewhere?
pursuitgit
@pursuitgit
Jun 16 2017 03:44
@chrono so I should do an elseif?
Diego Mayer
@Chrono79
Jun 16 2017 03:45
and why are you returning false?
pursuitgit
@pursuitgit
Jun 16 2017 03:45
@Chrono79 It was just for testing purposes till I could figure it out >.< not sure if that's bad practice or not
Diego Mayer
@Chrono79
Jun 16 2017 03:45
Read the instructions carefully again, 50% of the challenge is to understand what to do
pursuitgit
@pursuitgit
Jun 16 2017 03:46
Ok I'll have a dig
Diego Mayer
@Chrono79
Jun 16 2017 03:46
:+1:
some nested if could be useful there
@revisualize I agree a lot of people don't understand how to use a function, but I think maybe reordering some challenges, for instance, Passing Values to Functions with Arguments before Converting Celsius to Fahrenheit would help
pursuitgit
@pursuitgit
Jun 16 2017 03:47
@Chrono79 that's why we're at freecodecamp!
Joseph
@revisualize
Jun 16 2017 03:48
I could create a video about the whole thing. But, I don't know if that's warrented.
Diego Mayer
@Chrono79
Jun 16 2017 03:49
Maybe a related challenges part would help too
People do the array manipulation challenges and then when they reach Stand in Line have no clue on what to do
The same with Word Blanks
@pursuitgit I'm just discussing how FCC could improve its map
Joseph
@revisualize
Jun 16 2017 03:53
Well, hopefully, my issue gets addressed somehow.
Nathaniel Suchy
@nsuchy
Jun 16 2017 03:53
I think the entire freecodecamp system is open source
if your up to the challenge do a PR
:)
Joseph
@revisualize
Jun 16 2017 03:53
It is.
I'm not.
Diego Mayer
@Chrono79
Jun 16 2017 03:53
Did you check the beta @revisualize ?
Joseph
@revisualize
Jun 16 2017 03:54
I did.
Diego Mayer
@Chrono79
Jun 16 2017 03:54
Have they improved something there?
Joseph
@revisualize
Jun 16 2017 03:54
Nope.
There are not any additional Basic lessons about functions.
Diego Mayer
@Chrono79
Jun 16 2017 03:55
Not even an order change?
Mario Ley Tello
@23marioley
Jun 16 2017 03:55
How can I select a block of code and comment it with a command??
Joseph
@revisualize
Jun 16 2017 03:55
@nsuchy I don't know how to make a pull request nor do I have the time to craft up a whole series of lessons.
@Chrono79 There's a little bit of an order change but, not much.
Nathaniel Suchy
@nsuchy
Jun 16 2017 03:57
@revisualize That’s the fastest way to get a feature
to implement it yourself of couse that’s not always practical
you could add an issue and see if their team is up to making a change
Adel
@AdelMahjoub
Jun 16 2017 03:58
Here it won't exit directly after stdin.end(), does that mean that anything inside is a readable stream, and it won't end unless the readable stream ends ?
process.stdin.on('data', function(chunk) {
  let input = Buffer.from(chunk).toString().replace(/[\r\n]/g, '');
  console.log(chunk);
  if(input === 'exit') {
    process.stdin.end();

    setTimeout(function() {

    }, 2000);
  }
});
Joseph
@revisualize
Jun 16 2017 03:59
@nsuchy You don't realize that we're discussing the issue that I created?
freeCodeCamp/freeCodeCamp#15388
Nathaniel Suchy
@nsuchy
Jun 16 2017 04:00
Was just providing suggestions but thanks for the link
Joseph
@revisualize
Jun 16 2017 04:01
That's the issue that I created about 30min ago.
Nathaniel Suchy
@nsuchy
Jun 16 2017 04:01
I’ll look over it tomrrow
Joseph
@revisualize
Jun 16 2017 04:01
Anyhow. It's 9pm here. I'm actually tired.
Nathaniel Suchy
@nsuchy
Jun 16 2017 04:01
It’s midnight here
I’ll be back tomorrow morning
goodnight everyone
Joseph
@revisualize
Jun 16 2017 04:01
I think I'm going to call it an early one.
Duffy125
@Duffy125
Jun 16 2017 04:02
function checkObj(checkProp) {
// Your Code Here
var myObj={
gift: "pony",
pet: "kitten",
bed: "sleigh",
};
if ( myObj.hasOwnProperty(myObj === true))
{return checkProp.myObj;
}else {
return "Not Found";
}}
i feel there something wrong with my if
Diego Mayer
@Chrono79
Jun 16 2017 04:03
@Duffy125 yes
myObj === true that part is wrong
and checkProp.myObj is wrong too (for 2 reasons)
Duffy125
@Duffy125
Jun 16 2017 04:05
if ( myObj.hasOwnProperty(checkProp === true))
Diego Mayer
@Chrono79
Jun 16 2017 04:05
See the example code again
Duffy125
@Duffy125
Jun 16 2017 04:05
ok
Diego Mayer
@Chrono79
Jun 16 2017 04:05
@Duffy125 better, but still wrong, watch out where you close your parentheses
:wave: 1am here, I'll call it a day
see ya
Duffy125
@Duffy125
Jun 16 2017 04:08
cool thanks
OldmanVimes
@OldmanVimes
Jun 16 2017 04:14
@Duffy125 did you solve it?
if (myObj.hasOwnProperty(checkProp)===true)
return val=myObj[checkProp];
else
return "Not Found";
This code works
Bethany Roberts
@Betanya
Jun 16 2017 04:17
In "Using Objects for Lookups" I'm trying to figure out how to incorporate the "val" and "result" in the function. Why do we define result, then return result at the end? Thanks!
// Setup
function phoneticLookup(val) {
  var result = "";

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

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

// Change this value to test
phoneticLookup("charlie");
OldmanVimes
@OldmanVimes
Jun 16 2017 04:18
You have to define result
if (myObj.hasOwnProperty(checkProp)===true)
return val=myObj[checkProp];
else
return "Not Found";
why is it showing a small error even though the tests are passed
?
王想想
@wxxxxxxxx
Jun 16 2017 04:20
debug
fdemaa
@fdemaa
Jun 16 2017 04:20
can anyone help me on Profile Lookup exercise ?
any hints
im stuck with this one
OldmanVimes
@OldmanVimes
Jun 16 2017 04:21
The error is "did you mean to return a conditional instead of an assignment"
What does this mean?
The error relates to this line "return val=myObj[checkProp];"
Kevin Holmes
@codersc
Jun 16 2017 04:25
@fdemaa post your code please
Moisés Man
@moigithub
Jun 16 2017 04:26
assign OR return .. dont do both on same line @OldmanVimes
for that code most probably u only need to return.... sooo remove val=
Mario A. Carlos
@MarioC3
Jun 16 2017 04:28
Hey guys quick question
Why am I getting an undefined here?
This is my code:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>JS Drum Kit</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>


  <div class="keys">
    <div data-key="65" class="key">
      <kbd>A</kbd>
      <span class="sound">clap</span>
    </div>
    <div data-key="83" class="key">
      <kbd>S</kbd>
      <span class="sound">hihat</span>
    </div>
    <div data-key="68" class="key">
      <kbd>D</kbd>
      <span class="sound">kick</span>
    </div>
    <div data-key="70" class="key">
      <kbd>F</kbd>
      <span class="sound">openhat</span>
    </div>
    <div data-key="71" class="key">
      <kbd>G</kbd>
      <span class="sound">boom</span>
    </div>
    <div data-key="72" class="key">
      <kbd>H</kbd>
      <span class="sound">ride</span>
    </div>
    <div data-key="74" class="key">
      <kbd>J</kbd>
      <span class="sound">snare</span>
    </div>
    <div data-key="75" class="key">
      <kbd>K</kbd>
      <span class="sound">tom</span>
    </div>
    <div data-key="76" class="key">
      <kbd>L</kbd>
      <span class="sound">tink</span>
    </div>
  </div>

  <audio data-key="65" src="sounds/clap.wav"></audio>
  <audio data-key="83" src="sounds/hihat.wav"></audio>
  <audio data-key="68" src="sounds/kick.wav"></audio>
  <audio data-key="70" src="sounds/openhat.wav"></audio>
  <audio data-key="71" src="sounds/boom.wav"></audio>
  <audio data-key="72" src="sounds/ride.wav"></audio>
  <audio data-key="74" src="sounds/snare.wav"></audio>
  <audio data-key="75" src="sounds/tom.wav"></audio>
  <audio data-key="76" src="sounds/tink.wav"></audio>

<script>
    window.addEventListener('keydown', function(e) {
        // const audio = document.querySelector(`audio[data-key=${e.keycode}]`)
    console.log(e.keycode)
    });

</script>


</body>
</html>
but when I press a key
Moisés Man
@moigithub
Jun 16 2017 04:28
@Betanya do u remember dot and bracket notation ? to access object values
Mario A. Carlos
@MarioC3
Jun 16 2017 04:29
it returns an undefined
Kevin Holmes
@codersc
Jun 16 2017 04:29
is e itself undefined also
@MarioC3
Mario A. Carlos
@MarioC3
Jun 16 2017 04:30
no. because the event should be keydown
so when I press a key it should return the key code for whatever I pressed
Moisés Man
@moigithub
Jun 16 2017 04:31
javscript is case sensitive.. soo KEY is not the same as Key @MarioC3
check ur property name..
if u not sure.. then... console.log(e)
and inspect console
fdemaa
@fdemaa
Jun 16 2017 04:32

i dont know how to use the loop to give me the correct values of my properties;

When i console.log that return for the loop, it gives me the value of the 4 properties of likes,


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


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

  for(i=0; i<contacts.length; i++){
  return contacts[i][prop];

}
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
@codersc
Mario A. Carlos
@MarioC3
Jun 16 2017 04:33
Yes. I checked my console and it returns undefined
Bethany Roberts
@Betanya
Jun 16 2017 04:33
@moigithub yes(hi again!), why?
Mario A. Carlos
@MarioC3
Jun 16 2017 04:33
@moigithub what are you talking about? check my code, I didn't put any KEY
Moisés Man
@moigithub
Jun 16 2017 04:33
if u not sure.. then... console.log(e)
and inspect console
thats an example of case sensitive variables names :) @MarioC3
Mario A. Carlos
@MarioC3
Jun 16 2017 04:34
When I console.log(e)
I received this:
Moisés Man
@moigithub
Jun 16 2017 04:34
anther example... keyCODE is NOT the same as keycode neither keyCode
Ogundele Olumide
@Lumexralph
Jun 16 2017 04:34
@MarioC3 it's should be keyCode property not keycode
Kevin Holmes
@codersc
Jun 16 2017 04:35
@fdemaa hold on let look u the lesson
up*
Mario A. Carlos
@MarioC3
Jun 16 2017 04:35
@Lumexralph Thanks!!!!!!
CamperBot
@camperbot
Jun 16 2017 04:35
marioc3 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1937 | @lumexralph |http://www.freecodecamp.com/lumexralph
Mario A. Carlos
@MarioC3
Jun 16 2017 04:35
So it was only a typo then?
fdemaa
@fdemaa
Jun 16 2017 04:35
@codersc i had to use the .hasownproperty also, but i dont know how, right?
okey !
Bethany Roberts
@Betanya
Jun 16 2017 04:35
@moigithub oh, wait I see what you are saying
Ogundele Olumide
@Lumexralph
Jun 16 2017 04:36
@fdemaa
Here's an outline, if you follow it step-wise it'll help a great deal in telling you what to do or step you missed
1. you need a loop to pick each objects in the contacts array
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                  return the value of prop in the object
                 1.1.1.2  return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
@MarioC3 what @moigithub was correct
fdemaa
@fdemaa
Jun 16 2017 04:36
@Lumexralph thanks man!
CamperBot
@camperbot
Jun 16 2017 04:36
fdemaa sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1938 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 16 2017 04:37
@MarioC3 you could have inspected the e event object from your devTool console, then you'll come across the property you're trying to access
Mario A. Carlos
@MarioC3
Jun 16 2017 04:37
I understand. And I get the you have to 'figure it out' answer... but hahaha it was only a typo. I know, JS is case sensitive! Thanks
Ogundele Olumide
@Lumexralph
Jun 16 2017 04:37
@MarioC3 you're welcome
@fdemaa :+1:
Kevin Holmes
@codersc
Jun 16 2017 04:38
@fdemaa first just try to write some code that will loop through to check if the fiven first name is there and then we'll move on the rest
if the given*
do you know how?
nvm looks like you got it
william
@theironcock
Jun 16 2017 04:40
i can't figure out how to code the temperature conversion
Kevin Holmes
@codersc
Jun 16 2017 04:41
post your code @theironcock
which challenge is it?
Ogundele Olumide
@Lumexralph
Jun 16 2017 04:41
@theironcock do you know the formula ?
fdemaa
@fdemaa
Jun 16 2017 04:42
@codersc thanks kevin , i will try it, and came back if i get stuck!
CamperBot
@camperbot
Jun 16 2017 04:42
fdemaa sends brownie points to @codersc :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @codersc |http://www.freecodecamp.com/codersc
william
@theironcock
Jun 16 2017 04:42
yes i know i need to do celsius *9/5+32= farenheit. but each way i try i can't get it to actually work
Ogundele Olumide
@Lumexralph
Jun 16 2017 04:43
@theironcock other way round
Kevin Holmes
@codersc
Jun 16 2017 04:43
post your code @theironcock
Ogundele Olumide
@Lumexralph
Jun 16 2017 04:43
@theironcock it's fahrenheit
Kevin Holmes
@codersc
Jun 16 2017 04:43
^ yup
william
@theironcock
Jun 16 2017 04:45
var celsius = 30;
celsius*9/5+32= fahrenheit;
sorry i was trying few things.
Kevin Holmes
@codersc
Jun 16 2017 04:46
did it work
william
@theironcock
Jun 16 2017 04:46
no sadly
Kevin Holmes
@codersc
Jun 16 2017 04:46
'''
CamperBot
@camperbot
Jun 16 2017 04:46
:bulb: to format code use backticks! ``` more info
Ogundele Olumide
@Lumexralph
Jun 16 2017 04:46
@theironcock fahrenheit = celsius * 9 / 5 + 32;
Kevin Holmes
@codersc
Jun 16 2017 04:47
post you code and click the more info for instructions on how to do that
more info link*
william
@theironcock
Jun 16 2017 04:48
var celsius = 0;
fahrenheit = celsius*9/5+32;
this worked
melen16
@melen16
Jun 16 2017 04:48
Variable myStr should contain the string: I am a "double quoted" string inside "double quotes". need help in the output
Ogundele Olumide
@Lumexralph
Jun 16 2017 04:48
@melen16 you need to escape double quotes in the string where it appeared
william
@theironcock
Jun 16 2017 04:49
thank you.
Ogundele Olumide
@Lumexralph
Jun 16 2017 04:49
@melen16 double quotes \"
melen16
@melen16
Jun 16 2017 04:49
@Lumexralph var myStr = "I am a \"double quotes\" string inside \"double quotes\".";
doesnt work
fdemaa
@fdemaa
Jun 16 2017 04:50
@Lumexralph hey! how can i use the .hasownproperty to find out if my parameter props is a propertie?
Ogundele Olumide
@Lumexralph
Jun 16 2017 04:50
@melen16 don't change the string given, only escape the qoutes there
@fdemaa Object.hasOwnProperty(property);
@fdemaa Object.hasOwnProperty(props) Object is the object you want to check
fdemaa
@fdemaa
Jun 16 2017 04:53
thanks
Leritha
@LerithaPride1
Jun 16 2017 04:54
Help please with this code myStr = "FirstLine\n \SecondLine\ \rThirdLine";
Ogundele Olumide
@Lumexralph
Jun 16 2017 04:55
@LerithaPride1 eliminate any space in between your string, have you escaped backslash \\ ?
Bethany Roberts
@Betanya
Jun 16 2017 04:55
@moigithub I got it! :D Thanks!!
CamperBot
@camperbot
Jun 16 2017 04:55
betanya sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3371 | @moigithub |http://www.freecodecamp.com/moigithub
Leritha
@LerithaPride1
Jun 16 2017 04:57
Awesome @Lumexralph, thanks!
CamperBot
@camperbot
Jun 16 2017 04:57
lerithapride1 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1939 | @lumexralph |http://www.freecodecamp.com/lumexralph
william
@theironcock
Jun 16 2017 04:58
@codersc how so i get it so i can do all the return values at once so i can submit.
celsius = (-10);
celsius = (-30);
fahrenheit = celsius*9/5+32;
william
@theironcock
Jun 16 2017 05:03
convert celsius to fahrenheit
melen16
@melen16
Jun 16 2017 05:06
I am a "double quoted" string inside "double quotes".
still i couldnt find solution for this
Jeremy
@JeremyAntonoff
Jun 16 2017 05:07
can someone help me
melen16
@melen16
Jun 16 2017 05:07
in console it sows me the result and it same to me
Markus Kiili
@Masd925
Jun 16 2017 05:14
@Lumexralph Morning.
Manish Giri
@Manish-Giri
Jun 16 2017 05:14
@theironcock delete these lines
celsius = (-10);
celsius = (-30);
@melen16 your code?
melen16
@melen16
Jun 16 2017 05:15
@Lumexralph cant solve it . Variable myStr should contain the string: I am a "double quoted" string inside "double quotes". so then i did var myStr = " I am a \" double quoted \" string inside \" double quotes\" ";
@Manish-Giri cant solve it . Variable myStr should contain the string: I am a "double quoted" string inside "double quotes". so then i did var myStr = " I am a \" double quoted \" string inside \" double quotes\" ";
Manish Giri
@Manish-Giri
Jun 16 2017 05:16
@melen16 I think there was a . at the end there.
melen16
@melen16
Jun 16 2017 05:17
@Manish-Giri . yes and i didnt and it is the same .didnt solve
Manish Giri
@Manish-Giri
Jun 16 2017 05:18
@melen16 post the challenge url
click run tests first
Manish Giri
@Manish-Giri
Jun 16 2017 05:19
click run tests first
fdemaa
@fdemaa
Jun 16 2017 05:20
anyone can help me on this , idont know what im doing lol

//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("firstName"==firstName && (contacts).hasOwnProperty(prop)){
  for(i=0; i<contacts.length; i++){
  return contacts[i][prop];

}
}
}


// Change these values to test your function
lookUpProfile("Akira", "adress");
Manish Giri
@Manish-Giri
Jun 16 2017 05:22
@melen16 why do you have spaces around the \"
Markus Kiili
@Masd925
Jun 16 2017 05:23
@fdemaa First you need to loop or iterate through the contacts array.
Then test the looped contact.
melen16
@melen16
Jun 16 2017 05:24
@Manish-Giri after i removed it it is the same
fdemaa
@fdemaa
Jun 16 2017 05:24
@Masd925 thanks man , i will keep trying
CamperBot
@camperbot
Jun 16 2017 05:24
fdemaa sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4272 | @masd925 |http://www.freecodecamp.com/masd925
Manish Giri
@Manish-Giri
Jun 16 2017 05:25
@melen16 that's why I asked you to post the FULL challenge url
what you post doesn't have your code
zayn1914
@zayn1914
Jun 16 2017 05:28
Escape Sequences in Strings

var myStr; // Change this line

var myStr = "First\tLine\n\"Second\tLine\"\rThird\tLine";

??? help
wonder
@wonder2991
Jun 16 2017 05:30
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  return str.replace(/ |_|([a-z])([A-Z])/g, '$1-$2').toLowerCase();
}

spinalCase('AllThe-small Things');
can someone explain the '$1-$2' here?
Markus Ivancsics
@ivancsicsmarkus
Jun 16 2017 05:30
@zayn1914 You don’t need extre quotes.
var myStr = "FirstLine\n\\SecondLine\\\rThirdLine";
Christopher McCormack
@cmccormack
Jun 16 2017 05:30
@wonder2991 ([a-z])([A-Z]) are capturing groups - $1 and $2 are the first and second captured values from your regex matches
Markus Ivancsics
@ivancsicsmarkus
Jun 16 2017 05:31
@wonder2991 $1 means the first capturing group.
@wonder2991 Which is ([a-z])
wonder
@wonder2991
Jun 16 2017 05:31
alright
Christopher McCormack
@cmccormack
Jun 16 2017 05:32
wonder
@wonder2991
Jun 16 2017 05:32
Thanks @cmccormack @ivancsicsmarkus
CamperBot
@camperbot
Jun 16 2017 05:32
wonder2991 sends brownie points to @cmccormack and @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 620 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
:cookie: 911 | @cmccormack |http://www.freecodecamp.com/cmccormack
Markus Ivancsics
@ivancsicsmarkus
Jun 16 2017 05:33
@wonder2991 Good place to learn Regex: https://regexone.com/
zayn1914
@zayn1914
Jun 16 2017 05:33
@ivancsicsmarkus thanks :*
CamperBot
@camperbot
Jun 16 2017 05:33
zayn1914 sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 621 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
zayn1914
@zayn1914
Jun 16 2017 05:33
can i follow u? @ivancsicsmarkus
Ricardo Lara
@AlejandrLara12
Jun 16 2017 05:35
guis
zayn1914
@zayn1914
Jun 16 2017 05:35
?
Ricardo Lara
@AlejandrLara12
Jun 16 2017 05:35
guys help
Sum All Odd Fibonacci Numbers

function sumFibs(num) {
  serie = [1,1];
  sum = 0;
  stop = false;
  counter = 1;

 while ( !stop ){
    if(num == 1 || num == 2){
      serie = [1,1];
      stop = true;
    }else{
      serie.push(serie[counter-1] + serie[counter]);
      counter++;
      console.log('num', num);
      console.log('serie',serie);
      if(num <= serie[serie.length-1]){ stop = true; }
    }
 }
  return serie.reduce(
    function(accumulator,acctualValue){
      // si es par pasa solo el accumulator else suma accumulator y acctualValue
      console.log("serie",serie);
      return ( acctualValue%2 === 0 ) ? accumulator : accumulator + acctualValue; 
    },0);
}

sumFibs(4);
Alex
@roshambembo
Jun 16 2017 05:42

Sup, friends. Strugglin here, not sure how to tell these nested for loops to check for more than one value in each array.
'''
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 = product * arr[i]
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1],[2],[3]]);
'''

CamperBot
@camperbot
Jun 16 2017 05:42
:bulb: to format code use backticks! ``` more info
Christopher McCormack
@cmccormack
Jun 16 2017 05:43
@AlejandrLara12 you're pushing numbers greater than num to your array before you check, this means your math will be incorrect
Ricardo Lara
@AlejandrLara12
Jun 16 2017 05:44
function sumFibs(num) {
  serie = [1,1];
  sum = 0;
  stop = false;
  counter = 1;

 while ( !stop ){
    if(num == 1 || num == 2){
      serie = [1,1];
      stop = true;
    }else{
      serie.push(serie[counter-1] + serie[counter]);
      counter++;
      console.log('num', num);
      console.log('serie',serie);
      if(num < (serie[serie.length-1] + serie[serie.length-2])){ stop = true; }
    }
 }

  //return serie;

  return serie.reduce(
    function(accumulator,acctualValue){
      // si es par pasa solo el accumulator else suma accumulator y acctualValue
      console.log("serie",serie);
      return ( acctualValue%2 === 0 ) ? accumulator : accumulator + acctualValue; 
    },0);
}

sumFibs(4);
That worked
Christopher McCormack
@cmccormack
Jun 16 2017 05:44
@roshambembo do you mean arr[j]?
@AlejandrLara12 all tests passed?
Ricardo Lara
@AlejandrLara12
Jun 16 2017 05:45
yeap
Christopher McCormack
@cmccormack
Jun 16 2017 05:45
@AlejandrLara12 :clap:
Ricardo Lara
@AlejandrLara12
Jun 16 2017 05:45
is not my best code but it worked
is 1am here in mexico haha
Christopher McCormack
@cmccormack
Jun 16 2017 05:45
@AlejandrLara12 you can always go back later and try a different implementation
Ricardo Lara
@AlejandrLara12
Jun 16 2017 05:45
thanks for the support tho @cmccormack
CamperBot
@camperbot
Jun 16 2017 05:45
alejandrlara12 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 912 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Jun 16 2017 05:46
@AlejandrLara12 np :D
Alex
@roshambembo
Jun 16 2017 05:46
@cmccormack you're right! I do mean arr[j]
Paul Christian L. Catoera
@poncatoera
Jun 16 2017 05:46

``
function reverseString(str) {
var array = str.split("");
var newArray = array.reverse();
var finalArray = newArray.join("");
return finalArray;
}

reverseString("hello");``

what are the better ways to do this?
Ricardo Lara
@AlejandrLara12
Jun 16 2017 05:47
can try to doing one liner
@poncatoera that is probably it
Paul Christian L. Catoera
@poncatoera
Jun 16 2017 05:47
okay thanks @AlejandrLara12
CamperBot
@camperbot
Jun 16 2017 05:47
poncatoera sends brownie points to @alejandrlara12 :sparkles: :thumbsup: :sparkles:
:cookie: 250 | @alejandrlara12 |http://www.freecodecamp.com/alejandrlara12
Alex
@roshambembo
Jun 16 2017 05:48
@cmccormack but I still need to multiply product by each number in the array, even if there are sub-arrays. e. g. [[1, 2], [3, 4], [5, 6, 7]]
Markus Ivancsics
@ivancsicsmarkus
Jun 16 2017 05:48
@zayn1914 ofc
Christopher McCormack
@cmccormack
Jun 16 2017 05:48
@roshambembo yup that should happen while your in your inner loop and multiplying the product times each number
@roshambembo is it not working?
@poncatoera here's a more complicated way to do it without reverse :D 'Hello, World!'.split('').map((v,i,a)=>a[-i+a.length-1]).join('')
Ricardo Lara
@AlejandrLara12
Jun 16 2017 05:50
@roshambembo you could try to use reduce, and also a for loop
so for each element of the main array, you reduce it, arr.reduce(funciton(accumilator,actualVal){ for loop }); @roshambembo
so in the for loop you ask for how many
like length of the sub array and you could also reduce it
Kamal
@kpbro
Jun 16 2017 05:55
function chunkArrayInGroups(arr, size) {
  // Break it up.
 var result = [];



  return result;
}


chunkArrayInGroups(["a", "b", "c", "d"], 2);
need help for chunky monkey challenge.. How do i slice array at every given size interval?
Alex
@roshambembo
Jun 16 2017 05:55
@cmccormack nope. My understanding of what I've written is: the inner loop will multiply product by the number in position j in the array, so long as j is less than the length of the sub-array at position i. my next step is to keep looping until it exhausts all the numbers in each sub-array, right?
Christopher McCormack
@cmccormack
Jun 16 2017 05:56
@roshambembo yup your outer loop should iterate over the arrays, and your inner loop over the items
@roshambembo can you repost your code?
Alex
@roshambembo
Jun 16 2017 05:57
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 = product * arr[j];
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1, 2],[3, 4],[5, 6, 7]]);
Kamal
@kpbro
Jun 16 2017 05:58
@roshambembo product = product*arr[i][j];
Christopher McCormack
@cmccormack
Jun 16 2017 05:58
@melen16 what do you have so far?
@kpbro @roshambembo yup nice catch
Agate3CL
@Agate3CL
Jun 16 2017 05:59
noalt
hi, friends, i need some help, the result is right, but i can't pass this test. https://www.freecodecamp.com/challenges/no-repeats-please
HappyRedditor59
@HappyRedditor59
Jun 16 2017 05:59
why does my code show TypeError: Cannot read property 'length' of undefined. my code:
function largestOfFour(arr) {
  // You can do this!
  largestArr = [];

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

  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Christopher McCormack
@cmccormack
Jun 16 2017 06:00
@HappyRedditor59 you used <= on your loops - length is the number of items in the array, but array indexes start from 0
melen16
@melen16
Jun 16 2017 06:00
@cmccormack i have done all the steps and i dont know why it is not working
Christopher McCormack
@cmccormack
Jun 16 2017 06:00
@HappyRedditor59 so if an array is length 10, you want 0-9
VinayVijayJoshi
@VinayVijayJoshi
Jun 16 2017 06:00
Hello All, need help. I am at Caesars Cipher challenge. Below is my code and i am getting the error 'TypeError: a.fromCharCode is not a function"
function rot13(str) { // LBH QVQ VG!

  var arr = []; 
  console.log("@@ " + arr); 
  console.log(/^[a-zA-Z]+$/.test(str[0])); 
  for (i=0; i<str.length; i++) {
    if (/^[a-zA-Z]+$/.test(str[i])) {
        tmp = str.charCodeAt(i);
        tmp += 13;
        console.log("^^ " + tmp); 
        a = str[i];
        console.log("~~ " + a); 
        arr.push(a.fromCharCode(tmp));
        }
  }
/*  str = arr.join(" "); */
  return str; 
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Alex
@roshambembo
Jun 16 2017 06:00
@kpbro aha! daisy-chaining the bracket notation tells me arr[positionWithinOuterArray][positionWithinSubArray]?
Paul Christian L. Catoera
@poncatoera
Jun 16 2017 06:00
i did this for my factorial challenge
Christopher McCormack
@cmccormack
Jun 16 2017 06:01
@melen16 you can paste your code here, and format it using the following rules:
```
Code goes here, backticks go on their own line. Previous posts can be edited. control + shift + m for detailed Markdown Help.
```
Michael Schmidt
@lafisrap
Jun 16 2017 06:01
@roshambembo You need a loop and produce a newArray with the slice function.
Paul Christian L. Catoera
@poncatoera
Jun 16 2017 06:01

function factorialize(num) {
 if (num === 0) {
   return 1;
 } else {
  var array = [];
  for ( var i = 1; i <= num; i++){
    array.push(i);
  } 
  answer = array.reduce(function (previousVal, currentVal) {
    return previousVal * currentVal;
  }); return answer;
} 
}
factorialize(5);
Kamal
@kpbro
Jun 16 2017 06:01
@roshambembo post your code here
Paul Christian L. Catoera
@poncatoera
Jun 16 2017 06:01
im pretty sure there is a better way to get factorial. anybody?
Alex
@roshambembo
Jun 16 2017 06:01
yours worked! just hoping to understand it better
@kpbro sorry, yours worked!
Kamal
@kpbro
Jun 16 2017 06:02
@roshambembo :thumbsup:
HappyRedditor59
@HappyRedditor59
Jun 16 2017 06:02
@cmccormack yes thank you that was a stupid mistake haha
CamperBot
@camperbot
Jun 16 2017 06:02
happyredditor59 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 913 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Jun 16 2017 06:02
@HappyRedditor59 :thumbsup:
Alex
@roshambembo
Jun 16 2017 06:02
@kpbro @cmccormack thanks all!
CamperBot
@camperbot
Jun 16 2017 06:02
roshambembo sends brownie points to @kpbro and @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @kpbro |http://www.freecodecamp.com/kpbro
:cookie: 914 | @cmccormack |http://www.freecodecamp.com/cmccormack
Paul Christian L. Catoera
@poncatoera
Jun 16 2017 06:03
anyone can give me a better idea for factorial

function factorialize(num) {
 if (num === 0) {
   return 1;
 } else {
  var array = [];
  for ( var i = 1; i <= num; i++){
    array.push(i);
  } 
  answer = array.reduce(function (previousVal, currentVal) {
    return previousVal * currentVal;
  }); return answer;
} 
}
factorialize(5);
Christopher McCormack
@cmccormack
Jun 16 2017 06:03
@VinayVijayJoshi fromCharCode is a String method, call String.fromCharCode(tmp)
Kamal
@kpbro
Jun 16 2017 06:04
@poncatoera you just have to multiply a number with the same variable evrytime reducing number by one.... till it is 0
Paul Christian L. Catoera
@poncatoera
Jun 16 2017 06:04
ohhhh
got it thank you @kpbro
CamperBot
@camperbot
Jun 16 2017 06:04
poncatoera sends brownie points to @kpbro :sparkles: :thumbsup: :sparkles:
:cookie: 254 | @kpbro |http://www.freecodecamp.com/kpbro
Pranav Goel
@pranavgoel25
Jun 16 2017 06:05
@poncatoera Instead of pushing numbers to an array and then reducing the array, just mutliply your answer(initialised to 1) with numbers from 1 till num.
Kamal
@kpbro
Jun 16 2017 06:05
@poncatoera try it :thumbsup:
Pieter Stokkink
@forkerino
Jun 16 2017 06:05
@poncatoera you can do all the multiplication inside your loop. Just make a separate variable for the result. Another way to solve it is recursively.
Christopher McCormack
@cmccormack
Jun 16 2017 06:05
@forkerino :wave:

@VinayVijayJoshi https://mdn.io/fromCharCode -

Because fromCharCode() is a static method of String, you always use it as String.fromCharCode(), rather than as a method of a String object you created.

Kamal
@kpbro
Jun 16 2017 06:06
@forkerino hey i need help with chunky monkey
How do i slice array at every given size interval?
Johnny
@JohnnyBizzel
Jun 16 2017 06:07

@poncatoera

function factorialize(num) {
  var factorial = 1;

  for (i = 1; i <= num ; i++) {
    factorial *= i;
  }

  return factorial;
}

factorialize(5);

No array needed

Pieter Stokkink
@forkerino
Jun 16 2017 06:07
@cmccormack pulling an all nighter?
VinayVijayJoshi
@VinayVijayJoshi
Jun 16 2017 06:07
@cmccormack @cmccormack Thanks. I didnt realize that String was a keyword. This runs my code but my output is garbage, so need to work on it now. :+1:
CamperBot
@camperbot
Jun 16 2017 06:07
vinayvijayjoshi sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 915 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Jun 16 2017 06:07
@forkerino nope about to hop off, just finishing up some stuff on my linux box that blew up the other night
Pieter Stokkink
@forkerino
Jun 16 2017 06:07
@kpbro you need some loop
Christopher McCormack
@cmccormack
Jun 16 2017 06:08
@VinayVijayJoshi np good luck
Pieter Stokkink
@forkerino
Jun 16 2017 06:08
@cmccormack :+1:
Paul Christian L. Catoera
@poncatoera
Jun 16 2017 06:08
thanks @JohnnyBizzel
CamperBot
@camperbot
Jun 16 2017 06:08
poncatoera sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1708 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Kamal
@kpbro
Jun 16 2017 06:08
@forkerino i am using this for loop for(var i=0;i<arr.length;i++)
Christopher McCormack
@cmccormack
Jun 16 2017 06:08
Guess I'll hop off, have a good one!
Pieter Stokkink
@forkerino
Jun 16 2017 06:09
@cmccormack sleep well
Christopher McCormack
@cmccormack
Jun 16 2017 06:10
@forkerino thanks :D
CamperBot
@camperbot
Jun 16 2017 06:10
cmccormack sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2641 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jun 16 2017 06:11
@kpbro Ok. there's two options:
  1. Increase i by size in the head of your loop and use it as arguments in the slice inside.
  2. Stop looping at arr.length/size and do some other calculations for the argumetns of slice.
Kamal
@kpbro
Jun 16 2017 06:11
@forkerino 1 looks better .. lemme try
Hiago Patrick
@HiagoPatrick
Jun 16 2017 06:14
Good night guys
can anybody help me out with javascript ?

i have to "Initialize the three variables a, b, and c with 5, 10, and "I am a" respectively so that they will not be undefined."

then i have here
var a = 5;
var b = 10;
var c = "i am a";

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

but there's something wrong withc

"c should not contain undefined and should have a value of "I am a String!" "

Coy Sanders
@coymeetsworld
Jun 16 2017 06:18
@HiagoPatrick you changed your initialization variable for c
Pieter Stokkink
@forkerino
Jun 16 2017 06:18
@HiagoPatrick "I am a " with capital I
Coy Sanders
@coymeetsworld
Jun 16 2017 06:18
sorry, i mean you needed to fix that that's the part you needed to write
:point_up:
Hiago Patrick
@HiagoPatrick
Jun 16 2017 06:19
Oh, really ? capital I lol, thanks
Kamal
@kpbro
Jun 16 2017 06:19
function chunkArrayInGroups(arr, size) {
  // Break it up.
 var result = [];

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

  return result;
}


chunkArrayInGroups(["a", "b", "c", "d"], 2);
@forkerino
@forkerino says there is potential infinite loop
Pieter Stokkink
@forkerino
Jun 16 2017 06:20
@kpbro use += instead of + when you increase i, otherwise i will remain 0
Kamal
@kpbro
Jun 16 2017 06:21
@forkerino any other mistake here?
Pieter Stokkink
@forkerino
Jun 16 2017 06:22
@kpbro yeah, second argument of the slice is incorrect.
i should be in there somewhere
Kamal
@kpbro
Jun 16 2017 06:23
the 1st argument is where i need to start slicing and second is before which index i have to end slicing.. am i right?
Markus Kiili
@Masd925
Jun 16 2017 06:24
@kpbro All your slices end in the same index.
Pieter Stokkink
@forkerino
Jun 16 2017 06:24
yes
Kamal
@kpbro
Jun 16 2017 06:27
@Masd925 @forkerino I m confused which starting and ending index i have to use. Now i am using i end index. but where to start?
Markus Kiili
@Masd925
Jun 16 2017 06:27
@kpbro Start at i and figure out where to end.
Pieter Stokkink
@forkerino
Jun 16 2017 06:27
@kpbro use i for start, but where do you need to end if you start at i?
Ccs99817
@ccs99817
Jun 16 2017 06:27
Can anyone explain what do the following lines do in the whole code?
Here is my thought about the above code. Can you tell me whether I get the point or not?
json.forEach(function(val) { //for each values in the json file
var keys = Object.keys(val); //keys is defined as the keys(id, imageLink, ...) in each values, where "values" is the stuff with { }
html += "<div class = 'cat'>";
keys.forEach(function(key) { //run a function with parameter "key" which is defined as the single items in "keys" (id, imageLink, ...)
html += "<strong>" + key + "</strong>: " + val[key] + "<br>";
});
html += "</div><br>";
});
Can anyone explain what do the following lines do in the whole code?
Here is my thought about the above code. Can you tell me whether I get the point or not?
json.forEach(function(val) {    //for each values in the json file
  var keys = Object.keys(val);          //keys is defined as the keys(id, imageLink, ...) in each values, where "values" is the stuff with { }
  html += "<div class = 'cat'>";        
  keys.forEach(function(key) {          //run a function with parameter "key" which is defined as the single items in "keys" (id, imageLink, ...)
    html += "<strong>" + key + "</strong>: " + val[key] + "<br>";
  });
  html += "</div><br>";
});
Kamal
@kpbro
Jun 16 2017 06:28
@Masd925 @forkerino Thanks.. got it.. started at i and ended at i+size
CamperBot
@camperbot
Jun 16 2017 06:28
kpbro sends brownie points to @masd925 and @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2642 | @forkerino |http://www.freecodecamp.com/forkerino
:star2: 4273 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 16 2017 06:29
@kpbro :+1:
Ccs99817
@ccs99817
Jun 16 2017 06:29

@Masd925 Can you help me?

Here is my thought about the above code. Can you tell me whether I get the point or not?

json.forEach(function(val) {    //for each values in the json file
  var keys = Object.keys(val);          //keys is defined as the keys(id, imageLink, ...) in each values, where "values" is the stuff with { }
  html += "<div class = 'cat'>";        
  keys.forEach(function(key) {          //run a function with parameter "key" which is defined as the single items in "keys" (id, imageLink, ...)
    html += "<strong>" + key + "</strong>: " + val[key] + "<br>";
  });
  html += "</div><br>";
});
Kamal
@kpbro
Jun 16 2017 06:29
that's the real way to help without revealing the direct answer..
Markus Kiili
@Masd925
Jun 16 2017 06:30
@ccs99817 You need to show the json encoded string too for that to make sense.
Ccs99817
@ccs99817
Jun 16 2017 06:31

@Masd925 Actually, the whole code is as follow

$(document).ready(function() {
  $("#newQuoteButton").on("click", function(){
    //$("blockquote").html("Here is the message");
    // JSON LINK: https://api.myjson.com/bins/1by0m3

      $.getJSON("https://api.myjson.com/bins/1by0m3", function(json){
        var html = "";
        json.forEach(function(val){
          var keys = Object.keys(val);
          html += "div class = 'quote'"
          keys.forEach(function(key){
            html = key + val[key] + "<br>";
          });
          html += "</div><br>";
        });

        $("p").html(html);
      });


  });
});

https://codepen.io/ccs99817/pen/PjGgXj

I have no idea about how to generate random quote
Gurpreet SIngh
@Gurpreet3131
Jun 16 2017 06:36
svg = d3.select("#visualBox")
            .append("svg")
            .attr("width", w)
            .attr("height", h);

    var bars = svg.selectAll("rect")
                .data(dataSet)
                .enter()
                    .append("rect")
                    .attr("class", "bar");

    bars.attr("x", function(d, i) { return i * (w / dataSet.length); } );
    bars.attr("y", function(d) {return h - scale(d.value); });
    bars.attr("width", function(d) {return w / dataSet.length - padding; });
    bars.attr("height", function(d) {return scale(d.value); });
    bars.style("fill", function(d) {return color[d.state]; } );
I have this rectangular bars made using d3 js library. now how can I add text value to each of the rectagular bar?
Markus Kiili
@Masd925
Jun 16 2017 06:38
@ccs99817 That json is a JS array of quote objects. You can get a random quote by getting (and then accessing) a random element from that array.
and you can get a random element from an array with:
var arr = [5,6,7,8];
arr[Math.floor(Math.random()*arr.length)];
HappyRedditor59
@HappyRedditor59
Jun 16 2017 06:48
can someone pls help me? i'm on Truncate a String challenge and i get a weird error of TypeError: newStr.join is not a function. this is my code:
```
function truncateString(str, num) {
  // Clear out that junk in your trunk
  var newStr = [];

  if (str.length > num-3){
    str = str.split('');
    for (var i = 0; i < num-3; i++){
      newStr += str[i];
    }
    newStr = newStr.join('') + "...";
    str = newStr;
  }

  return str;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Pieter Stokkink
@forkerino
Jun 16 2017 06:49
@HappyRedditor59 + coerces an array to a string. Use .push or .concat
@HappyRedditor59 better idea is to just use .slice for the original string, no need to split
HappyRedditor59
@HappyRedditor59
Jun 16 2017 06:52
@forkerino will try that thanks
CamperBot
@camperbot
Jun 16 2017 06:52
happyredditor59 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2643 | @forkerino |http://www.freecodecamp.com/forkerino
Mohak Chaturvedi
@lucky73
Jun 16 2017 07:00
it says multiplyAll[i] is undefined dont understand why please help

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

  product*=multiplyAll[i][j].length;
}

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

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

Pieter Stokkink
@forkerino
Jun 16 2017 07:00
@lucky73 your array is named arr... multiplyAll is the function name
Mohak Chaturvedi
@lucky73
Jun 16 2017 07:02
so instead on multiplyall i shoud be writing arr @forkerino
Manon
@manonja
Jun 16 2017 07:02
hey guys, i dont understand why it returns false here :
function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  for (var i = 0; i < str.length; i++) {
    if (str.substr(str.length-1) && str.substr(str.length-4) == target) {
      return true;
    } else {
        return false;
      }
  }
  return str;
}

confirmEnding("Bastian", "n");
Pieter Stokkink
@forkerino
Jun 16 2017 07:03
@lucky73 yes
Mohak Chaturvedi
@lucky73
Jun 16 2017 07:04
but it does not fits taste cases @forkerino
test*
Pieter Stokkink
@forkerino
Jun 16 2017 07:06
@lucky73 there is a inside your loops, do you still have .length when you multiply? Numbers don't have lengths.
Mohak Chaturvedi
@lucky73
Jun 16 2017 07:06
no i dont have @forkerino
Pieter Stokkink
@forkerino
Jun 16 2017 07:06
@manonja you are testing if the last four characters of the string are equal to target. This can only be true if target is four characters long.
@lucky73 show your current code
Mohak Chaturvedi
@lucky73
Jun 16 2017 07: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][j];
}

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

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

@forkerino

Markus Kiili
@Masd925
Jun 16 2017 07:07
@manonja In JS, you can compare strings with ===, so you can solve it without a loop by making a substring from str and comparing with target.
Mohak Chaturvedi
@lucky73
Jun 16 2017 07:08
@forkerino thank you it worked
CamperBot
@camperbot
Jun 16 2017 07:08
lucky73 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2644 | @forkerino |http://www.freecodecamp.com/forkerino
Mai Thinh
@mthinh
Jun 16 2017 07:08

var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split('');

Pieter Stokkink
@forkerino
Jun 16 2017 07:08
@lucky73 I thought so. :+1:
Mai Thinh
@mthinh
Jun 16 2017 07:08
what i have to do with this pls?
Pieter Stokkink
@forkerino
Jun 16 2017 07:09
@mthinh do they want you to split into words or characters?
Mai Thinh
@mthinh
Jun 16 2017 07:09
You should split the string by its spaces.
i dont understand what they mean?
Quan Minh Pham
@dreamtheater2195
Jun 16 2017 07:09
@mthinh array = string.split(' ');
John Wilfred
@ewojjowe
Jun 16 2017 07:09
Hey all
Pieter Stokkink
@forkerino
Jun 16 2017 07:09
@manonja the idea is to take the end of str, with the same length as target and compare it to target. So if target is 3 long, take three from the end of str.
Mai Thinh
@mthinh
Jun 16 2017 07:10
@dreamtheater2195 i did the same, it doenst work
Pieter Stokkink
@forkerino
Jun 16 2017 07:10
@mthinh '' is not a space, but empty string. Put a space in there
Manon
@manonja
Jun 16 2017 07:10
ok got it @forkerino thanks !
CamperBot
@camperbot
Jun 16 2017 07:10
manonja sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2645 | @forkerino |http://www.freecodecamp.com/forkerino
Mai Thinh
@mthinh
Jun 16 2017 07:10
oh i see , tks you :D
CamperBot
@camperbot
Jun 16 2017 07:11
:bulb: to format code use backticks! ``` more info
Mai Thinh
@mthinh
Jun 16 2017 07:12
@dreamtheater2195 are you vnese :D
Quan Minh Pham
@dreamtheater2195
Jun 16 2017 07:12
@mthinh yes i am
Chinemelu Nwosu
@chinemelu
Jun 16 2017 07:16
Hey guys, I am struggling with the Profile look Up question. My problem is that my code only searches for the first i (0); and it does not iterate through the whole nested array. I have looked online and I have seen "recursion" being touted as a possible solution, however, I don't think it should be that complicated. Please help.
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (i = 0; i < contacts.length; i++){
    if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
    }
    else if (contacts[i].firstName !== firstName){
      return "No such contact";
    }
    else if (contacts[i].hasOwnProperty(prop) !== true){
      return "No such property";
    }
  }

// Only change code above this line
}
Markus Kiili
@Masd925
Jun 16 2017 07:18
@chinemelu Simplest structure would be two nested if's for the first name and property existence tests. Using multiple tests like that on one if leads to repeating conditions.
dseillier
@dseillier
Jun 16 2017 07:20
Hi everyone ! I can't see whats wrong with my code here :
function destroyer(arr) {
  // Remove all the values
  for (var i = 0; i < arguments.length; i++) {
    for (var j = 0; j < arr.length; j++) {
      if (arguments[i] === arr[j]) {
        arr.splice(arr[j], 1);
        }
      }
    }
  return arr;
 }
schizo99
@shashank1999coder
Jun 16 2017 07:23

var ourArray = [1,2,3];
ourArray[1] = 3; // ourArray now equals [1,3,3].

// Setup
var myArray = [3,2,3];
ourArray[0] = 3;
// Only change code below this line.

hi guys what's wrong

Markus Kiili
@Masd925
Jun 16 2017 07:23
@dseillier Mutating the array you iterate over with a for loop usually messes up the indices. Even if you make it work somehow, the code is hard to understand.
Claudio Restifo
@Marmiz
Jun 16 2017 07:24
@dseillier don't use splice inside a loop. Splice change the instance of the array, so you have no certainty that the second time it loops over you are looking at the "same" data as before
@Masd925 :wave:
Markus Kiili
@Masd925
Jun 16 2017 07:24
@Marmiz Yo.
dseillier
@dseillier
Jun 16 2017 07:24
Alright, thanks guys ! So I need to use the filter method instead of splice ?
Claudio Restifo
@Marmiz
Jun 16 2017 07:25

@shashank1999coder

ourArray[0] = 3;

You are changing ourArray when you should change myArray

Chinemelu Nwosu
@chinemelu
Jun 16 2017 07:25
@Masd925 Thanks a lot. I will try it now.
CamperBot
@camperbot
Jun 16 2017 07:25
chinemelu sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4274 | @masd925 |http://www.freecodecamp.com/masd925
Pieter Stokkink
@forkerino
Jun 16 2017 07:25
@dseillier if you use .filter you don't need a loop
@Masd925 :wave:
Markus Kiili
@Masd925
Jun 16 2017 07:25
@forkerino Hello.
dseillier
@dseillier
Jun 16 2017 07:25
@forkerino even if I need to iterate on every argument provided ?
Pieter Stokkink
@forkerino
Jun 16 2017 07:26
I'm implementing Dijkstra's algorithm for the first time.... @Masd925
@dseillier you can use another method for that if you put them in an array.
Claudio Restifo
@Marmiz
Jun 16 2017 07:26
@dseillier filter already loop into the array and execute a function for every instance of it
Markus Kiili
@Masd925
Jun 16 2017 07:26
@forkerino Expression parser for calculator?
schizo99
@shashank1999coder
Jun 16 2017 07:26
@Marmiz thank you
CamperBot
@camperbot
Jun 16 2017 07:26
shashank1999coder sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 932 | @marmiz |http://www.freecodecamp.com/marmiz
dseillier
@dseillier
Jun 16 2017 07:27
@Marmiz okay thanks, I'll try that
CamperBot
@camperbot
Jun 16 2017 07:27
dseillier sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 933 | @marmiz |http://www.freecodecamp.com/marmiz
Claudio Restifo
@Marmiz
Jun 16 2017 07:27
@dseillier give the docs a read :)
Pieter Stokkink
@forkerino
Jun 16 2017 07:31
@Masd925 shortest path problem
dseillier
@dseillier
Jun 16 2017 07:32
@Marmiz Yes I read that, but I can't figure out how to pass some arguments inside the filter method so that it returns a new array without those arguments as elements..
Markus Kiili
@Masd925
Jun 16 2017 07:32
@forkerino ok. One man should only have one algorithm named after him.
Pieter Stokkink
@forkerino
Jun 16 2017 07:32
@Masd925 :joy: I agree
dseillier
@dseillier
Jun 16 2017 07:33
I think I have some issue understanding how the argumentobject works
Ogundele Olumide
@Lumexralph
Jun 16 2017 07:34
@Masd925 Good Morning
Pieter Stokkink
@forkerino
Jun 16 2017 07:34
@Lumexralph :wave:
Markus Kiili
@Masd925
Jun 16 2017 07:34
@forkerino I always get suspicious when I see a number greater than 1 somewhere. 0 and 1 are logical results for many things, but why for example 5 :rat:
@Lumexralph Hello.
Claudio Restifo
@Marmiz
Jun 16 2017 07:35
@dseillier example:
var arr = [1, 2, 3,  4, 5]
var filtered = arr.filter(function(value){
console.log(value)  // so that you'll see in console that is looping into the array --> 1 - 2 -3 -4 -5   
return val  > 3
})

arr   // [1, 2, 3,  4, 5]
filtered // [ 4, 5]  only number > 3 has been returned
dseillier
@dseillier
Jun 16 2017 07:36
I tried that :
function destroyer(arr) {
  // Remove all the values

  var newArr = arr.filter(function(value) {
    return value !== arguments;
  });

  return newArr;
 }
Vedant Kashyap
@vedant15188
Jun 16 2017 07:37
Can someone help me with the Exact Change Challenge? Some hints on how to go about it...?
https://www.freecodecamp.com/challenges/exact-change
Claudio Restifo
@Marmiz
Jun 16 2017 07:37
@dseillier you have to isolate the two arguments array. it's not enough to say != arguments
Have you printed it in console to see what arguments is actually looking like?
Ogundele Olumide
@Lumexralph
Jun 16 2017 07:39
@forkerino Good Morning Bro!
Markus Kiili
@Masd925
Jun 16 2017 07:40
@forkerino While you are doing the Dijkstra thing, could you also prove that the shortest distance between two points on an infinite space is a straight line?
Claudio Restifo
@Marmiz
Jun 16 2017 07:40
@dseillier when prototyping and working with functions I suggest you to use something that lets you quick test and see the data easier than FCC console.
I like https://repl.it/languages/javascript
Markus Kiili
@Masd925
Jun 16 2017 07:42
@forkerino I have though about how pathing works in some computer games. They must use something resembling Dijkstra to find paths between a place where someone is and where he want's to go.
dseillier
@dseillier
Jun 16 2017 07:43
@Marmiz thank you for the advice ! :-)
CamperBot
@camperbot
Jun 16 2017 07:43
dseillier sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:warning: dseillier already gave marmiz points
Markus Kiili
@Masd925
Jun 16 2017 07:44
@dseillier That filter callback function has its own arguments object.
Vedant Kashyap
@vedant15188
Jun 16 2017 07:47

Can someone help me with the Exact Change Challenge? Some hints on how to go about it...?
https://www.freecodecamp.com/challenges/exact-change

anyonee???

Markus Kiili
@Masd925
Jun 16 2017 07:47
@vedant15188 A robust way to avoid float rounding problems is to work with penny amounts that are safe integers.
Vedant Kashyap
@vedant15188
Jun 16 2017 07:49
okay... and umm what about the answer array... i have to sort to accordingly... how do i do that with a 2d array ...? @Masd925
Markus Kiili
@Masd925
Jun 16 2017 07:51
@vedant15188 Most likely you will need on object of some kind that holds the mapping between note names and values. I solved it then by reversing and iterating the array cid.
Ogundele Olumide
@Lumexralph
Jun 16 2017 07:53
@Masd925 that algorithm is used in computer networking by routers in the OSPF model
patrick cook
@arcteryx
Jun 16 2017 07:56
Hi, I'm having trouble with the Word Blanks challenge. My code follows:

```function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
var myNoun = "dog";
var myAdjective = "big";
var myVerb = "ran";
var myAdverb = "quickly";
result = "The " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb + ".";

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");``` Doesn't pass the third test...

Osamudiamen Imasuen
@pwadeveloper
Jun 16 2017 07:58
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++){
  for(i in firstName){
    if(contacts[i].firstName===firstName){
      if(contacts[i].hasOwnProperty(prop)===true){
         return contacts[i][prop];
    } else {
     return "No such property";
   }

  }

// Only change code above this line
}

   } 
  }
ADay
@aday091
Jun 16 2017 07:59

I can't get the function to return the element that was removed in the "Stand In Line" exercise...
function nextInLine(arr, item) {
// Your code here
testArr.push(item);
testArr.shift();
return item; // Change this line
}

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

Osamudiamen Imasuen
@pwadeveloper
Jun 16 2017 07:59
I need to be able to access contacts and search of a number is there or not also
profile look up challange
Pieter Stokkink
@forkerino
Jun 16 2017 08:00
@Masd925 Does using an elastic band between two points count as proof?
OldmanVimes
@OldmanVimes
Jun 16 2017 08:01
if (contacts.hasOwnProperty(firstName)===true)
return contacts.firstName;
else
return "No such contact";
if (contacts.hasOwnProperty(prop)===true)
return contacts.prop;
else
return "No such property";
I know this is incorrect, but can't figure out what.
Any help?
Chris Juchtmans
@kjuchtmans
Jun 16 2017 08:02
morning, kind folks of codeland :wave:
dseillier
@dseillier
Jun 16 2017 08:02
@OldmanVimes try return contacts[prop]instead
ADay
@aday091
Jun 16 2017 08:02
@arcteryx I just did this exercise, try leaving the variables down where they were when the lesson loaded. let me go back a look at what I did.
Ogundele Olumide
@Lumexralph
Jun 16 2017 08:04
@aday091 change testArr to arr and return arr.shift(); not item
ADay
@aday091
Jun 16 2017 08:04
thanks @Lumexralph
CamperBot
@camperbot
Jun 16 2017 08:04
aday091 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1940 | @lumexralph |http://www.freecodecamp.com/lumexralph
ADay
@aday091
Jun 16 2017 08:05
@arcteryx what was the name of that exercise
Ogundele Olumide
@Lumexralph
Jun 16 2017 08:05
@pwadeveloper you need a loop not 2 loops
Ken Haduch
@khaduch
Jun 16 2017 08:05
@OldmanVimes - you recognize that contacts is an array? Are you writing some type of code to iterate through the array, like a for loop? And if you are, are you generating an index - you have to use that to access the array elements.
OldmanVimes
@OldmanVimes
Jun 16 2017 08:06
@dseillier made no difference, actually this is an array, so will hasOwnProperty() work?
patrick cook
@arcteryx
Jun 16 2017 08:06
@aday091 Word Blanks : Obviously spec'd by a salesman!
ADay
@aday091
Jun 16 2017 08:09
@Lumexralph I did that but now it's violating the two opposite parameters... any ideas?
OldmanVimes
@OldmanVimes
Jun 16 2017 08:10
@khaduch so do I first need to define a for loop e.g. for i=0,i<arr.length,i++?
Ken Haduch
@khaduch
Jun 16 2017 08:10
@oldmanvimes - yes! That's the idea
Ogundele Olumide
@Lumexralph
Jun 16 2017 08:11
@khaduch Hallo :wave:
ADay
@aday091
Jun 16 2017 08:12
@arcteryx make sure that when you call the wordBlanks function and pass the arguments that it is outside of the function itself. Does that make sense?
Ken Haduch
@khaduch
Jun 16 2017 08:14
@Lumexralph - hello there! How are you doing?
@OldmanVimes for ( var i = 0; i < contacts.length; i++ ) { is the start of the loop that you want.
Chris Juchtmans
@kjuchtmans
Jun 16 2017 08:15

@kjuchtmans is discovering new toys: .hide() and .show() :baby:

who cares to give me feedback on my "Wikipedia Viewer"?
pen
it's working for me (notwithstanding the bland styling)

any tips welcome on e.g. :

  • confusing or superfluous code
  • ill logic
  • general code aesthetics

would help me a lot! I'm slowly falling in love with jQuery

Mai Thinh
@mthinh
Jun 16 2017 08:16

function factorialize(n) {
for(var i = 1; i < n+1; i++){
var resutl = n*(n-i);
return resutl;
}

}

factorialize(5);

what did I do wrong here?
patrick cook
@arcteryx
Jun 16 2017 08:17
@aday091 No. I only have a function definition and a definition call... non-recursive.
Ken Haduch
@khaduch
Jun 16 2017 08:19
Hi @kjuchtmans - it seems that the wikipedia search works. One thing that would be nice would be to put the keyboard focus on the search box when you open it. If I put a nonsense string in the search box, it doesn't do anything like tell me "No results found". Good start!
ADay
@aday091
Jun 16 2017 08:20
@arcteryx it should look like this:
patrick cook
@arcteryx
Jun 16 2017 08:20
My code satisfies the first 2 req's, not the third....
wordBlanks("","","","") should return a string.
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
Osamudiamen Imasuen
@pwadeveloper
Jun 16 2017 08:20
@Lumexralph a single loop didnt work
ADay
@aday091
Jun 16 2017 08:20

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

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("exercise", "freeCodeCamp", "is", "Bullshit");

Osamudiamen Imasuen
@pwadeveloper
Jun 16 2017 08:20
The code cleared all the conditions i just need where to insert another return statement
to return "No such Contact"
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++){
  for(i in contacts){
    if(contacts[i].firstName==firstName){

      if(contacts[i].hasOwnProperty(prop)===true){
         return contacts[i][prop];
    } else {

     return "No such property";
   }

  }

// Only change code above this line
}

   } 
  }
ADay
@aday091
Jun 16 2017 08:22
how are you guys getting those screenshots of the console?
Osamudiamen Imasuen
@pwadeveloper
Jun 16 2017 08:22
where to insert this
  if(contacts[i].prop!==prop){
      return "No such contact";
    }
@aday091 type "javasctipt
Ken Haduch
@khaduch
Jun 16 2017 08:23
@aday091 - - for code posting information see https://forum.freecodecamp.com/t/markdown-code-formatting/18391 - basically, use backticks, like ``` on a line all alone at the start and end of your code block.
Osamudiamen Imasuen
@pwadeveloper
Jun 16 2017 08:23
@aday091 javascript
Mai Thinh
@mthinh
Jun 16 2017 08:24

function factorialize(n) {
for(var i = 1; i < n+1; i++){
var result = n*(n-i);
return result;
}

}

factorialize(10);

Aakash Bhusal
@aakashbhusal7
Jun 16 2017 08:24

@pwadeveloper
look at mine
function lookUpProfile(firstName, prop){
var a;
for(var i=0;i<contacts.length;i++){
if (firstName===contacts[i].firstName && contacts[i].hasOwnProperty(prop)===true){
a= contacts[i][prop];
break;
}
else if(firstName!==contacts[i].firstName && contacts[i].hasOwnProperty(prop)===true){
a="No such contact";
}
else {
a= "No such property";
}
}
return a;

}

ADay
@aday091
Jun 16 2017 08:24

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

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("exercise", "freeCodeCamp", "is", "Bullshit");
'''

CamperBot
@camperbot
Jun 16 2017 08:24
:bulb: to format code use backticks! ``` more info
Mai Thinh
@mthinh
Jun 16 2017 08:24
why my loop doesnt work pls
Osamudiamen Imasuen
@pwadeveloper
Jun 16 2017 08:24
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++){
  for(i in contacts){
    if(contacts[i].firstName==firstName){

      if(contacts[i].hasOwnProperty(prop)===true){
         return contacts[i][prop];
    } else {

     return "No such property";
   }

  }

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

   } 
  }
@pwadeveloper so i have no idea why it is not working
OldmanVimes
@OldmanVimes
Jun 16 2017 08:24
for (i=0;i<contacts.length;i++){
if (contacts[i].hasOwnProperty[firstName]===true)
return contacts[firstName];
else
return "No such contact";
if (contacts[i].hasOwnProperty[prop]===true)
return contacts[prop];
else
return "No such property";
}
@khaduch not working
Chris Juchtmans
@kjuchtmans
Jun 16 2017 08:25

@khaduch thanks for taking a look. yeah, even FCC example was not really interactive on nonsense strings; just did nothing. Wikipedia web search gives you meaningful alternatives in that case, but I'm a bit hesitant -if interested- to code out 'Did you mean...?' options.

Any thoughts on how this could be done?

CamperBot
@camperbot
Jun 16 2017 08:25
kjuchtmans sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2995 | @khaduch |http://www.freecodecamp.com/khaduch