25th
Nov 2016
Ikenga Derrick
@euphoriawolf
Nov 25 2016 00:07
hello . i just started js and im stuck at the array part . i'm asked to do something under 'stand in line' and i've tried alot based on my knowledge so far but im stuck
Gniewoszu
@Gniewoszu
Nov 25 2016 00:11
@euphoriawolf show code
Zina Astafyeva
@tragetraje
Nov 25 2016 00:15
can anybody help me to debug my wikipedia viewer please?
Walid Ashri
@walidashri
Nov 25 2016 00:16
Zina Astafyeva
@tragetraje
Nov 25 2016 00:17
crazycoder775
@crazycoder775
Nov 25 2016 00:18
Hi, can someone help me with a D3 chart ? I developed a simple D3 bar chart. I want to export the same to Excel and PDF (both chart and data). What are the possible options to do the same ? I did Google but didn't seem to fine a suitable answer.
Nov 25 2016 00:22
Hello everyone! Check at my JS code, please. And tell me what you think about it. Maybe weak sides or so. http://codepen.io/vl-doit/full/WoOzXQ
Ikenga Derrick
@euphoriawolf
Nov 25 2016 00:22
function nextInLine(arr, item) {

return arr.push(item);
// Change this line

}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
that's as far as i can think of
crazycoder775
@crazycoder775
Nov 25 2016 00:24
@euphoriawolf you can use shift and store it in a var, then return the value
Johnny
@JohnnyBizzel
Nov 25 2016 00:25
@euphoriawolf There is one case where you need to do a .shift() first.
crazycoder775
@crazycoder775
Nov 25 2016 00:25
@euphoriawolf change the code in the function nextInLine to the below code and remove everything else in that function :
arr.push(item);
var test=arr.shift();
// Change this line
return test;

function nextInLine(arr, item) {
arr.push(item);
var test=arr.shift();
// Change this line
return test;
}

// Test Setup
var testArr = [1,2,3,4,5];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

c0d0er
@c0d0er
Nov 25 2016 00:27
@toianw thanks
CamperBot
@camperbot
Nov 25 2016 00:27
c0d0er sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
Zina Astafyeva
@tragetraje
Nov 25 2016 00:27
any luck @walidashri ?
c0d0er
@c0d0er
Nov 25 2016 00:28
@walidashri thanks
CamperBot
@camperbot
Nov 25 2016 00:28
c0d0er sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
Ikenga Derrick
@euphoriawolf
Nov 25 2016 00:29
@crazycoder775 . thanks alot! it worked .
CamperBot
@camperbot
Nov 25 2016 00:29
euphoriawolf sends brownie points to @crazycoder775 :sparkles: :thumbsup: :sparkles:
Hannah
@westie1980
Nov 25 2016 00:31
Can anyone give me some hints on where to start with this profile lookup task, I'm stumped!
{
"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");

Johnny
@JohnnyBizzel
Nov 25 2016 00:33
@westie1980 Object notation: http://www.w3schools.com/js/js_objects.asp
@westie1980 In this case it is probably best to use the bracket notation, eg) objectName["propertyName"]
Hannah
@westie1980
Nov 25 2016 00:40
thanks for the link and tips @JohnnyBizzel !
CamperBot
@camperbot
Nov 25 2016 00:40
westie1980 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
Hannah
@westie1980
Nov 25 2016 00:40
I'll give it a go :smile:
Johnny
@JohnnyBizzel
Nov 25 2016 00:41
@westie1980 :+1:
Walid Ashri
@walidashri
Nov 25 2016 01:13
@tragetraje Sorry I'm in duty u still there
Emily Christensen
@emmalee113
Nov 25 2016 01:37

Hi again everyone! working on random quote generator. I'm almost done, my last issue is figuring out how to make the tweet button actually make each quote go to someone's twitter? any advice? here is what i've got now:

http://codepen.io/emmalee113/pen/WojpVY?editors=1010

samson
@samcampc
Nov 25 2016 01:37
hi guys is learning from a person on google and doing what he does by copying him bad
but you still learn
Walid Ashri
@walidashri
Nov 25 2016 01:40
@emmalee113 try this
silver537
@silver537
Nov 25 2016 01:40
@emmalee113 that project was supposed to teach you how to use api's. you might want to use api's instead of hard coding.
waresouhe-app
@Warehouse-app
Nov 25 2016 01:44
@silver537 I gotta one question for you, when are we supposed to get that class, or better, all of us will learn how to use api's or that project is something a part?
silver537
@silver537
Nov 25 2016 01:45
after you complete your basicalgorithm challenges for JS the challenges will talk about API.
Emily Christensen
@emmalee113
Nov 25 2016 01:47
@silver537 yeah i guess i didn't get a good enough understanding of them in the codecamp challenges =/ i understand how they work but not really how i'm supposed to be using them
samson
@samcampc
Nov 25 2016 01:48
Caesars Cipher
hongwutian
@hongwutian
Nov 25 2016 01:49
Don't rush man. Everytime i rush, my result come out negative
silver537
@silver537
Nov 25 2016 01:50

@emmalee113 when using jquery

$.getJSON(URL, function(JSON){ console.log(JSON) }) that's all to it. if you know how to work around object, then you can grab data from the JSON. URL will be the url link in which you want to grab the quotes from. Moisés Man @moigithub Nov 25 2016 01:52 understanding objects n arrays is a must if u wanna work with APIs Emily Christensen @emmalee113 Nov 25 2016 01:52 @silver537 i actually just put in my own quotes in an array.... is that where i'm missing the point of this project? silver537 @silver537 Nov 25 2016 01:52 yes. that's called hardcoding Emily Christensen @emmalee113 Nov 25 2016 01:52 whoops. lol Graham Gillmore @bggillmore Nov 25 2016 01:52 // Keep a copy of the collection for tests var collectionCopy = JSON.parse(JSON.stringify(collection)); // Only change code below this line function updateRecords(id, prop, value) { if(prop !== "tracks" && value !== ""){ if (collection[id].hasOwnProperty(prop) === false){ collection[id].prop = value; return collection; } } } // Alter values below to test your code updateRecords(5439, "artist", "ABBA"); This is returning "prop": "ABBA", Is there a way i can get the function to use the parameter value instead of the string "prop"? Moisés Man @moigithub Nov 25 2016 01:53 prop is variable.. NO dot notation @bggillmore silver537 @silver537 Nov 25 2016 01:54 @emmalee113 you can do whatever you want in your own projects, but usually the projects here in FCC will teach you a bit of technologies or concepts. if you want, finish the project you have now, then start again using only API's Henry Cabello @hacu9 Nov 25 2016 01:54 http://codepen.io/cabello986/pen/rrgdpV?editors=0010 Can anyone check my animation function? The animations r alil odd and i cant figure out a way to make it work :c silver537 @silver537 Nov 25 2016 01:54 you're gonna need the twitter API for the twitterbutton anyway samson @samcampc Nov 25 2016 01:55 hi guys can you help me with ceaser chapper silver537 @silver537 Nov 25 2016 01:55 @samcampc no code, no help samson @samcampc Nov 25 2016 01:55 i dont think i can type it while i learn from someone on internet function rot13(str) { // LBH QVQ VG! return str; } // Change the inputs below to test rot13("SERR PBQR PNZC"); silver537 @silver537 Nov 25 2016 01:56 copy and paste try something think about what you need. follow those links they provide you with. Moisés Man @moigithub Nov 25 2016 01:57 @samcampc did u checked the link the instruction provide ?? fromCharCode , charCodeAt and dunnowhat else Emily Christensen @emmalee113 Nov 25 2016 01:57 @silver537 i like that idea. because i definitely want to learn and understand the apis better but don't want to waste what i've made so far. are you still able to help me with the twitter button with my code the way it is? i read that you can set the button to go to href="https://twitter.com/intent/tweet" but that isn't doing anything unless my code is just messed up does the button need to be nested within the link or vice versa? Stephen James @sjames1958gm Nov 25 2016 01:58 @emmalee113 You can assign the correct URL as the href of an anchor tag <a> silver537 @silver537 Nov 25 2016 01:59 @emmalee113 and input your values in the query Emily Christensen @emmalee113 Nov 25 2016 01:59 @sjames1958gm and nest the button within that? silver537 @silver537 Nov 25 2016 02:00 if you're using bootstrap, the anchor tag can look like a button. with the btn btn-primary unless you're using the bird icon Stephen James @sjames1958gm Nov 25 2016 02:00 @silver537 :+1: silver537 @silver537 Nov 25 2016 02:00 no.... you can still do it. hehe JoannaPopo @joannapopo Nov 25 2016 02:01 hey you all. What am I doing wrong here? // Example var firstNameLength = 0; var firstName = "Ada"; firstNameLength = firstName.length; // Setup var lastNameLength = 0; var lastName = "Lovelace"; // Only change code below this line. var lastNameLenght = 8; var lastName = "Popovic"; lastNameLength = lastName.lenght; lastNameLength should be equal to eight. You should be getting the length of lastName by using .length like this: lastName.length. silver537 @silver537 Nov 25 2016 02:02 @joannapopo you misspelled length Ken Haduch @khaduch Nov 25 2016 02:02 @joannapopo - not sure of the requirment, but you have misspelled length in a couple places - the var lastNameLength, and the lastName.length Emily Christensen @emmalee113 Nov 25 2016 02:02 @silver537 yup i did both those! lol. so the only thing i'm unsure how to do here is to get it so when you click the tweet button, the current quote is displayed for someone who wants to tweet it. no idea where to start. as of now it opens a page where you can just make a new tweet JoannaPopo @joannapopo Nov 25 2016 02:03 :D i feel so bad now! @khaduch Moisés Man @moigithub Nov 25 2016 02:05 <a href="https://twitter.com/intent/tweet?text=hello%20world" _target="blank">twit me</a> __mifflin__ @cdrainxv Nov 25 2016 02:05 @joannapopo: Make use of the var lastName = "Lovelace"; that has been setup for you. The length of that variable is already 8 characters, whereas yours - Popovic- only has 7 characters. silver537 @silver537 Nov 25 2016 02:06 HA i found it! @emmalee113 read carefully :P https://dev.twitter.com/web/tweet-button/web-intent Ken Haduch @khaduch Nov 25 2016 02:06 @joannapopo - not to worry! It is just one of those things that you have to check - the variable name spelling is important here because the test setup is expecting to find exactly that spelling. And the function name (or method) just has to be spelled correctly to work... you can find that error in the console when you try to run the program, so you'll learn ways to debug those. Emily Christensen @emmalee113 Nov 25 2016 02:09 @silver537 haha i was looking at that same page. but how do i make it so it will tweet the content of whatever the current quote is? like to tweet out whatever {showQuotation()} is at that moment? also @silver537 thank you so much for all your help and patience CamperBot @camperbot Nov 25 2016 02:09 emmalee113 sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles: :cookie: 784 | @silver537 |http://www.freecodecamp.com/silver537 JoannaPopo @joannapopo Nov 25 2016 02:09 @khaduch also, English is not my first language, I am learning it only 3 years, I dont notice every wrong spelling lol. i see how important it is. Thank you @cdrainxv CamperBot @camperbot Nov 25 2016 02:09 joannapopo sends brownie points to @khaduch and @cdrainxv :sparkles: :thumbsup: :sparkles: :star2: 1103 | @cdrainxv |http://www.freecodecamp.com/cdrainxv :star2: 1971 | @khaduch |http://www.freecodecamp.com/khaduch silver537 @silver537 Nov 25 2016 02:10 @emmalee113 you can do something like $('a').attr("https://twitter.com/intent/tweet?text="+showQuotation())
im not a pro in jquery. so idk if that syntax is right
and also provided that showQuotation() is a function that returns the quote string.
@emmalee113 in that url, anything after the ? is a query. and you can use multiple queries by using &
tweet?text=my+text&hashtags=my,text
josephinemonica
@josephinemonica
Nov 25 2016 02:12
Hi can anyone tell me why this code doesn't work as it is supposed to
if ($("#searchBar").is(':focus')) {$("#data").html("searchBar is focus");
}
else{
$("#data").html("searchBar is NOT focus"); }$("#b").click(function(){
$("#data").html("MEH"); }) Intended: Hello changed to the corresponding text when : button is clicked, or searchBar is focus, or searchBar is not focus but neither works Ken Haduch @khaduch Nov 25 2016 02:14 @josephinemonica - when you add an ID attribute, you do not put the # in the id="data" - that # belongs in other places, but not there. it should just be as I wrote. Also the same for id="b" Diego Mayer @Chrono79 Nov 25 2016 02:15 @josephinemonica the numeral (#) is added when you want to target it with a css or a jquery selector, like$("#data") for jQuery or #data for css
josephinemonica
@josephinemonica
Nov 25 2016 02:17
Isee
Andrei Luca
@AndreiLuca99
Nov 25 2016 02:17
Hi, everyone.
josephinemonica
@josephinemonica
Nov 25 2016 02:17
now the searchbar ifocus still doesn't work
Andrei Luca
@AndreiLuca99
Nov 25 2016 02:17
I'm on the course 254.
josephinemonica
@josephinemonica
Nov 25 2016 02:17
Andrei Luca
@AndreiLuca99
Nov 25 2016 02:18
Let us share our experiences.
Please tell me what courses you're taking now?
Is there anyone who passed all the course now?
josephinemonica
@josephinemonica
Nov 25 2016 02:18
@khaduch @Chrono79 I have updated my code. The button now works, but the searchbar doesn't
Nov 25 2016 02:19
@AndreiLuca99 - the numbers are meaningless in terms of lessons - you have to go by the titles of the lessons to be accurate.
josephinemonica
@josephinemonica
Nov 25 2016 02:19
if ($("#searchBar").is(':focus')) {$("#data").html("searchBar is focus");
}

$("#b").click(function(){$("#data").html("MEH");
});
Nov 25 2016 02:19
@josephinemonica - the searchbar does not have a "click" function - it will only be checked when the code runs the first time. You would have to assign a click function, I think?
josephinemonica
@josephinemonica
Nov 25 2016 02:19
the button works, but the searchbar focus doesn't
@khaduch Isn't is Focus the same thing?
waiting for event?
Nov 25 2016 02:21
@josephinemonica - I don't think so? I've never used focus? Maybe something like "mouseover" would work? I don't know if there is a "focus" event, but you might be able to set up a handler for it. I think that what you have is not an event handler? Just a check for focus state?
@josephinemonica -https://api.jquery.com/focus/
josephinemonica
@josephinemonica
Nov 25 2016 02:23
@khaduch What do you mean by focus state?
handler
Type: Function( Event eventObject )
A function to execute each time the event is triggered.
Nov 25 2016 02:24
@josephinemonica - you are checking that the searchBar has "focus", which you can check at any time during a code execution. That is what I mean by "state" - is it in focus or not? The Event handler would trigger when you focus on the bar, and then you wouldn't really need to check the focus, because by definition you have it?
Diego Mayer
@Chrono79
Nov 25 2016 02:25
@josephinemonica
$('#searchBar').on("focus", function(){$("#data").html("searchBar is on focus");
});

$('#searchBar').on("blur", function(){$("#data").html("searchBar is not on focus");
});
theremdim
@theremdim
Nov 25 2016 02:27
hello hello! looking for a (hopefully) easy answer to a basic question: in this W3 example of a JQuery sliding nav menu, how would i allow the user to remove the menu by clicking 'anywhere else' on the document? http://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_sidenav_push
I've looked at this but am having a hard time changing it to apply http://stackoverflow.com/questions/34857303/sidebar-menu-close-when-click-elsewhere
josephinemonica
@josephinemonica
Nov 25 2016 02:28
@Chrono79 what's the difference between $('#searchBar').on("focus", function(){ AND$( "#searchBar" ).focus(function() {?
@Chrono79 They're both jquery?
Diego Mayer
@Chrono79
Nov 25 2016 02:28
@josephinemonica
https://api.jquery.com/on/
https://api.jquery.com/focus/
Yes, they are (focus is a shortcut)
josephinemonica
@josephinemonica
Nov 25 2016 02:28
@khaduch Ieven if I put the if-else statement. The if-else statement is ony executed once ?
Nov 25 2016 02:29
@josephinemonica - without an event handler, yes, only one pass through the code that checks that condition.
josephinemonica
@josephinemonica
Nov 25 2016 02:30
CamperBot
@camperbot
Nov 25 2016 02:30
josephinemonica sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
josephinemonica
@josephinemonica
Nov 25 2016 02:30
@Chrono79 Thanks :)
CamperBot
@camperbot
Nov 25 2016 02:30
josephinemonica sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 2628 | @chrono79 |http://www.freecodecamp.com/chrono79
silver537
@silver537
Nov 25 2016 02:39
Nov 25 2016 02:41
@theremdim @theremdim - well, the example that is shown on the jsfiddle link within that stackoverflow discussion is using jquery (and it doesn't seem to work for me, or at least it doesn't work anymore, perhaps some stale code?) The w3schools code is using straight javascript functions. Have you taken that into account? (My first question.)
Joseph
@revisualize
Nov 25 2016 02:41
Hello.
Nov 25 2016 02:41
@josephinemonica - you're welcome
silver537
@silver537
Nov 25 2016 02:42
@revisualize SILENCE!!!
theremdim
@theremdim
Nov 25 2016 02:45
aha @khaduch . step one forme
I feel like the idea of changing class resonates with reading I've done
Konstantin Mazur
@incerta
Nov 25 2016 02:47
var a just test markdowns
theremdim
@theremdim
Nov 25 2016 02:50
CamperBot
@camperbot
Nov 25 2016 02:50
theremdim sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Gabriel Betancourt
@mau5atron
Nov 25 2016 02:52
Anyone here familiar with the counting cards challenge?
Joseph
@revisualize
Nov 25 2016 03:07
I am.
Sup?
theremdim
@theremdim
Nov 25 2016 03:07
or anyone else interested; how to make the side nav retract when user clicks anywhere outside of it
Edward Alexander Pineda Marín
@edwardpmarin
Nov 25 2016 03:14
i need help with the Couting Cards excercise
Gabriel Betancourt
@mau5atron
Nov 25 2016 03:15
0- @revisualize I'm very stuck
Edward Alexander Pineda Marín
@edwardpmarin
Nov 25 2016 03:15
this is my code

var count = 0;

function cc(card) {
// Only change code below this line

if (card==2||card==3||card||4||card==5||card==6){
count ++;
}

else if (card==7||card==8||card||9){
count = count+0;
}

else {
count--;
}

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

else
{
return count+" Bet";
}
}

// Note: Only the last will display
cc(2); cc(3); cc(2); cc('K'); cc('A');

Kunjang sherpa
@sherpaguy
Nov 25 2016 03:16
hey guys need help. got stuck @ return early pattern for functions.
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
Moisés Man
@moigithub
Nov 25 2016 03:19
@edwardpmarin ||card==3||card||4 4 is wrong also 9
Edward Alexander Pineda Marín
@edwardpmarin
Nov 25 2016 03:23
:O
Thank you
this wrong was invisible for me
@moigithub you are amazing jejejeje
Nov 25 2016 03:28
@theremdim - - the link that you posted there :point_up: November 24, 2016 10:07 PM in your comment works if you hit the ESC button - that toggles the menu. Did you see how that works? I would think that you could try a click handler anywhere on the window, and to determine if you haven't clicked on the menu, or maybe even if you have clicked on the menu? THen toggle the navbar?
Nov 25 2016 03:33

@theremdim - if you take that example that you posted, for example, and add this code:

// Normal Clicks
$(function() {$('.toggle-nav').click(function() {
$('body').toggleClass('show-nav'); return false; });$('body').click(function() {
$('body').toggleClass('show-nav'); return false; }); }); It will toggle the menu if you click anywhere on the page, it seems... so if you just wanted it to toggle the menu off only if it was exposed, then you could probably test where the click happened, and if it wasn't in the menu, then don't toggle? did that make any sense? Ken Haduch @khaduch Nov 25 2016 03:45 @theremdim - instead of what I posted above, try this: $(function() {
$('.toggle-nav').click(function() {$('body').toggleClass('show-nav');
return false;
});
// ADD THIS CODE TO THE EXAMPLE
$('.push-wrap').click(function() { if ($('body').hasClass("show-nav")) {
$('body').toggleClass('show-nav'); return false; } }); }); This adds a click handler to the .push-wrap, which is the main content div of the page, and if the body has the class "show-nav", when it toggles it off and hides the panel if you click in the body, but doesn't hide it if you click in the navbar. I think that might be the effect that you wanted? Kunjang sherpa @sherpaguy Nov 25 2016 03:58 @edwardpmarin hey ! were you able to complete the card counting exercise? Eduardo Sujević @Eduardo40 Nov 25 2016 04:06 Hello, im stuck at the "seek and destroy", can someone look at my code?  function destroyer(arr,...args) { for(var i=0;i<arr.length;i++){ for(var j=0;j<args.length;j++){ if(arr[i] === args[j]){ arr.splice([i],args.length -1); } } } return arr; } Anthony Drane @Antiaccess Nov 25 2016 04:55 Hey guys, anyone able to help me make my markdown viewer display the markdown on $(document).ready
https://codepen.io/antiaccess/pen/dORmwa
It works as soon as you add some text
hongwutian
@hongwutian
Nov 25 2016 05:01

function lookUpProfile(firstName, prop){
// Only change code below this line
var i = 0;
while(i <4){
if (contacts[i].firstName === firstName){

  break;
}
i++;

}
if (contacts[i].hasOwnProperty(prop) === true && i < 4){
return contacts[i][prop];
}
else if ( i > 3){
return "No such contact";
}
else if (contacts[i].hasOwnProperty(prop) !== true && i <4){
return "No such property";
}
// Only change code above this line
}

Anyone know why non exist firstname won't work?
vikash kumar
@vikashqa
Nov 25 2016 05:21
How to convert celsius to fahrenheit
Ba Ba K
@cyclops24
Nov 25 2016 05:22
Hi guys,
I have a small question anyone here?
vikash kumar
@vikashqa
Nov 25 2016 05:22
return fahrenheit;

how to convert celsius to fahrenheit

function convertToF(celsius) {
var fahrenheit;

// Only change code below this line

F=9/5*c+32;
// Only change code above this line
return fahrenheit;
}

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

Ghulam Shabir
@ghulamshabir
Nov 25 2016 05:23
@iceveda06 no I haven't yet
Will
@Will-is-Coding
Nov 25 2016 05:23
@vikashqa What is c in that equation though? Not defined
@cyclops24 What's the issue?
LandonBreeden
@LandonBreeden
Nov 25 2016 05:23
@vikashqa 9/5 is quall to1.8
Will
@Will-is-Coding
Nov 25 2016 05:24
@hongwutian Might want to try using a for loop instead. And not constantly be checking the size of i
LandonBreeden
@LandonBreeden
Nov 25 2016 05:24
equall**
Ba Ba K
@cyclops24
Nov 25 2016 05:25

I have a utils.js file with contents like below:

this.isValidEmail = function(value) {
var filter = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if(filter.test(value)) { return true; } return false; }; Now I want to use ES6 style to manage my utils. I don't know how I can manage my utils functions in a ES6 class and import it somewhere. I search a lot about static function in ES6 but what is the best way for this? Ghulam Shabir @ghulamshabir Nov 25 2016 05:25 @vikashqa you have variables available for F and c, replace them Ba Ba K @cyclops24 Nov 25 2016 05:25 @Will-is-Coding Please read above man. Will @Will-is-Coding Nov 25 2016 05:25 @vikashqa You haven't defined c what I think you mean to use is celsius which is your parameter. vikash kumar @vikashqa Nov 25 2016 05:27 @Will-is-Coding can u help to do tht function convertToF(celsius) { var fahrenheit; var c =celsius; // Only change code below this line F=9/5*c+32; // Only change code above this line return fahrenheit; } // Change the inputs below to test your code convertToF(30); convertToF(0); Eric Pacheco @ZucchiniC0d3er Nov 25 2016 05:27 Record Collection exorcise. Need to know what I am doing wrong to put the value in the record array. function updateRecords(id, prop, value) { if(prop !== "tracks" && value !==""){ collectionCopy.put("album", value); } else if(prop ==="tracks"){ if(!collection.id[prop]){ var tracks = {}; collection.push(tracks); if(value !== ""){ arr.push(value); } collectionCopy.id.tracks =arr; } } else if(value ===""){ collectionCopy.id.shift(prop); } return collection; } Will @Will-is-Coding Nov 25 2016 05:27 @cyclops24 I haven't gotten too much into ES6, and I'm not quite sure I understand your problem. Trying to import this function into another file to use? @vikashqa Okay, now you have var c = celsius what about F? It's not declared properly and you're not returning it Ghulam Shabir @ghulamshabir Nov 25 2016 05:29 @ZucchiniC0d3er id is a variable you can not use variables in dot notation is export default is best way for this? Ghulam Shabir @ghulamshabir Nov 25 2016 05:31 @cyclops24 static functions in js are not like classical static methods in java, they are different Ba Ba K @cyclops24 Nov 25 2016 05:32 What is they difference? vikash kumar @vikashqa Nov 25 2016 05:33 @Will-is-Coding not able to do tht Shane Peterson @SDPeterson777 Nov 25 2016 05:35 I am having a hard time with the "Accessing Nested Objects" challenge Will @Will-is-Coding Nov 25 2016 05:35 @cyclops24 I think export default would work fine, since it's just one object you're exporting. But how are you currently importing it? However, it also seems, by using this. syntax, that this function is part of a larger object? Ghulam Shabir @ghulamshabir Nov 25 2016 05:37 @cyclops24 my bad they work similarly Shane Peterson @SDPeterson777 Nov 25 2016 05:43 can someone help me Ba Ba K @cyclops24 Nov 25 2016 05:43 Now my helpers (Utils.js) is like this: export default { leftZeroFill(number, targetLength) { var output = number + ''; while (output.length < targetLength) { output = '0' + output; } return output; }, isValidEmail(value) {...},.... And I import this like this: import Utils from '../../api/Utils.js'; My code is working now but I want to know is it best way or any other best practice exists about this question? @ghulamshabir , @Will-is-Coding Ghulam Shabir @ghulamshabir Nov 25 2016 05:45 @cyclops24 don't you think you may need a class definition for Utils ? Will @Will-is-Coding Nov 25 2016 05:46 @cyclops24 I wouldn't know about the best practices, honestly. No you don't technically need a class definition, depends on what you want to do. Export simple function helpers or export it as an object that you may want to instantiate with different properties, etc. Ghulam Shabir @ghulamshabir Nov 25 2016 05:47 oh i see Ba Ba K @cyclops24 Nov 25 2016 05:50 @ghulamshabir , @Will-is-Coding thanks guys so I keep my code and go to next task :smile: vikash kumar @vikashqa Nov 25 2016 05:56 my challng is escaping literal quotes in string var myStr = I am a"double quoted"string inside"double quotes"; @ghulamshabir Ashan Mohammed @AshanMohammed Nov 25 2016 06:02 Hello! Can i use both javascript and jquery in a page? Ghulam Shabir @ghulamshabir Nov 25 2016 06:02 @vikashqa you need to escape quotes using \ @AshanMohammed yes you can @AshanMohammed jquery is just a js object named $
Ashan Mohammed
@AshanMohammed
Nov 25 2016 06:03
@ghulamshabir Thanks
CamperBot
@camperbot
Nov 25 2016 06:03
ashanmohammed sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1133 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ashan Mohammed
@AshanMohammed
Nov 25 2016 06:04
@ghulamshabir Do i need to load any cdn into my page to do that?
Ghulam Shabir
@ghulamshabir
Nov 25 2016 06:05
vikash kumar
@vikashqa
Nov 25 2016 06:05
@ghulamshabir not able to do tht
Ghulam Shabir
@ghulamshabir
Nov 25 2016 06:05
@vikashqa current code?
vikash kumar
@vikashqa
Nov 25 2016 06:06
@ghulamshabir where to use \
var myStr = \I am a,"double quoted"string inside"double quotes";
Ghulam Shabir
@ghulamshabir
Nov 25 2016 06:07
@vikashqa you are not escaping quotes, it should be \"
@vikashqa do not change any other character except escaping quotes
vikash kumar
@vikashqa
Nov 25 2016 06:12
@ghulamshabir how to use in this
I am a "double quoted" string inside "double quotes"
Ghulam Shabir
@ghulamshabir
Nov 25 2016 06:13
@vikashqa do you see the quotes inside the string ?
@vikashqa put a backlash in front of each quote
Josceline Feng
@JoscelineF
Nov 25 2016 06:55
Could any one help me with the exercise "Where do I belong"?
My code is as below:

function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr.sort(function(a, b){return a - b;});

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

}

var n = arr.indexOf(mnNum);
return n+1;
}

getIndexToIns([5, 3, 20, 3], 5);

Markus Kiili
@Masd925
Nov 25 2016 06:56
@JoscelineF The solution is much simpler if you first push num into arr and then sort.
Josceline Feng
@JoscelineF
Nov 25 2016 06:57
Yes, I have googled the answer, while still don't understand what's wrong with the logic in my code...
Markus Kiili
@Masd925
Nov 25 2016 06:57
There is also a clever way to solve it without sorting at all.
Josceline Feng
@JoscelineF
Nov 25 2016 06:57
@Masd925 Oh,really? Could you please give a hint?
Markus Kiili
@Masd925
Nov 25 2016 06:58
@JoscelineF You can figure out your spot in a queue by length by counting the number of people shorter than you.
Josceline Feng
@JoscelineF
Nov 25 2016 07:00

@Masd925 Thank you. But isn't it similar to my code as :

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

CamperBot
@camperbot
Nov 25 2016 07:00
joscelinef sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3007 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Nov 25 2016 07:05
@JoscelineF If you just forget sorting and just count the arr elements <num it will work.
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:09
lets filter the number of people shorter than me ;)
Josceline Feng
@JoscelineF
Nov 25 2016 07:10
@Masd925 Thank you~~
CamperBot
@camperbot
Nov 25 2016 07:10
joscelinef sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: joscelinef already gave masd925 points
Markus Kiili
@Masd925
Nov 25 2016 07:10
@JoscelineF Your code has a couple of logical errors. You find out the last element that is <num. Then you find out the index of first element equal to it and add 1. If there are several of those, it doesn't really work. Also if the num is the smallest, the code doesn't work.
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:10
@abhisekp - me
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:11
that was a hint for Where do I belong challenge ;P
Markus Kiili
@Masd925
Nov 25 2016 07:12
@abhisekp I remember that in school the queue
order was by muscle mass.
That order was hard to challenge.
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:13
lol
Markus Kiili
@Masd925
Nov 25 2016 07:13
By a skinny guy who could remember 30 Pi decimals.
mindiuxa
@mindiuxa
Nov 25 2016 07:13

Good morning to everyone. I have problem with challenge on switch statement.I write a code but there is something wrong. function caseInSwitch(val) {
// Only change code below this line
switch(val){
case"1":
break;
case"2":
break;
case"3":
break;
case"4":

// Only change code above this line
}

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

Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:14
:muscle:
@mindiuxa
js  [shift + enter for newline]

<code here>

    [ctrl + enter to post] 
Josceline Feng
@JoscelineF
Nov 25 2016 07:15
@Masd925 Thank you for your explanation. I thought that if there are several equal values of the num in the arr, then whatever location of the num among them does not matter. Seems what I thought was wrong
CamperBot
@camperbot
Nov 25 2016 07:15
joscelinef sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: joscelinef already gave masd925 points
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:15
@mindiuxa is your case testing for a number or number string? your answer was returned in the switch statement i think it should be out
Markus Kiili
@Masd925
Nov 25 2016 07:16
@JoscelineF Yes, you should return the smallest index where it can be inserted.
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:17
@mindiuxa you should be thinking of storing your result of each case in answer, you're not makin answer a variable to store result be doing this answer(delta).. ... assign delta to answer
Josceline Feng
@JoscelineF
Nov 25 2016 07:17
@Masd925 realized now. Thanks again~
CamperBot
@camperbot
Nov 25 2016 07:17
joscelinef sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: joscelinef already gave masd925 points
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:17
@Masd925 good morning
Markus Kiili
@Masd925
Nov 25 2016 07:18
@Lumexralph Hi.
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:18
@Masd925 How's it going?
Markus Kiili
@Masd925
Nov 25 2016 07:20
@Lumexralph Just got laid off two days ago. Have to start pumping my "javascript".substring(0,4); muscles.
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:22
@Masd925 good for you man, all the best.... am thinking of picking up python after i am done with understanding the major concepts in Javascript.....
@Masd925 never for once thought of Java..
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:24
everytime you think about JavaScript, you think of Java..
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:24
is it as cranky as C language?
Markus Kiili
@Masd925
Nov 25 2016 07:24
@Lumexralph Some recruiter contacted me yesterday, even though I have no LinkedIn profile yet, nor do I have anything really on my github, and my email should not be visible anywhere. They must be buying information from Echelon that spies on our gmails.
dayashankar
Nov 25 2016 07:24
@fanaugen Convert Celsius to Fahrenheit
help me on this
CamperBot
@camperbot
Nov 25 2016 07:24
no wiki entry for: me on this
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:25
@Masd925 lol,was the offer good? you never can say a colleague might have recommended you
@abhisekp funny enough i don't
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:26
Guess the language
class Student extends Employee {}
Markus Kiili
@Masd925
Nov 25 2016 07:27
dayashankar
Nov 25 2016 07:27
Convert Celsius to Fahrenheit...help me on this
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:27
@dayadee celsius is a parameter for your function that you're to apply the formula of converting Celsius to Fahrenheit and store your result in your Fahrenheit variable then return that answer
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:27

They must be buying information from Echelon that spies on our gmails.

@Masd925 huh? o_O

Ogundele Olumide
@Lumexralph
Nov 25 2016 07:27
@Masd925 probably they'll be back
@Masd925 do Google support spying on their customers?
Markus Kiili
@Masd925
Nov 25 2016 07:29
@abhisekp I got laid off two days ago and yesterday I was contacted by a recruiter. That was the first time ever. I have to get some tin foil over my skull.
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:29
NSA supports spying
mindiuxa
@mindiuxa
Nov 25 2016 07:29
@Lumexralph thank you!!!
CamperBot
@camperbot
Nov 25 2016 07:29
mindiuxa sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:30
@abhisekp uh oh! but that's not cool
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:30
that's cool for them
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:30
dayashankar
Nov 25 2016 07:30
@Lumexralph so what should i do now
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:31
@dayadee so you know the formula of converting Celsius to Fahrenheit?
@abhisekp any platform apart from them that doesn't support spying?
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:32
@Lumexralph Watch "Snowden" movie
dayashankar
Nov 25 2016 07:32
@Lumexralph fahrenheit= convertToF(9/5)+32;
im i right?
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:33
@Masd925 seen this new browser Brendan Eich always talking about on Twitter?
Markus Kiili
@Masd925
Nov 25 2016 07:33
@Lumexralph It is also not nice that they spy company secrets from foreign firms and give them to US companies.
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:34
@Masd925 and people are quiet about it?
dayashankar
Nov 25 2016 07:34

@Lumexralph THIS IS MY CODE

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit= convertToF(9/5)+32;

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

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

Ogundele Olumide
@Lumexralph
Nov 25 2016 07:35
@dayadee convertToF is the name of your function that's wrong there, only if you want to apply recursion and this does not need recursion
dayashankar
Nov 25 2016 07:37
@Lumexralph can you send the code please. becasuse im not getting
Thomas Hicks
@forbajato
Nov 25 2016 07:37
How do you delete a property from a JSON object? I am trying to do the Record Collection challenge and the instructions say:
Markus Kiili
@Masd925
Nov 25 2016 07:38
@forbajato That is a JS object. Nothing really to do with JSON.
Use delete operator. delete obj[key] or delete obj.key
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:38
js  [shift + enter for newline]

<code here>

    [ctrl + enter to post] 
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:39
@dayadee Fahrenheit =(( Celsius * 9) / 5) + 32
Thomas Hicks
@forbajato
Nov 25 2016 07:39
@Masd925 Thanks!
CamperBot
@camperbot
Nov 25 2016 07:39
forbajato sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3008 | @masd925 |http://www.freecodecamp.com/masd925
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:39
that's what you're to do
William Huang
@WilliamHuang1995
Nov 25 2016 07:40
hey
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:41
$\Huge{\text{F}=\text{C}\times\frac{9}{5}+32}$
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:41
@dayadee @abhisekp is showing you how to paste your code, you should try it out
William Huang
@WilliamHuang1995
Nov 25 2016 07:41
i'm having trouble understanding this task
c0d0er
@c0d0er
Nov 25 2016 07:41
@toianw thanks!
CamperBot
@camperbot
Nov 25 2016 07:41
c0d0er sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
dayashankar
Nov 25 2016 07:42
@abhisekp fahrenheit= celsius(9/5)+32;
i have done this
William Huang
@WilliamHuang1995
Nov 25 2016 07:42
Thomas Hicks
@forbajato
Nov 25 2016 07:42
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:42
@dayadee you left the multiplication operator *
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:42
@WilliamHuang1995
we can't see the code
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:43
@WilliamHuang1995 what does the instruction say?
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:43
@dayadee check the formula i wrote for you
dayashankar
Nov 25 2016 07:43
@abhisekp oh okay,i thought brackets are enough
thq
William Huang
@WilliamHuang1995
Nov 25 2016 07:44
@Lumexralph wait how do you link the challenge with my code in it
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:44
@dayadee everything must be explicitly written unless otherwise stated using any shortcuts
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:44
@dayadee Javascript engine doesn't see the way humans see, you have to use its Language
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:45
:eyes: <--- JS can see with these
William Huang
@WilliamHuang1995
Nov 25 2016 07:45
help
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:45
:eyes: <--- eyes of JS
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:45
@WilliamHuang1995 you mean paste your code here, right?
William Huang
@WilliamHuang1995
Nov 25 2016 07:45
nvm
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
];
var hisMusic ={
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
};
myMusic.push (hisMusic);
is there a better way than doing this
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:46
@WilliamHuang1995 what does the instruction say?
William Huang
@WilliamHuang1995
Nov 25 2016 07:46
Add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings.
Tim Stawowski
@officer-sexy
Nov 25 2016 07:47
@WilliamHuang1995 you have to write the 2nd object right after the first one in myMusic, you dont't have to initialize a 2nd variable
William Huang
@WilliamHuang1995
Nov 25 2016 07:48
well i passed the test still
Tim Stawowski
@officer-sexy
Nov 25 2016 07:48
@WilliamHuang1995 just seperate the object - elements with a komma
@WilliamHuang1995
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
},
{
"artist": "",
"title": "",
"release_year": 2020,
"formats": [
"2",
"2",
"2"]
}
];
sainijassi
@sainijassi
Nov 25 2016 07:49
lllllllllll
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:50
@WilliamHuang1995 you have added to the array, the easiest i know to do that is push but if you know the last index of the array you can use array[lastindex + 1].... that'll put at the end the array
William Huang
@WilliamHuang1995
Nov 25 2016 07:51
aight
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:51
@WilliamHuang1995 yeah
Markus Kiili
@Masd925
Nov 25 2016 07:52
@Lumexralph arr[arr.length]=... also adds to the end of array.
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:53
@Masd925 very true
Markus Kiili
@Masd925
Nov 25 2016 07:53
A bit faster than push, but using that syntax to make elements can make an array with holes, which is to be avoided.
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:54
@Masd925 you meant the one you talked about?
how does that happen
Markus Kiili
@Masd925
Nov 25 2016 07:55
@Lumexralph I mean that using methods is safer than assigning when you make array elements.
var arr = [];
arr[5] = "cat";
console.log(arr.length); // 6
There are no elements at indices 0,1,2,3,4 and that causes some problems when you iterate the array etc. Browsers also have hard time optimizing the code when you have holes.
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:57
i understand what you're saying
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:58
...and that is called a Sparse Array
Markus Kiili
@Masd925
Nov 25 2016 07:58
Nobody really remembers how different iterators handle holes, so using them is not a good idea.
Ogundele Olumide
@Lumexralph
Nov 25 2016 07:59
@abhisekp sparse array you say.... :worried: lol
Abhisek Pattnaik
@abhisekp
Nov 25 2016 07:59
Compiler traverses the array twice for working with a sparse array.
optimization goes to the pit :poop:
Thomas Hicks
@forbajato
Nov 25 2016 08:07
Is there a place to see other people's solutions to challenges? I managed to pass the Record Collection challenge but ... "elegant" would hardly be the proper descriptor, would love to see something better.
William Huang
@WilliamHuang1995
Nov 25 2016 08:07
// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents = myStorage.car.inside["glove box"];
any other way to access the glove box element other than this?
can I do myStorage["car"]["inside"]["glove box"]?
nvm I got it
Thomas Hicks
@forbajato
Nov 25 2016 08:10
@WilliamHuang1995 In Chromium you can use the javascript console to check stuff like that - probably other browsers have such a thing as well.
William Huang
@WilliamHuang1995
Nov 25 2016 08:10
oh
how would I go about doing that? after ctrl+shift+i
@forbajato
Ogundele Olumide
@Lumexralph
Nov 25 2016 08:11
@WilliamHuang1995 you can use repl.it too
Thomas Hicks
@forbajato
Nov 25 2016 08:12
@WilliamHuang1995 When I do ctrl+shift+i it opens the developer console, at the top it has a menu that includes Elements, Console, etc. Click on Console and I can enter javascript just like I was at a terminal.
Hari
@clocarius
Nov 25 2016 08:13
Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
var myStr= "I am a \"double quoted\"\"double quotes\""; why it's still not work ?
Markus Kiili
@Masd925
Nov 25 2016 08:13
@forbajato You can see peoples solution on their profiles, I think.
CamperBot
@camperbot
Nov 25 2016 08:13
Markus Kiili
@Masd925
Nov 25 2016 08:13
Now I could look at your profile.
Thomas Hicks
@forbajato
Nov 25 2016 08:14
Fantastic, I'll check it out!
CamperBot
@camperbot
Nov 25 2016 08:14
:star2: 3008 | @masd925 |http://www.freecodecamp.com/masd925
Thomas Hicks
@forbajato
Nov 25 2016 08:17
Thanks again @Masd925 , you solution to the Record Collection is helpful, cleaner conditionals.
CamperBot
@camperbot
Nov 25 2016 08:17
forbajato sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: forbajato already gave masd925 points
TipXZ
@TipXZ
Nov 25 2016 08:17

Hi,
I have to this:
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
With var testArr = [1,2,3,4,5];

My function is:
function nextInLine(arr, item) {
testArr.push(item);
testArr.shift();

return item; // Change this line
}

But it just don't pass two test :
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5

Can you help me understand what is wrong ?

William Huang
@WilliamHuang1995
Nov 25 2016 08:19
return item needs to be changed
should return the element that was removed
TipXZ
@TipXZ
Nov 25 2016 08:19
oooh
atogz
@atogz
Nov 25 2016 08:20
Hey guys! Can someonye please explain why my function is not working correctly? Just started leaerning JS ... :)

function yourName(name) {
var inputName = prompt('What is your name?');
if (inputName = 'Alex') {
return 'I know, you are Alex!';
}
else {
return 'Sorry, i don\'t recongnize you....';
}
}

William Huang
@WilliamHuang1995
Nov 25 2016 08:20
inputName =='Alex'
atogz
@atogz
Nov 25 2016 08:20
ah
Correct if i'im wrong, if i put single = it means i set a string
and to check i should use ==
William Huang
@WilliamHuang1995
Nov 25 2016 08:22
ye
100%
atogz
@atogz
Nov 25 2016 08:22
Big thanks, William :)
William Huang
@WilliamHuang1995
Nov 25 2016 08:22
np! :)
Markus Kiili
@Masd925
Nov 25 2016 08:22
@atogz = is assigning a value. === is comparison. == should not be used.
atogz
@atogz
Nov 25 2016 08:23
@Masd925 == also works though, but right way is to use === ?
Carlos
@clockwerkz
Nov 25 2016 08:23
Why should == not be used?
Ogundele Olumide
@Lumexralph
Nov 25 2016 08:23
@Masd925 you're also a fan of the the strict mode right?
William Huang
@WilliamHuang1995
Nov 25 2016 08:24
== is abstract comparison
Ogundele Olumide
@Lumexralph
Nov 25 2016 08:25
@clockwerkz because it only values and not data type compared to === that checks both values and data type e.g 1 == "1"\true 1 === "1" \\ false
William Huang
@WilliamHuang1995
Nov 25 2016 08:26
var a = 10
var b ='10'
a==b //true
a===b // false
that's basically why
Markus Kiili
@Masd925
Nov 25 2016 08:26
@atogz The abstract equality involves coercing the values to same type before comparing. The actual algorithm that tells how it works is very complicated and somewhat arbitrary, so most people don't know how it actually works. So using == makes code that is hard to understand and at least makes you think. With === you see what it does easily.
atogz
@atogz
Nov 25 2016 08:26
@Masd925 Great explanation, i think i got it :) Thanks
CamperBot
@camperbot
Nov 25 2016 08:26
atogz sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3009 | @masd925 |http://www.freecodecamp.com/masd925
Carlos
@clockwerkz
Nov 25 2016 08:27
Ahh gotcha, cool.
Ogundele Olumide
@Lumexralph
Nov 25 2016 08:27
@clockwerkz it helps with a consistent result and not unusual result like == might do at times except you're 100% aware of everything going on in your code
Markus Kiili
@Masd925
Nov 25 2016 08:27
I have read it a couple of times from the ECMAScript standard and have some help sheets about how == works, but I don't remember how it works.
William Huang
@WilliamHuang1995
Nov 25 2016 08:27
oh you get brownie points for thanking someone and a tag?
Carlos
@clockwerkz
Nov 25 2016 08:28
@WilliamHuang1995 @Masd925 @Lumexralph Thanks!
CamperBot
@camperbot
Nov 25 2016 08:28
clockwerkz sends brownie points to @williamhuang1995 and @masd925 and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 3010 | @masd925 |http://www.freecodecamp.com/masd925
William Huang
@WilliamHuang1995
Nov 25 2016 08:28
@camperbot thanks!
CamperBot
@camperbot
Nov 25 2016 08:28
williamhuang1995 sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 2656 | @camperbot |http://www.freecodecamp.com/camperbot
William Huang
@WilliamHuang1995
Nov 25 2016 08:28
lul
Carlos
@clockwerkz
Nov 25 2016 08:28
Dropping brownie points on the whole lot of ya
William Huang
@WilliamHuang1995
Nov 25 2016 08:28
@clockwerkz thanks bud
CamperBot
@camperbot
Nov 25 2016 08:28
williamhuang1995 sends brownie points to @clockwerkz :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for clockwerkz
Ogundele Olumide
@Lumexralph
Nov 25 2016 08:28
@clockwerkz :smile:
William Huang
@WilliamHuang1995
Nov 25 2016 08:28
wait why
:walking:
Carlos
@clockwerkz
Nov 25 2016 08:29
Weird. I think it's because I changed my handle recently
bamcrown
@bamcrown
Nov 25 2016 08:44
help witescape-sequences-in-strings, here my code: var myStr ='here is a backslash: \.\n\r\t\\tHere is a new line with two tabs.'; // Change this line
CamperBot
@camperbot
Nov 25 2016 08:44
no wiki entry for: witescape-sequences-in-strings here my code var mystr here is a backslash nrtthere is a new line with two tabs change this line
Ghulam Shabir
@ghulamshabir
Nov 25 2016 08:45
@Masd925 thanks I did it using reduce too
CamperBot
@camperbot
Nov 25 2016 08:45
ghulamshabir sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3011 | @masd925 |http://www.freecodecamp.com/masd925
Philipp Scholz
@philipp32
Nov 25 2016 08:49
Hello mah fellow campers;
I am busy with the challenge mutation.

function mutation(arr) {
return arr[0].indexOf(arr[1])===true ? true : false;

}

mutation(["hello", "hey"]);
Why does my code only return false?
vague13
@vague13
Nov 25 2016 08:49
Hi good afternoon. can you help me with the spinal tap case algorithm, how can i separate inputs like this "thisIsSpinalTap"
Markus Kiili
@Masd925
Nov 25 2016 08:50
@philipp32 IndexOf returns a number. It is never === true.
Ogundele Olumide
@Lumexralph
Nov 25 2016 08:51
@vague13 you split the string to an array
TipXZ
@TipXZ
Nov 25 2016 08:51

function nextInLine(arr, item) {
testArr.push(item);
var test=testArr.shift();

return test; // Change this line

}

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

I don't get why the test nextInLine([5,6,7,8,9], 1) should return 5 is not working

Ogundele Olumide
@Lumexralph
Nov 25 2016 08:51
@TipXZ you have arr as the parameter in your function and not testArr
Philipp Scholz
@philipp32
Nov 25 2016 08:52
@TipXZ you need to declace testArr as a variable
Ghulam Shabir
@ghulamshabir
Nov 25 2016 08:53
@TipXZ testArr is global, you are supposed to use local ones
Ogundele Olumide
@Lumexralph
Nov 25 2016 08:54
@TipXZ arr is holding the array you'll have to push the item to and as @ghulamshabir testArray is global variable
@ghulamshabir hey bro, been a lil while, how're you?
TipXZ
@TipXZ
Nov 25 2016 08:55
oh well !

function nextInLine(arr, item) {

arr.push(item);
return arr.shift() // Change this line

}

better this way ;) thanks
Ghulam Shabir
@ghulamshabir
Nov 25 2016 08:55
@Lumexralph hey there bro, yes I got throat infection, its winter here
Ogundele Olumide
@Lumexralph
Nov 25 2016 08:55
@ghulamshabir sorry bro, welcome back
Ghulam Shabir
@ghulamshabir
Nov 25 2016 08:56
@Lumexralph thanks, how are you doing ?
CamperBot
@camperbot
Nov 25 2016 08:56
ghulamshabir sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
Ogundele Olumide
@Lumexralph
Nov 25 2016 08:57
@ghulamshabir am good been a lil away also work and some other stuffs to attend to
@ghulamshabir on break at school?
Ghulam Shabir
@ghulamshabir
Nov 25 2016 08:58
@Lumexralph yes I got a leave today I am still not well, can't speak loudly to teach my students
Ogundele Olumide
@Lumexralph
Nov 25 2016 08:59
@ghulamshabir speedy recovery, good your fingers can type :wink:
Philipp Scholz
@philipp32
Nov 25 2016 08:59
function mutation(arr) {
var string1 = arr[0]; // first half of array
var string2 = arr[1]; // second half of array

return string2.includes(string1.split(""));

}

mutation(["hello", "hel"]);
Why isn't this working? It only returns false.
Ghulam Shabir
@ghulamshabir
Nov 25 2016 08:59
@Lumexralph haha yes thanks again
CamperBot
@camperbot
Nov 25 2016 08:59
ghulamshabir sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: ghulamshabir already gave lumexralph points
vague13
@vague13
Nov 25 2016 08:59
@Lumexralph can you please elaborate sir, how can I split "thisIsSpinalTap" if it has no space or special character
William Maes
@maeswilliam
Nov 25 2016 09:02
How can i represent all non-alphanumeric characters?
dtonlai
@dtonlai
Nov 25 2016 09:02
Hi, can I get some help with "Accessing Objects Properties with Variables"?
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:03
@vague13 you have to use a regular expression
dtonlai
@dtonlai
Nov 25 2016 09:04
I am able to get the player name using the bracket notation, but it's asking me to use the variable playerNumber in my bracket.
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:04
@vague13 to match the upper case letter and split from there, can we do without the sir thing pls :smile:
ashkrish07
@ashkrish07
Nov 25 2016 09:05
@dtonlai can you post your code
dtonlai
@dtonlai
Nov 25 2016 09:06
@ashkrish07 var playerNumber; // Change this Line
var player = testObj[16];
Oh, sorry I don't know how people are posting the code nicely in this channel.
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:06
@maeswilliam /\W/ or /[^\w]/
ashkrish07
@ashkrish07
Nov 25 2016 09:07
@dtonlai Enclose your code like this your code
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:07
@dtonlai when you use a variable to access an object you use object[variable name]....without double quotes
dtonlai
@dtonlai
Nov 25 2016 09:08
@ashkrish07 Specifically, how can I enclose my code? Sorry I'm pretty new.
ashkrish07
@ashkrish07
Nov 25 2016 09:11
Ghulam Shabir
@ghulamshabir
Nov 25 2016 09:11
@dtonlai @Lumexralph when you use a varaible as key
dtonlai
@dtonlai
Nov 25 2016 09:11
@Lumexralph OK, so my variable is testObj and I'm trying to figure out the player's name so I put in his number in brackets without quotes.
js
var playerNumber = 16;
var player = testObj[16];
vague13
@vague13
Nov 25 2016 09:12
@Lumexralph thank you.
CamperBot
@camperbot
Nov 25 2016 09:12
vague13 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
dtonlai
@dtonlai
Nov 25 2016 09:13
@ashkrish07 Thanks for showing me how to encode my code.
CamperBot
@camperbot
Nov 25 2016 09:13
dtonlai sends brownie points to @ashkrish07 :sparkles: :thumbsup: :sparkles:
ashkrish07
@ashkrish07
Nov 25 2016 09:13
@dtonlai try using playerNumber inside brackets
Ghulam Shabir
@ghulamshabir
Nov 25 2016 09:13
@Lumexralph @dtonlai sometimes strings are used in brackets if a key has a space between its words
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:13
@dtonlai i don't know what you're trying to achieve but when you want to use a variable to access an object you use [], object[variable]
Patkaa
@Patkaa
Nov 25 2016 09:14
In the profile lookup challenge
should I in a way or another
dtonlai
@dtonlai
Nov 25 2016 09:14
@ashkrish07 That totally worked, THANKS!
CamperBot
@camperbot
Nov 25 2016 09:14
dtonlai sends brownie points to @ashkrish07 :sparkles: :thumbsup: :sparkles:
:warning: dtonlai already gave ashkrish07 points
Patkaa
@Patkaa
Nov 25 2016 09:14
use for or while in Profile Lookup?
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:14
@ghulamshabir yeah, am aware just responding to what he was trying to do
Jefferson
@jeffersonnnn
Nov 25 2016 09:14
Hi all, i am at the find the longest word in the string challenge. Can i get any tips, please?
Stuart
Nov 25 2016 09:14
Hey guys, im stuck on the "Seek and Destroy" JS Challenge, any one help?
function destroyer(arr) {
for(var i = 0; i < arr.length; i++){
for(var t = 1; t < arguments.length; t++){
if(arguments[t] == arr[i]){
arr.splice(i, 1);
}
}
}
return arr;
}
Ghulam Shabir
@ghulamshabir
Nov 25 2016 09:15
@Lumexralph :+1:
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:15
@jeffersonnnn what have you been able to do?
@ghulamshabir yes bro
@Patkaa they both do same thing, just that their constructs are a lil bit different
dtonlai
@dtonlai
Nov 25 2016 09:16
@Lumexralph @ghulamshabir @ashkrish07 Thanks for the help!
CamperBot
@camperbot
Nov 25 2016 09:16
dtonlai sends brownie points to @lumexralph and @ghulamshabir and @ashkrish07 :sparkles: :thumbsup: :sparkles:
:warning: dtonlai already gave ashkrish07 points
:star2: 1134 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:16
@dtonlai :+1:
Patkaa
@Patkaa
Nov 25 2016 09:16
@Lumexralph Yes, but should I use them in that challenge? For me, the thing that makes sense is to use if statements
Jefferson
@jeffersonnnn
Nov 25 2016 09:16
@Lumexralph nothing actually. I am staring at the challenge unable to understand a thing.
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:17
Tom Cruise
@dongCode
Nov 25 2016 09:17
Selecting from many options with Switch Statements
how to do?
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:17
@Patkaa do you have an array?
Ghulam Shabir
@ghulamshabir
Nov 25 2016 09:17
@Rushmead your first loop should loop over arguments and second loop over arr
Patkaa
@Patkaa
Nov 25 2016 09:18
@Lumexralph Yes i do
Stuart
Nov 25 2016 09:18
function destroyer(arr) {

for(var t = 1; t < arguments.length; t++){
for(var i = 0; i < arr.length; i++){
console.log(arr[i]);
if(arguments[t] == arr[i]){
console.log("Splice");
arr.splice(i, 1);
}
}
}
return arr;
}
So like that.
Patkaa
@Patkaa
Nov 25 2016 09:18
@Lumexralph Array of objects
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:18
@Patkaa then you have to iterate the array, there are so many ways but for or while loop will do just fine
Jefferson
@jeffersonnnn
Nov 25 2016 09:19
@Lumexralph the challenge requires me to return the length of the longest word in a sentence. As a extension of the requirement, i am to return this as a number.
Patkaa
@Patkaa
Nov 25 2016 09:19
@Lumexralph Alright, then I'm completely stuck :D
Tom Cruise
@dongCode
Nov 25 2016 09:19
thank you @Lumexralph
CamperBot
@camperbot
Nov 25 2016 09:19
dongcode sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
Ghulam Shabir
@ghulamshabir
Nov 25 2016 09:19
@Rushmead yes now try i-- in splice
Stuart
Nov 25 2016 09:20
Ah, that works. But why?
Ghulam Shabir
@ghulamshabir
Nov 25 2016 09:20
@Rushmead splice reduces size of arr
Stuart
Nov 25 2016 09:20
ahh right, thanks @ghulamshabir
CamperBot
@camperbot
Nov 25 2016 09:20
rushmead sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1135 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:21
@jeffersonnnn you have to split that string/ sentence into an array, loop through it, check the length of each element in the array, have a variable to keep track of each length if the next element's length is greater update that variable that keeps track of the length and when the loop is done, return the length
Ghulam Shabir
@ghulamshabir
Nov 25 2016 09:21
Patkaa
@Patkaa
Nov 25 2016 09:22
can while loops have arguments such as
while ( contacts.hasOwnProperty(firstName) && contacts.hasOwnProperty(prop)){
return value;
or wait, that has to = true
any way of doing that? or am I totally on the wrong side of the fence now? :D
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:23
@Patkaa yes it will pass provided a true boolean is returned and if you don't change that condition in your loop, you're setting yourself up for an infinite loop,
Patkaa
@Patkaa
Nov 25 2016 09:23
@Lumexralph Ahh I can see that. How can I make it loop once? that return exists it forever
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:23
@Patkaa all you need is just to iterate the array of objects to be able to pick each objects
Patkaa
@Patkaa
Nov 25 2016 09:24
@Lumexralph iterate?
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:25
@Patkaa use the length of the array for your condition and decrement it in your loop
@Patkaa by iterate i mean picking each element of the array as you wanted
Patkaa
@Patkaa
Nov 25 2016 09:26
while ( contacts.hasOwnProperty(firstName) && contacts.hasOwnProperty(prop) < contacts.length)
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:26
@Patkaa or for(var j = 0; j < array of objects.length; j++)
Patkaa
@Patkaa
Nov 25 2016 09:27
can I have a for loop
inside an if statement?
i guess I can, makes sense to be able to do that
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:27
@Patkaa that while loop is wrong, yes you can have branches like if statement or switch in your loop
Patkaa
@Patkaa
Nov 25 2016 09:28
@Lumexralph alright brother, let me try to do something based on what you've told me
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:28
@Patkaa the loop should give you access to the array and you use j or whatever you name it to pick each element
@Patkaa all the best
Patkaa
@Patkaa
Nov 25 2016 09:29
@Lumexralph it needs to return " value "
but there is nothing that is being called value??
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:30
@Patkaa i don't know what you're trying to do, you needed a loop and that I just helped
Aaklii
@Aaklii
Nov 25 2016 09:31

//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 results = false;
len = contacts.length;
for (var i = 0 ; i < len; i++) {

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

if(results === false) {
return "No such contact";
}

}

// Only change code above this line
}

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

Patkaa
@Patkaa
Nov 25 2016 09:32
there are no loops here?
Tom Cruise
@dongCode
Nov 25 2016 09:32
Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"
Johnny
@JohnnyBizzel
Nov 25 2016 09:33
@Patkaa Morning!
Tom Cruise
@dongCode
Nov 25 2016 09:33
what dose it mean?
Patkaa
@Patkaa
Nov 25 2016 09:33
@JohnnyBizzel Hey Johnny, how was yesterday in town? :shipit:
Johnny
@JohnnyBizzel
Nov 25 2016 09:34
@Patkaa I fell asleep and didn't go! :/ I watch the Chess and NFL instead
Patkaa
@Patkaa
Nov 25 2016 09:34
@JohnnyBizzel Oh Johnny oh Johnny..
Johnny
@JohnnyBizzel
Nov 25 2016 09:34
@Patkaa Pittsburgh won! :D
What are you stuck with todaY?
Or are you helping out ;)
Jefferson
@jeffersonnnn
Nov 25 2016 09:35
@Lumexralph Wow. Just wow. Okay then. Thanks.
CamperBot
@camperbot
Nov 25 2016 09:35
jeffersonnnn sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:35
@dongCode create a switch statement, that takes val and use case to test for each and set answer to each
Patkaa
@Patkaa
Nov 25 2016 09:35
@JohnnyBizzel The usual , I'm stuck :D
Johnny
@JohnnyBizzel
Nov 25 2016 09:36
@Patkaa Which challenge?
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:36
@Patkaa @JohnnyBizzel :smile:
Johnny
@JohnnyBizzel
Nov 25 2016 09:37
@Lumexralph Morning. How's it going??
Patkaa
@Patkaa
Nov 25 2016 09:37
Profile Lookup :')
Having a bad headache this morning and not understanding the task is not helping at all :-1:
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:37
@JohnnyBizzel am very well, thank you
CamperBot
@camperbot
Nov 25 2016 09:37
lumexralph sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:37
@JohnnyBizzel you?
Tom Cruise
@dongCode
Nov 25 2016 09:38
switch(val) {
case "alpha":
break;
case "beta":
break;
case "gamma":
break;
case "delta":
break;
}
Johnny
@JohnnyBizzel
Nov 25 2016 09:38
@Lumexralph Just about to have some museli for breakfast :yum:
@Patkaa I've done a JS Fiddle for that one.
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:38
@JohnnyBizzel enjoy lol :smile:
Patkaa
@Patkaa
Nov 25 2016 09:39
@JohnnyBizzel you can PM it and I can have a look at it ! :)
Tom Cruise
@dongCode
Nov 25 2016 09:40
@Lumexralph switch(val) {
case "alpha":
break;
case "beta":
break;
case "gamma":
break;
case "delta":
break;
} Right?
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:41
@dongCode answer should be equal to the corresponding string e.g answer = "alpha"
@dongCode but you've done a good job only for what i noticed
Tom Cruise
@dongCode
Nov 25 2016 09:43
@Lumexralph thank you very much!!
CamperBot
@camperbot
Nov 25 2016 09:43
dongcode sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: dongcode already gave lumexralph points
Tom Cruise
@dongCode
Nov 25 2016 09:43
@Lumexralph switch(val) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
}
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:44
@dongCode yes
Johnny
@JohnnyBizzel
Nov 25 2016 09:45
Edit previous post with (up arrow) :arrow_up: key
@Patkaa I've PM'd you dude
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:45
Tom Cruise
@dongCode
Nov 25 2016 09:47
I'll go to my next challenge ! thank you Happy coding! @JohnnyBizzel @Lumexralph
CamperBot
@camperbot
Nov 25 2016 09:47
dongcode sends brownie points to @johnnybizzel and @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: dongcode already gave lumexralph points
Ogundele Olumide
@Lumexralph
Nov 25 2016 09:48
@dongCode you too
Aaklii
@Aaklii
Nov 25 2016 09:48
Thanks @Patkaa
CamperBot
@camperbot
Nov 25 2016 09:48
aaklii sends brownie points to @patkaa :sparkles: :thumbsup: :sparkles:
Johnny
@JohnnyBizzel
Nov 25 2016 09:49
@dongCode :+1:
Patkaa
@Patkaa
Nov 25 2016 09:50
@Aaklii what did I do? :D
Lux Winter
@LuxWinter
Nov 25 2016 10:09
Hey guys, I need your help real quick. My instruction reads "a should be assigned to b with =", so I set a = b, but it shows the task as failed. Am I misunderstanding something?
darkflikk
@darkflikk
Nov 25 2016 10:09
@LuxWinter Lux?
darkflikk
@darkflikk
Nov 25 2016 10:11
@LuxWinter "a should be assigned to b" bedeutet "a soll b zugewiesen werden". Also ist es b = a
Lux Winter
@LuxWinter
Nov 25 2016 10:12
Huh, dann bekomme ich aber a und b als undefined variables raus o.0
darkflikk
@darkflikk
Nov 25 2016 10:13

Instructions:
Assign the value 7 to variable a. a = 7;

Assign the contents of a to variable b. b = a;

Piotr
@PiotrSzablewski
Nov 25 2016 10:13
Hi all Im working on Roman numeral converter and dont why my code is failing can somebody tell me why?
Lux Winter
@LuxWinter
Nov 25 2016 10:13
I'll try that, @darkflikk - thank you!
CamperBot
@camperbot
Nov 25 2016 10:13
luxwinter sends brownie points to @darkflikk :sparkles: :thumbsup: :sparkles:
darkflikk
@darkflikk
Nov 25 2016 10:13
@LuxWinter Immer gerne :)
Piotr
@PiotrSzablewski
Nov 25 2016 10:14

function convertToRoman(num) {

var result="";

switch (num){
case num>= 1000:
result+="M";
num-=1000 ;
break ;
case num >= 900:
result += "CM";
num-=900;
break;
case num>=500:
result+="D";
num-=500;
break;
case num>=400:
result+="CD";
num-=400;
break;
case num>=100:
result+="C";
num-=100;
break;
case num>=90:
result+="XC";
num-=90;
break;
case num>=50:
result+="L";
num-=50;
break;
case num>=40:
result+="XL";
num-=40;
break;
case num>=10:
result+=10;
num-=10;
break;
case num==9:
result+="IX";
num-=9;
break;
case num>=5:
result+="V";
num-=5;
break;
case num==4:
result+="IV";
num-=4;
break;
case num==3:
result+="III";
num-=3;
break;
case num>=1:
result+=1;
num-=1;
break;

}

return result;
}

Ogundele Olumide
@Lumexralph
Nov 25 2016 10:14
@LuxWinter though we speak english here, am learning german and it's cool to read some from you
Boris Yordanov
@borisyordanov
Nov 25 2016 10:14
<body>
<input id="first"/>
<input id="second"/>
<script type="text/javascript">
var elems = {
length: 0,
Array.prototype.push.call(this, elem);
},
gather: function(id){
}
};
elems.gather("first");
assert(elems.length == 1 && elems[0].nodeType,
"Verify that we have an element in our stash");
elems.gather("second");
assert(elems.length == 2 && elems[1].nodeType,
"Verify the other insertion");
</script>
</body>
CamperBot
@camperbot
Nov 25 2016 10:14
:bulb: to format code use backticks!  more info
Lux Winter
@LuxWinter
Nov 25 2016 10:14
Haha just randomly found another german speaking person! I usually stick to English too ;) @Lumexralph
Ghulam Shabir
@ghulamshabir
Nov 25 2016 10:14
@PiotrSzablewski < > || && operators do not work in switch cases
darkflikk
@darkflikk
Nov 25 2016 10:15
I prefer english over german as well @LuxWinter
But since i saw you were german, i thought it was easier for you to understand
Boris Yordanov
@borisyordanov
Nov 25 2016 10:15
can anyone answer some questions with the code i posted above
darkflikk
@darkflikk
Nov 25 2016 10:15
Boris Yordanov
@borisyordanov
Nov 25 2016 10:15
i don't understand how the length property works
darkflikk
@darkflikk
Nov 25 2016 10:15
@borisyordanov sure
Boris Yordanov
@borisyordanov
Nov 25 2016 10:15
@darkflikk yay!
Lux Winter
@LuxWinter
Nov 25 2016 10:16
Awe thanks, but I have two native tongues - Eng and Ger, so we're good @darkflikk
CamperBot
@camperbot
Nov 25 2016 10:16
luxwinter sends brownie points to @darkflikk :sparkles: :thumbsup: :sparkles:
:warning: luxwinter already gave darkflikk points
darkflikk
@darkflikk
Nov 25 2016 10:16
@borisyordanov the length property just contains a value that represents the length of the array
Piotr
@PiotrSzablewski
Nov 25 2016 10:16
@ghulamshabir thx I feel stupid now ;[
CamperBot
@camperbot
Nov 25 2016 10:16
piotrszablewski sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1136 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
darkflikk
@darkflikk
Nov 25 2016 10:17

@borisyordanov so if you do:

var myArray = [1, 2, 3, 4];

then myArray.length would be 4

Boris Yordanov
@borisyordanov
Nov 25 2016 10:17
@darkflikk i get that part. However when we start and the array is empty, length is 0. Which is fine. However when we add elements to the array how does the length property change
ashkrish07
@ashkrish07
Nov 25 2016 10:17
Hai guys need help with "Title case a sentence"
Ghulam Shabir
@ghulamshabir
Nov 25 2016 10:18
@PiotrSzablewski you can create two arrays, one for romans one for numbers, then use loops over them
darkflikk
@darkflikk
Nov 25 2016 10:18
@borisyordanov lets see
besynerlig
@besynerlig
Nov 25 2016 10:19

what have i done wrong?

function testLogicalOr(val) {
// Only change code below this line

if (val >= 20 || val <= 10) {
return "Outside";
}

// Only change code above this line
return "Inside";
}

// Change this value to test
testLogicalOr(15);

Instructions
Combine the two if statements into one statement which returns "Outside" if val is not between 10 and 20, inclusive. Otherwise, return "Inside".

darkflikk
@darkflikk
Nov 25 2016 10:19
@borisyordanov it's done by the push function you call
Piotr
@PiotrSzablewski
Nov 25 2016 10:19
I know Ghulam ... just wanted to be smarter that Im ....;p
josephinemonica
@josephinemonica
Nov 25 2016 10:20
    <footer style="position: fixed; bottom: 0px; "><h5 class="text-right">
Copyright information</h5></footer>
Boris Yordanov
@borisyordanov
Nov 25 2016 10:20
@besynerlig i think you need to switch 20 with 10 in the if statement
josephinemonica
@josephinemonica
Nov 25 2016 10:20
Can anyone tell me why the code above doesn't align the footer at the center?
Boris Yordanov
@borisyordanov
Nov 25 2016 10:21
@darkflikk how does push do that?
besynerlig
@besynerlig
Nov 25 2016 10:21
@borisyordanov nope, didint change anything :/
josephinemonica
@josephinemonica
Nov 25 2016 10:21
<footer style="position: fixed; bottom: 0px; "><h5 class="text-right">Copyright information</h5></footer>
@ModiRama
Nov 25 2016 10:21
// Setup
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if(collection[id].hasOwnProperty(prop)===false)
{
if(prop == "tracks")
{
collection[id][prop]=[value];
return collection;
}
else
{
collection[id][prop]=value;
return collection;
}
}
else if(value=="")
{
delete collection[id][prop][value];
return collection;
}
else
{
collection[id][prop].push(value);
return collection;
}
}

// Alter values below to test your code
updateRecords(2548, "artist", "");
Boris Yordanov
@borisyordanov
Nov 25 2016 10:21
@besynerlig also should the operator be &&?
josephinemonica
@josephinemonica
Nov 25 2016 10:21
I want the footer to be at the botoom of page,, and at the center
but it's not at the center now
besynerlig
@besynerlig
Nov 25 2016 10:21
nope it tells me to use "||" @borisyordanov
darkflikk
@darkflikk
Nov 25 2016 10:21
@josephinemonica you have a codepen?
josephinemonica
@josephinemonica
Nov 25 2016 10:22
<footer style="position: fixed; bottom: 0px; "><h5 class="text-right">Copyright information</h5></footer>
Boris Yordanov
@borisyordanov
Nov 25 2016 10:22
@besynerlig can you tell me the name of the challenge
besynerlig
@besynerlig
Nov 25 2016 10:22
got it working @borisyordanov i needed to remove the "=". Thanks for trying :)
CamperBot
@camperbot
Nov 25 2016 10:22
besynerlig sends brownie points to @borisyordanov :sparkles: :thumbsup: :sparkles:
josephinemonica
@josephinemonica
Nov 25 2016 10:22
darkflikk
@darkflikk
Nov 25 2016 10:23
@borisyordanov you call Array.prototype.push.call(this, elem);
The function will then add the element to the array and to this.length++
ashkrish07
@ashkrish07
Nov 25 2016 10:23
@ModiRama else if is misplaced change your structure . else if should follow if statement
darkflikk
@darkflikk
Nov 25 2016 10:24
@josephinemonica give the footer a width of 100%
@ModiRama
Nov 25 2016 10:25
@ashkrish07 That's right (y) Thank you ^^
CamperBot
@camperbot
Nov 25 2016 10:25
modirama sends brownie points to @ashkrish07 :sparkles: :thumbsup: :sparkles:
Stefaan Walleghem
@lawfets
Nov 25 2016 10:25
@ModiRama if value is blanck string, you have to remove the whole not just the value
josephinemonica
@josephinemonica
Nov 25 2016 10:25
@darkflikk thanks it solves it.
CamperBot
@camperbot
Nov 25 2016 10:25
josephinemonica sends brownie points to @darkflikk :sparkles: :thumbsup: :sparkles:
josephinemonica
@josephinemonica
Nov 25 2016 10:26
@darkflikk but what did i do wrong?
Boris Yordanov
@borisyordanov
Nov 25 2016 10:27
@darkflikk push returns the updated length property of the array. I did not know that. OK one more questions - in Array.prototype.push.call(this, elem) what does this refer to? The var elems?
josephinemonica
@josephinemonica
Nov 25 2016 10:27
@darkflikk but it doesn't work nicely if I have padding on body
Stefaan Walleghem
@lawfets
Nov 25 2016 10:27
  if(prop == "tracks")
{
collection[id][prop]=[value];
return collection;
Jefferson
@jeffersonnnn
Nov 25 2016 10:28
Hi all, can i get tips on how to check the length of each element in an array?
Stefaan Walleghem
@lawfets
Nov 25 2016 10:28
remove the prop and just use value instead of in brackets
@jeffersonnnn just use element.length
josephinemonica
@josephinemonica
Nov 25 2016 10:29
Stefaan Walleghem
@lawfets
Nov 25 2016 10:29
@jeffersonnnn you can do that with a for loop
@Fayaz274
Nov 25 2016 10:29
exercise workbook for JQuery???
darkflikk
@darkflikk
Nov 25 2016 10:29
@borisyordanov that's almost correct. var elems is the variable that contains the object. this is a reference to that object. So in that case elem and thiswould be the same
@josephinemonica i see
@josephinemonica btw: you should not use those inline styles ;)
Jefferson
@jeffersonnnn
Nov 25 2016 10:30
@lawfets does it mean that when i loop through an array with a for loop mechanism, i automatically check the length of each element in the array?
Brandon
@bd1887
Nov 25 2016 10:31

Hi everyone. I'm trying to dynamically create key:value pairs using variable names. Right now my code looks like this:

var turnCount = 0; //This gets incremented every turn
var curGameState = {r1: [0,0,0], r2: [0,0,0], r3: [0,0,0], c1: [0,0,0], c2: [0,0,0], c3: [0,0,0], d1: [0,0,0], d2: [0,0,0]}; //This changes every turn.
var gameStateStore = {};

gameStateStore[turnCount]=curGameState;

I expect the code to create a new key equal to the turnCount and then save the curGameState as it was at that turn. However, what seems to be happening is it creates a new key equal to turnCount but then updates all of the previous game states to be equal to the current game state.

So what I expect:
1: prevgamestate1
2: prev game state 2
3: current game state

What I get:
1: current game state
2: current game state
3: current game state

Ryan Hikel
@ryanhikel
Nov 25 2016 10:32

Hi can I get some help with javascript mission Introducing Else If Statements

function testElseIf(val) {}
if (val > 10) {
return "Greater than 10";
}
else if (val < 5) {
return "Smaller than 5";
}
else{

return "Between 5 and 10";
}

// Change this value to test
testElseIf(7);

it says I need two else statements still.
Boris Yordanov
@borisyordanov
Nov 25 2016 10:33
@darkflikk this is how i understand it - the Array.prototype.push.call(this, elem) takes elem and ads it to the object(this) contained in the variable. The way i understand is that this is the object we are inserting elem in. How can they be the same thing? Why would we want to push elem in this if they are the same thing?
darkflikk
@darkflikk
Nov 25 2016 10:34
@borisyordanov sry, a little confusion. i was talking amout elems not elem
Boris Yordanov
@borisyordanov
Nov 25 2016 10:34
@darkflikk everything is clear then. You helped me out a lot. Thank you!
CamperBot
@camperbot
Nov 25 2016 10:34
borisyordanov sends brownie points to @darkflikk :sparkles: :thumbsup: :sparkles:
darkflikk
@darkflikk
Nov 25 2016 10:35
@borisyordanov so this is the array itself. ( elems)
Boris Yordanov
@borisyordanov
Nov 25 2016 10:35
@ryanhikel what do you mean by "two else statements still"
darkflikk
@darkflikk
Nov 25 2016 10:35
@josephinemonica ok, ill take another look
ashkrish07
@ashkrish07
Nov 25 2016 10:35
function titleCase(str) {
var arr=[],arr1=[];
var str1='';
arr= str.split(" ");
for(var i=0;i<arr.length;i++)
{
str1 = arr[i].charAt(0).toUpperCase()+arr[i].slice(1).toLowerCase();
arr1.push(str1+" ");
}
var str2 = arr1.join('');
str2='"'+str2;
str2+='"';
return str2;
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Need help with this :worried:
darkflikk
@darkflikk
Nov 25 2016 10:36
@josephinemonica do you need the body padding?
Boris Yordanov
@borisyordanov
Nov 25 2016 10:36
@ryanhikel i think you have a typo - your code should be between the curly brackets after (val) not after them
@ryanhikel Like this:
(val) {
if(val > 10) {
return "10 or Bigger";
}

else if(val < 5) {
return "Smaller than 5";
}

else {
return "Between 5 and 10";
}
}
Ryan Hikel
@ryanhikel
Nov 25 2016 10:37
@borisyordanov thank you I got it
CamperBot
@camperbot
Nov 25 2016 10:37
ryanhikel sends brownie points to @borisyordanov :sparkles: :thumbsup: :sparkles:
Boris Yordanov
@borisyordanov
Nov 25 2016 10:37
@ashkrish07 how can we help
@ashkrish07 first make all the letters lowercase, then use replace() to change the first letter to uppercase
darkflikk
@darkflikk
Nov 25 2016 10:40
@josephinemonica you still there?
Jefferson
@jeffersonnnn
Nov 25 2016 10:41
Hi all, i have a question please. Is it possible that while executing a for loop for the purpose of looping through an array, i automatically check the lenght of each element in the array? Answers please!
Boris Yordanov
@borisyordanov
Nov 25 2016 10:42
@ashkrish07 another tip - after you make everything lowercase, split every word into a separate array, then replace each string's first letter with the same letter but capital.
darkflikk
@darkflikk
Nov 25 2016 10:42
@jeffersonnnn not sure what exactly you want, but almost everything is possible ;)
@josephinemonica ???
Johnny
@JohnnyBizzel
Nov 25 2016 10:44
@jeffersonnnn If it is a string you're checking, you can use the .length function
Thomas Hicks
@forbajato
Nov 25 2016 10:44
@jeffersonnnn The length operator works on strings, arrays, maybe other things.
darkflikk
@darkflikk
Nov 25 2016 10:47
@forbajato it works on anything. you just have to implement the logic for it to work ;)
Thomas Hicks
@forbajato
Nov 25 2016 10:49
Does javascript have type conversion? Like if I have an integer, 12345, and want its length, how would I accomplish that?
Ghulam Shabir
@ghulamshabir
Nov 25 2016 10:49
@forbajato @JohnnyBizzel .length is neither function nor operator, its property (this.length = 0), when the items are added, this property is incremented and also decrement when items removed for example push increments length of arrays and shift decrements it
Johnny
@JohnnyBizzel
Nov 25 2016 10:50
@ghulamshabir THanks buddy
CamperBot
@camperbot
Nov 25 2016 10:50
johnnybizzel sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1137 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Thomas Hicks
@forbajato
Nov 25 2016 10:50
@ghulamshabir Thanks, getting the vocabulary correct is part of the learning process!
CamperBot
@camperbot
Nov 25 2016 10:50
forbajato sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1138 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Nov 25 2016 10:51
:+1:
Johnny
@JohnnyBizzel
Nov 25 2016 10:52
@forbajato JS is not strict on data types. You could do this
var num = 124542;
var len = num.toString().length;
Subramanya Chakravarthy
@chakrihacker
Nov 25 2016 10:53
hi
@camperbot sum all numbers in a range
help sum all numbers in a range
CamperBot
@camperbot
Nov 25 2016 10:54
no wiki entry for: sum all numbers in a range
Subramanya Chakravarthy
@chakrihacker
Nov 25 2016 10:54
Thomas Hicks
@forbajato
Nov 25 2016 10:54
@JohnnyBizzel I would have done something very similar in python but thought maybe JS had a unique approach.
Johnny
@JohnnyBizzel
Nov 25 2016 10:55
@forbajato How would you do it in Python?
Subramanya Chakravarthy
@chakrihacker
Nov 25 2016 10:56
var sum = 0;
var temp;
function sumAll(arr) {
console.log(arr);
if(arr[0] >= arr[1] ){
temp = arr[0];
while (temp > arr[1]){
sum += temp;
temp--;
}
} else{
temp = arr[1];
while (temp >= arr[0]) {
sum += temp;
temp--;
}
}
return sum;
}

sumAll([5, 10]);
help
Philipp Scholz
@philipp32
Nov 25 2016 10:57
@chakrihacker its arr[0].length
You can't simply compare an array to a number value. It has to be its length
Subramanya Chakravarthy
@chakrihacker
Nov 25 2016 10:58
TsoTne LomiDze
@sertso
Nov 25 2016 10:59
hello people, i need your help.
i am on the javascript Stand in Line
i cant understand what to do, can anyone help me?
Thomas Hicks
@forbajato
Nov 25 2016 11:00
@JohnnyBizzel say you have an variable (integ) of type integer, value is 1234 and want its length: len(str(integ))
kirbyedy
@kirbyedy
Nov 25 2016 11:00
@sertso try to use push() and shift() methods
TsoTne LomiDze
@sertso
Nov 25 2016 11:00
ok i will try
Thanks @kirbyedy
CamperBot
@camperbot
Nov 25 2016 11:00
sertso sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1583 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
Johnny
@JohnnyBizzel
Nov 25 2016 11:01
@forbajato Nice one thanks :+1:
CamperBot
@camperbot
Nov 25 2016 11:01
johnnybizzel sends brownie points to @forbajato :sparkles: :thumbsup: :sparkles:
Philipp Scholz
@philipp32
Nov 25 2016 11:03

function mutation(arr) {
var arr1 = [arr[0].toLowerCase()];
var arr2 = [arr[1].toLowerCase()];
return arr1.indexOf(arr2);

}

mutation(["hello", "hey"]);
Why does the return statement only return -1 (false)?
Stephen James
@sjames1958gm
Nov 25 2016 11:08
You are looking for an array inside of another array. @philipp32
@philipp32 The challenge is to return true/false if every letter of arr[1] is in arr[0] individually, not as a whole string
TsoTne LomiDze
@sertso
Nov 25 2016 11:09

var code = "formatted";
function nextInLine(arr, item) {
arr = testArr;
arr.shift(item);
arr.push(item);
return arr[item];
}

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

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

@kirbyedy here is my code, but it's not workd
Blauelf
@Blauelf
Nov 25 2016 11:09
@philipp32 Test each letter of the second string, whether it is contained in the first string. If any letter is missing, return false, if all are found, return true.
@sertso shift does not take arguments, it removes and returns the first element. Also, don't use testArr, work only with arr and item. And push first, then shift.
TsoTne LomiDze
@sertso
Nov 25 2016 11:11
ok i will try
Blauelf
@Blauelf
Nov 25 2016 11:12
@sertso While one is rarely interested in the return value of push, you should not ignore the return value of shift, but return it (as it's the removed first element)
Stephen James
@sjames1958gm
Nov 25 2016 11:14
@sertso Make sure you get the order of operations correct Add the number to the end of the array, then remove the first element of array.
DavidR
@davidrinconv
Nov 25 2016 11:17
hey guys I just finished my calculator please let me know what you think http://codepen.io/davidrv/pen/XNKpNJ
atogz
@atogz
Nov 25 2016 11:17
guys i have such a sample code (Rock Paper Scissors game). What i want to achieve is to store number of wins by player and by computer. After value reaches 10, display an alert. Only achieved to rise var value by 1, but when i start new script, the value resets
the code

var computerWinsCount = 0;
var playerWinsCount = 0;

function getUserChoice() {
var userInput = prompt('Выбери камень, ножницы или бумагу');
userInput = userInput.toLowerCase();
if(userInput === 'камень' || userInput === 'бумага' || userInput === 'ножницы' || userInput === 'бомба') {
return userInput;
}
else {
console.log('Ошибка! Выбери камень, ножницы или бумагу!');
}
}

function getComputerChoice() {
var randomNumber = Math.floor(Math.random() *3);
if(randomNumber === 1) {
return 'камень';
}

else if(randomNumber === 2) {
return 'бумага';
}

else {
return 'ножницы';

}
}

function determineWinner (userChoice, computerChoice) {
if(userChoice === computerChoice) {
return 'Ничья!';
}

if(userChoice === 'камень') {
if(computerChoice === 'ножницы') {
playerWinsCount = playerWinsCount + 1;
return 'Вы выиграли!';

}
else {
if(computerChoice === 'бумага') {

computerWinsCount = computerWinsCount + 1;
return 'Компьютер выиграл!'

}
}

}

if(userChoice === 'бумага') {
if(computerChoice === 'ножницы') {
computerWinsCount = computerWinsCount + 1;
return 'Компьютер выиграл!';
}
else {
if(computerChoice === 'камень') {
playerWinsCount = playerWinsCount + 1;
return 'Вы выиграли!';
}
}
}
if(userChoice === 'ножницы') {
if(computerChoice === 'камень') {
computerWinsCount = computerWinsCount + 1;
return 'Компьютер выиграл!';
}
else {
if(computerChoice === 'бумага') {
playerWinsCount = playerWinsCount + 1;
return 'Вы выиграли!';
}
}
}

  if(userChoice === 'бомба') {
if(computerChoice === 'камень' || computerChoice === 'ножницы' || computerChoice === 'бумага') {
playerWinsCount = playerWinsCount + 1;
return 'Вы выиграли!';

}
}

}

function playGame() {
var userChoice = getUserChoice();
var computerChoice = getComputerChoice();
console.log('Вы выбрали' + ' ' + userChoice);
console.log('Компьютер выбрал' + ' ' + computerChoice);
console.log(' ');
console.log(determineWinner(userChoice, computerChoice));
console.log(playerWinsCount, computerWinsCount);
}

playGame();

anyone able to point me out how to do it?
sorry for pasting the code, meant to give a link
Sai Srinivas
@SaiSrnvs
Nov 25 2016 11:19
Hi guys , please help me out i am stuck in this java script challenge - Word Blanks
Stephen James
@sjames1958gm
Nov 25 2016 11:19
@atogz Where are you running this code? Browser?
@SaiSrnvs What have you written?
atogz
@atogz
Nov 25 2016 11:20
@sjames1958gm using repl.it at the moment, so yea, browser i guess
Nico Vergauwen
@kyriediculous
Nov 25 2016 11:21
Can anyone tell me why my ajax request is returning a syntax error in the console?
Stephen James
@sjames1958gm
Nov 25 2016 11:21
@atogz I am not sure how repl.it works, but wouldn't you just want to loop in your playGame() function until the desired score is reached.
Sai Srinivas
@SaiSrnvs
Nov 25 2016 11:21
@atogz sir actualy i did not understand the question properly
TsoTne LomiDze
@sertso
Nov 25 2016 11:23
i will kill myself

function nextInLine(arr, item) {
arr.push(item);
arr.shift();
return arr.push(item);
}
Codemzy
@codemzy
Nov 25 2016 11:23
@kyriediculous remove this line dataType:"jsonp",
TsoTne LomiDze
@sertso
Nov 25 2016 11:23
function nextInLine(arr, item) {
arr.push(item);
arr.shift();
return arr.push(item);
}
Nico Vergauwen
@kyriediculous
Nov 25 2016 11:23
then I will get a CORS error due to codepen
Stephen James
@sjames1958gm
Nov 25 2016 11:23
@sertso return the value from the arr.shift() - why add another push?
Nico Vergauwen
@kyriediculous
Nov 25 2016 11:23
@codemzy
Codemzy
@codemzy
Nov 25 2016 11:24
@kyriediculous I removed it and just got the response, you already have format jsonp in your request
atogz
@atogz
Nov 25 2016 11:24
@sjames1958gm sounds fair, will try that. thanks :)
CamperBot
@camperbot
Nov 25 2016 11:24
:star2: 4516 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
atogz sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
TsoTne LomiDze
@sertso
Nov 25 2016 11:25
@sjames1958gm yeaa but its not work.
Stephen James
@sjames1958gm
Nov 25 2016 11:25
@sertso What doesn't work?
Nico Vergauwen
@kyriediculous
Nov 25 2016 11:25
@codemzy are you running it on something else than codepen perhaps?
Codemzy
@codemzy
Nov 25 2016 11:25
@kyriediculous or change it to format:"jsonp", that also works.. no I am in codepen, in your pen
Nico Vergauwen
@kyriediculous
Nov 25 2016 11:26
I'm still getting
MLHttpRequest cannot load http://m.mlb.com/lookup/json/named.sport_hitting_game_log_composed.bam?game…%279%27&sit_code=%2710%27&sit_code=%2711%27&sit_code=%2712%27&format=jsonp. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.
Codemzy
@codemzy
Nov 25 2016 11:27
@kyriediculous works for me in Chrome... what browser are you in?
Stephen James
@sjames1958gm
Nov 25 2016 11:27
@sertso
function nextInLine(arr, item) {
arr.push(item);
return arr.shift();  // Change this line
}
Nico Vergauwen
@kyriediculous
Nov 25 2016 11:27
@codemzy chrome as well
TsoTne LomiDze
@sertso
Nov 25 2016 11:28
@sjames1958gm it's working. Thanks
CamperBot
@camperbot
Nov 25 2016 11:28
sertso sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4517 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 25 2016 11:28
@sertso Just push and shift - return the value from the shift not add another push.
TsoTne LomiDze
@sertso
Nov 25 2016 11:28
Thanks @sjames1958gm
CamperBot
@camperbot
Nov 25 2016 11:28
sertso sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: sertso already gave sjames1958gm points
TsoTne LomiDze
@sertso
Nov 25 2016 11:28
and sorry for a lot of speach :*
Codemzy
@codemzy
Nov 25 2016 11:28
@kyriediculous strange.. have you changed the code though I just refreshed you pen and its the same
AlCon1989
@AlCon1989
Nov 25 2016 11:29
myStr should have encoded text with the proper escape sequences and no spacing.
myStr should have one newline character \n
myStr should have one carriage return character \r
myStr should have two correctly escaped backslash characters \
any help pleaase
Nico Vergauwen
@kyriediculous
Nov 25 2016 11:30
@codemzy yeah I've tried it but getting the CORS error , I'll try to run it on somethign else than codepen. It's been giving me issues with ajax requests alot.
Blauelf
@Blauelf
Nov 25 2016 11:30
@AlCon1989 Take the string "FirstLinenewline backslashSecondLinebackslash carriage-returnThirdLine" and replace all the special characters by their escape sequences. And don't put any spaces in that string, if there are any, they were not intended.
Stephen James
@sjames1958gm
Nov 25 2016 11:30
@SaiSrnvs The function will get four words in the variables myNoun, etc. You need to combine those with other strings to form a sentence
assigning to the variable provided.
@kyriediculous Do you have a link to the API reference for mlb?
AlCon1989
@AlCon1989
Nov 25 2016 11:31
var myStr ="First line\nSecondLine\rThirdLine"; // Change this line
Stephen James
@sjames1958gm
Nov 25 2016 11:31
@kyriediculous It looks like it is sending json and not jsonp back
AlCon1989
@AlCon1989
Nov 25 2016 11:32
@Blauelf var myStr ="First line\nSecondLine\rThirdLine"; // Change this line
Codemzy
@codemzy
Nov 25 2016 11:32
@kyriediculous try dataType:"json" that worked for me also
Blauelf
@Blauelf
Nov 25 2016 11:32
@AlCon1989 Use backticks around inline code for chat: var myStr ="First line\nSecondLine\rThirdLine"; // Change this line
It's FirstLine, not First line, and you forgot the escaped backslashes.
Nico Vergauwen
@kyriediculous
Nov 25 2016 11:32
@sjames1958gm there is no official public API and I'm using jsonp to avoid the XMLHTTPrequest error, it's the only workaround I know.
Sai Srinivas
@SaiSrnvs
Nov 25 2016 11:33
Stephen James
@sjames1958gm
Nov 25 2016 11:34
@SaiSrnvs It is kind of a game where you are have a sentence with blanks spaces where you fill in the spaces (with nouns, verbs, etc) to make humorous sentences
AlCon1989
@AlCon1989
Nov 25 2016 11:34
@Blauelf where do the escaped backslashes go ?
Blauelf
@Blauelf
Nov 25 2016 11:34
@SaiSrnvs Madlib is putting words in a sentence which has a blank where for example a noun should be. As the sentence and the words put in are not exactly related, this is often funny.
Codemzy
@codemzy
Nov 25 2016 11:34
@kyriediculous what happens if you change dataType to json for you?
Blauelf
@Blauelf
Nov 25 2016 11:35
@AlCon1989 Around SecondLine there's a backslash on each side.
Stephen James
@sjames1958gm
Nov 25 2016 11:35
@kyriediculous @codemzy Yeah, I just dropped the p from dataType: "jsonp" and it worked for me as well
Nico Vergauwen
@kyriediculous
Nov 25 2016 11:36
@codemzy I get a CORS error if I drop it "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access."
Codemzy
@codemzy
Nov 25 2016 11:37
@kyriediculous thats odd not sure why you would get that error when it works for me and @sjames1958gm :confounded:
Nico Vergauwen
@kyriediculous
Nov 25 2016 11:38
I've had issues with codepen and my weatherApp as well, strange things.
Codemzy
@codemzy
Nov 25 2016 11:39
the joys of coding lol
Emre Çağatay KÖSE
@emrecgty
Nov 25 2016 11:39

I'm having trouble with golf code in js. Can anyone tell me what's wrong with this code?

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 {
return "Go Home!";
}
// Only change code above this line
}

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

@ModiRama
Nov 25 2016 11:40

// Setup
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if(value !=="")
{
if(collection[id].hasOwnProperty(prop)===false)
{
if(prop == "tracks")
{
collection[id][prop]=[value];
return collection;
}
else
{
collection[id][prop]=value;
return collection;
}
}
else
{
collection[id][prop].push(value);
return collection;
}
}
else
delete collection[id][prop];
return collection;
}

// Alter values below to test your code
updateRecords(2548, "artist", "");
solved it ^_^
heroiczero
@heroiczero
Nov 25 2016 11:41
@emrecgty dont you not have to return strokes with the code and is par a global variable?
François-Xavier Bonnefont
@fx1312
Nov 25 2016 11:43
They say palindrome("0_0 (: /-\ :) 0-0") should return true. This not a palindrome?! / and \ are different characters, aren't they?
Stephen James
@sjames1958gm
Nov 25 2016 11:43
@fx1312 You are supposed to remove all non alphanumeric
@emrecgty Single = is assignment not comparison
Brandon
@bd1887
Nov 25 2016 11:45

@bd1887
Hi everyone. I'm trying to dynamically create key:value pairs using variable names. Right now my code looks like this:

var turnCount = 0; //This gets incremented every turn
var curGameState = {r1: [0,0,0], r2: [0,0,0], r3: [0,0,0], c1: [0,0,0], c2: [0,0,0], c3: [0,0,0], d1: [0,0,0], d2: [0,0,0]}; //This changes every turn.
var gameStateStore = {};

gameStateStore[turnCount]=curGameState;

I expect the code to create a new key equal to the turnCount and then save the curGameState as it was at that turn. However, what seems to be happening is it creates a new key equal to turnCount but then updates all of the previous game states to be equal to the current game state.
So what I expect:
1: prevgamestate1
2: prev game state 2
3: current game state

What I get:
1: current game state
2: current game state
3: current game state

Boris Yordanov
@borisyordanov
Nov 25 2016 11:45
function smallest(array){
return Math.min.apply(Math, array);
}
Can anyone explain what is the purpose of the Math in the brackets after apply
Emre Çağatay KÖSE
@emrecgty
Nov 25 2016 11:46
@sjames1958gm thanks that solved it :)
CamperBot
@camperbot
Nov 25 2016 11:46
emrecgty sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4518 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Patkaa
@Patkaa
Nov 25 2016 11:46
Wann begann Sie mit Turn, Herr Keup?
Wie war das DDR?
Wie viele Medalien hast du in deinem Leben gewonnen?

Wie alt ist die Gebaude?
Gibt es viele Religionen in Düsseldorf, oder sind meisten Christlich?
Können Sie etwas spännand über die Synagoge erzählen?

Wissen Sie etwas über die Norwegische Schulsystem?
Wie viele Leute studieren hier?
Wie alt ist die Gymnasium alt?
Was kann Mann hier studieren?

Haben sie viele Hausaufgaben?
Was passiert, wenn Mann nach die Schule nicht kommt?
Welche Fächer haben Sie?

Wie viele Menschen haben hier gearbeidet?
Wie alt ist dieser Museum?
Wie viele Touristen kommen hier jedes Jahre?
woopsie
wrong :P
Miguel Maestre
@kmaestre
Nov 25 2016 11:47
they say "palindrome("1 eye for of 1 eye.") should return false. ". but after removing both "1", it turns into "eyeforofeye"...that is a palindrome, am i wrong?
Patkaa
@Patkaa
Nov 25 2016 11:47
" Range Error : maximum call stack size exceeded " . What's that?
Stephen James
@sjames1958gm
Nov 25 2016 11:47
@borisyordanov The first parameter to apply is The value of this provided for the call to fun. in this case min doesn't care about the this value
You could put anything there.
Patkaa
@Patkaa
Nov 25 2016 11:47
for (i=0; i < contacts.length; i++)
if ( lookUpProfile(firstName) == firstName && contacts.hasOwnProperty(prop)) {
return contacts[i][prop];
Stephen James
@sjames1958gm
Nov 25 2016 11:48
@Patkaa Likely you are recursing without stopping (calling the function on itself)
@kmaestre Don't remove numbers, per instructions
Patkaa
@Patkaa
Nov 25 2016 11:48
@sjames1958gm I don't understand
Stephen James
@sjames1958gm
Nov 25 2016 11:48
@Patkaa You are calling the function again, you should be using contacts[i].firstName not calling the function again
Patkaa
@Patkaa
Nov 25 2016 11:48
@sjames1958gm ahh!
Stephen James
@sjames1958gm
Nov 25 2016 11:49
@Patkaa Also, don't test has own property on the array
Miguel Maestre
@kmaestre
Nov 25 2016 11:49
Wow. XD thanks @sjames1958gm
CamperBot
@camperbot
Nov 25 2016 11:49
kmaestre sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4519 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
heroiczero
@heroiczero
Nov 25 2016 11:49
@kmaestre isnt that supposed to return false in the instruction
Patkaa
@Patkaa
Nov 25 2016 11:49
@sjames1958gm then how should I see if it has an own property?
Stephen James
@sjames1958gm
Nov 25 2016 11:50
@Patkaa use i since you want to test the contact, not the array
Jack Lyons
@JackEdwardLyons
Nov 25 2016 11:50
hey guys, im working on the AI for my Tic Tac Toe, currently I'm just trying to get the computer to mark a "random" tile... It works, but the index of that tile is not being logged, and therefore my "check winner" function isn't being correctly executed... could anyone help me out? Thank you!!!
http://codepen.io/JackEdwardLyons/pen/WGvrEd?editors=0110
Boris Yordanov
@borisyordanov
Nov 25 2016 11:51
@sjames1958gm so it doesn't do anything, but you can just leave it empty, right?
Patkaa
@Patkaa
Nov 25 2016 11:52
@sjames1958gm
for (i=0; i < contacts.length; i++)
if ( contacts[i].firstName == firstName && contacts[i].prop == prop) {
return contacts[i][prop];
that's wrong too :S
Stephen James
@sjames1958gm
Nov 25 2016 11:52
@bd1887 When you put curGameState into the array - you are putting a reference to the object, the same object every time.
Maybe use Object.assign to create a copy when saving.
@borisyordanov Well you could put null there, but you have to have something
@Patkaa contacts[i].prop == prop well this is wrong
Boris Yordanov
@borisyordanov
Nov 25 2016 11:54
@sjames1958gm thank you
CamperBot
@camperbot
Nov 25 2016 11:54
borisyordanov sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4520 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Patkaa
@Patkaa
Nov 25 2016 11:54
@sjames1958gm contacts[i][prop] == prop)
orghh getting frustrated
really only have about 40% understanding of what I'm doing
Stephen James
@sjames1958gm
Nov 25 2016 11:55
@Patkaa Why would the property be equal to the property name ?
What are you trying to test there
darkflikk
@darkflikk
Nov 25 2016 11:55
@JackEdwardLyons Where is the AI?
Patkaa
@Patkaa
Nov 25 2016 11:56
The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.
Jan Babinec
@JohnConstantin
Nov 25 2016 11:57
Hi guys
Patkaa
@Patkaa
Nov 25 2016 11:57
I though .hasOwnProperty would be appropriate here
Jan Babinec
@JohnConstantin
Nov 25 2016 11:57
I need help i try JavaScript and I dont understand propertly how to escape in this situation.
FirstLine
\SecondLine\
ThirdLine
var myStr = "FirstLine\n\SecondLine\ThirdLine"

console.log() must return :

FirstLine
\SecondLine\
ThirdLine

darkflikk
@darkflikk
Nov 25 2016 11:58
@JackEdwardLyons before you work on the "AI" as you call it, you should build a working game
heroiczero
@heroiczero
Nov 25 2016 11:59
@JohnConstantin you need a return ithink
Patkaa
@Patkaa
Nov 25 2016 11:59
@JohnConstantin How does your code look like till now?
Brandon
@bd1887
Nov 25 2016 11:59
@sjames1958gm Ok, cool, thanks. I'll give that a try. I thought that might be the problem, but then I didn't understand why it would still remember that the previous turns existed but not the previous game states.
CamperBot
@camperbot
Nov 25 2016 11:59
bd1887 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4521 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Patkaa
@Patkaa
Nov 25 2016 11:59
@JohnConstantin you only need to change the variable
Jan Babinec
@JohnConstantin
Nov 25 2016 11:59
@bd1887
var myStr = "Firstline '\n\SecondLine\' \rThirtLine";// Change this line
console.log(myStr);
Stephen James
@sjames1958gm
Nov 25 2016 12:00
@JohnConstantin 1) make sure the words are correct ThirtLine should be ThirdLine
remove the extra ' and all spaces
@Patkaa Yes hasOwnProperty is a good choice
Jan Babinec
@JohnConstantin
Nov 25 2016 12:03

my code is
var myStr = 'Firstline \r\\SecondLine\\ \n\ThirdLine';// Change this line

console.log(myStr);

and i must complete last rule and it it "myStr should have encoded text with the proper escape sequences and no spacing."
(sorry for my english)
Stephen James
@sjames1958gm
Nov 25 2016 12:05
@JohnConstantin no spacing means remove all spaces (also there is a \ before the T in ThirdLine?)
heroiczero
@heroiczero
Nov 25 2016 12:06
@JohnConstantin no spacing you have two spaces
Jan Babinec
@JohnConstantin
Nov 25 2016 12:07
now i have var myStr = 'Firstline\n\SecondLine\\r\ThirdLine';// Change this line
console.log(myStr);
and its return Firstline
\SecondLine\
ThirdLine
Jorn
@jornvw
Nov 25 2016 12:08
function destroyer(arr) {
var newArray = [];

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
ive been struggling for a while with this problem
how do i access 2 ,3 if only one parameter is defined
arr = [1,2,3,1,2,3]
but not the other outstanding 2, 3
Gniewoszu
@Gniewoszu
Nov 25 2016 12:09
@Patkaa if(contacts[i].firstName === firstName)
Stephen James
@sjames1958gm
Nov 25 2016 12:09
@jornvw The arguments object (link provide in instructions) holds all the parameters, not just the named ones
Jorn
@jornvw
Nov 25 2016 12:12
Thank you @sjames1958gm . Should've read that in more detail then.
CamperBot
@camperbot
Nov 25 2016 12:12
jornvw sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4522 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 25 2016 12:12
@jornvw :+1: Good luck
Ashan Mohammed
@AshanMohammed
Nov 25 2016 12:13
@AshanMohammed
Hello Guys! How do i create a shopping cart icon in the top right corner in every page of my eCommerce site with a counter that is increased every time the user add an item to the cart? Anyone please!
Gniewoszu
@Gniewoszu
Nov 25 2016 12:20
@AshanMohammed maybe but maybe. use CSS to position icon, with JS make some object that store all items added to shopping cart and display number of items in object
Ashan Mohammed
@AshanMohammed
Nov 25 2016 12:24
@Gniewoszu The problem i am facing is i placed the shopping cart icon in my page using bootstrap glyphicon and i placed the counter on top of it . When i resize the page both of them collapse and shows separately. Is there anything i can do to keep both shopping cart icon and counter together when i resize the page
Gniewoszu
@Gniewoszu
Nov 25 2016 12:26
@AshanMohammed code ?? or codepen ??
Ashan Mohammed
@AshanMohammed
Nov 25 2016 12:26
@Gniewoszu code!!
Yerrapotu Manojkiran
@nani554
Nov 25 2016 12:28
guys i should use ifelse stmt right?
Gniewoszu
@Gniewoszu
Nov 25 2016 12:28
@AshanMohammed so paste code?
@nani554 yes
Yerrapotu Manojkiran
@nani554
Nov 25 2016 12:29
ok darling,let me check
Ashan Mohammed
@AshanMohammed
Nov 25 2016 12:30
@Gniewoszu
<a href="#">
<span class="glyphicon glyphicon-shopping-cart navbar-right" id="shoppingcart"></span>
<div class="navbar-right" id="shoppingcartcount">0</div>
Mohamed Gamal
@Jimy2010
Nov 25 2016 12:31

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i=0; i<multiplyAll.lenght;i++){
for (var j=0; j<multiplyAll[i].length;j++){
product *=multiplyAll([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]]);
whats wrong here ?
Stephen James
@sjames1958gm
Nov 25 2016 12:32
@Jimy2010 You are calling the function again, not accessing the array in the middle there.
look at the sample code to see how to access the array value
@Jimy2010 Also your for loops are using the function name and not the array name
Ghulam Shabir
@ghulamshabir
Nov 25 2016 12:32
@Jimy2010 multiplyAll([i][j]); is it how you access array elements ?
Ashan Mohammed
@AshanMohammed
Nov 25 2016 12:34
@Jimy2010 Your using the function name instead of array name and the way your accessing the array is wrong. Re-check the sample code
Mohamed Gamal
@Jimy2010
Nov 25 2016 12:36


function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i=0; i<arr.lenght;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]]);
Blauelf
@Blauelf
Nov 25 2016 12:36
@Jimy2010 Typo: arr.length, not arr.lenght
Mohamed Gamal
@Jimy2010
Nov 25 2016 12:36
@Blauelf hahaa yeah :D
@Blauelf @AshanMohammed @ghulamshabir @sjames1958gm Thanks :D
CamperBot
@camperbot
Nov 25 2016 12:36
jimy2010 sends brownie points to @blauelf and @ashanmohammed and @ghulamshabir and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1139 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
:star2: 4523 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 3039 | @blauelf |http://www.freecodecamp.com/blauelf
Stephen James
@sjames1958gm
Nov 25 2016 12:38
@Jimy2010 :+1:
@omeizahanif
Nov 25 2016 12:38
hi people!
@Gaben14
Nov 25 2016 12:38

Hello, could somebody please help me in the Profile Lookup challenge? I can not get my first if to work


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

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

  //console.log(contacts[i].firstName);
console.log(contacts[i][prop]);
if(contacts[i].firstName === firstName && contacts[i][prop] === prop){
//console.log("Test");
return contacts[i][prop];
}
else if(contacts[i].firstName != firstName){
return "No such contact";
}
else if(contacts[i][prop] != prop){
return "No such property";
}

}
// Only change code above this line
}

Stephen James
@sjames1958gm
Nov 25 2016 12:39
@Gaben14 contacts[i][prop] === prop this is testing that the property name is the same as the property value?
perhaps using .hasOwnProperty is a better choice
Gniewoszu
@Gniewoszu
Nov 25 2016 12:39
@AshanMohammed change div to span or in css add to id shoppingcartcount display:inline
Blauelf
@Blauelf
Nov 25 2016 12:40
@Gaben14 Use hasOwnProperty like introduced in Testing Objects for Properties. And don't return "No such contact" on the first name mismatch, you know that only after you had all name mismatches. Best to return that after the loop.
@Gaben14
Nov 25 2016 12:41
@Blauelf @sjames1958gm thanks, I will test it.
CamperBot
@camperbot
Nov 25 2016 12:41
gaben14 sends brownie points to @blauelf and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4524 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 3040 | @blauelf |http://www.freecodecamp.com/blauelf
Diego Mayer
@Chrono79
Nov 25 2016 12:41
@Blauelf @sjames1958gm and anyone else, has any of you used Ionic for app developing?
Stephen James
@sjames1958gm
Nov 25 2016 12:42
@Chrono79 Not me
Nico Vergauwen
@kyriediculous
Nov 25 2016 12:42
Native apps > Ionic or Cordova but it will do the job
theremdim
@theremdim
Nov 25 2016 12:43
One question I've consistently run up against I can demonstrate in the following codepen; how would I create a new nav element from something on a page? Use a click function to append the list? But then what would generate a proper new href link? Thanks in advance! http://codepen.io/Shaz3e/pen/imHyE
Blauelf
@Blauelf
Nov 25 2016 12:43
Ionic, Electron, everything seems so charged these days :P
Diego Mayer
@Chrono79
Nov 25 2016 12:44
@kyriediculous I know, but you have to develop in different languages that way, and with Ionic, it's one for all
Nico Vergauwen
@kyriediculous
Nov 25 2016 12:44
java and Swift
Ashan Mohammed
@AshanMohammed
Nov 25 2016 12:45
@Gniewoszu Perfect! Done it. added the counter number to span and it looks good now.
CamperBot
@camperbot
Nov 25 2016 12:45
ashanmohammed sends brownie points to @gniewoszu :sparkles: :thumbsup: :sparkles:
Diego Mayer
@Chrono79
Nov 25 2016 12:45
@kyriediculous apart that you need a Mac (almost mandatory) to develop for iOS
Blauelf
@Blauelf
Nov 25 2016 12:48
@Chrono79 There are people renting macs in the cloud, these come with xcode and other developer tools preinstalled, and VNC access. As ugly as it can get.
Yerrapotu Manojkiran
@nani554
Nov 25 2016 12:48
guys i have a good question
Blauelf
@Blauelf
Nov 25 2016 12:48
@nani554 Then don't let us wait for it.
Yerrapotu Manojkiran
@nani554
Nov 25 2016 12:48
whenever i click on freecodecamp logo
my question changes
Diego Mayer
@Chrono79
Nov 25 2016 12:48
@Blauelf yes, that's why I wrote almost ;)
Blauelf
@Blauelf
Nov 25 2016 12:49
@nani554 I think it takes you to where it thinks you left the site.
Yerrapotu Manojkiran
@nani554
Nov 25 2016 12:49
for me its totally magic
CamperBot
@camperbot
Nov 25 2016 12:50
nani554 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 3041 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Nov 25 2016 12:50
@nani554 Link is https://www.freecodecamp.com/challenges/next-challenge (not sure what magic is behind that one)
Yerrapotu Manojkiran
@nani554
Nov 25 2016 12:52
i dont know but i like it ,whenever i find one topic hard ,iam just clicking on it
Nico Vergauwen
@kyriediculous
Nov 25 2016 12:53
Is it possible to push data from an HTML form into a JSON object that is declared as a variable?
Ghulam Shabir
@ghulamshabir
Nov 25 2016 12:56
@kyriediculous yes you can
Nico Vergauwen
@kyriediculous
Nov 25 2016 12:57
name attribute as far as i can find ?
Markus Kiili
@Masd925
Nov 25 2016 12:57
@kyriediculous You mean JS object. JSON is a string format for storing objects.
Nico Vergauwen
@kyriediculous
Nov 25 2016 12:58
Nobody cares mate :)
It's commonly referred to as JSON never as JS object, but if you really need to feel good go ahead
accmail
@accmail
Nov 25 2016 12:59
hello i have problem with sorting 2D array i found this sort(function(a,){
return a[1]-b[1] but that doesnt work any help ?
})
var arr=[[1,"AAA"],[3,"DDD"],[10,"BBB"],[20,"CCC"]];
//so i want it to sort by strings  "AAA" "BBB" "CCC" "DDD"
//but it doesnt work i also try to arr = arr.sort(.... didn't help
arr.sort(function(a,b){
return a[1]-b[1];
});
Diego Mayer
@Chrono79
Nov 25 2016 13:01
@accmail try: return a[1]>b[1];
Blauelf
@Blauelf
Nov 25 2016 13:01
@accmail - is only for numeric comparison
accmail
@accmail
Nov 25 2016 13:02
@Chrono79 @Blauelf ok Thank you
CamperBot
@camperbot
Nov 25 2016 13:02
accmail sends brownie points to @chrono79 and @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2629 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 3042 | @blauelf |http://www.freecodecamp.com/blauelf
ungular
@ungular
Nov 25 2016 13:02
hi. how to do this.src='placeholder.png' in load of img?
<img load="javascript: this.src='placeholder.png' " src="{{ imageUtils.getImage(id) }}" onerror="javascript: this.src='placeholder.png'"/>
Blauelf
@Blauelf
Nov 25 2016 13:02
@accmail The full solution would be return (a[1]>b[1])-(b[1]>a[1]); (can return -1, 0, or 1), but @Chrono79 's shorter version is treated the same by all sort implementations I know.
Stephen James
@sjames1958gm
Nov 25 2016 13:02
@nani554 Clicking on the logo is how you go to the next challenge without having to submit
Blauelf
@Blauelf
Nov 25 2016 13:03
@sjames1958gm next in which sense?
Stephen James
@sjames1958gm
Nov 25 2016 13:03
@Blauelf In the order that they are presented if you go through the course
Same as the map.
accmail
@accmail
Nov 25 2016 13:05
@Blauelf his > doesnt' worked but i found localCompare and it worked
Blauelf
@Blauelf
Nov 25 2016 13:06
@sjames1958gm I tried a few times, and sometimes they were in the same order, sometimes they were not. That's why I ask. But I might have other pages open in some tab in another window, which might confuse the site, I would have to create a more minimal test case for that.
@accmail It should have worked.
Stefan
@st3fun1
Nov 25 2016 13:07
Hi guys can you tell me a way to refactor this Router
var express = require('express');
var app = express();
var mongodb = require('mongodb').MongoClient;
var PollRouter = express.Router();
var ObjectId = require('mongodb').ObjectID;
var route = function (dbAddress) {
PollRouter.route('/').get(function (req, res) {
var polls;
var pollOwner =