These are chat archives for FreeCodeCamp/HelpJavaScript

7th
Jun 2017
Jason Luboff
@JLuboff
Jun 07 2017 00:00
Yoinked it myself. And now I'm out. Peace
Veronica Eulenberg
@HappyViki
Jun 07 2017 00:00
WAT?
Okay peace
frankny
@frankny
Jun 07 2017 00:04
How do i stop gitter notifications from going to my email
nevermind found it
fadia19
@fadia19
Jun 07 2017 00:05
@HappyViki what do u think ?
d-beloved
@d-beloved
Jun 07 2017 00:10
hello. I am in the palindrome challenge, please what regular expression will work in order to replace it in the supplied string
Ravi Kishore Thella
@ravikishorethella
Jun 07 2017 00:13
@d-beloved I messaged you. check your all conversations tab
Joseph
@revisualize
Jun 07 2017 00:13
@fadia19 Global variables are NOT reset on each function execution.
@fadia19 So, each time the free code camp tests run it is just adding more and more and more to your global variable array
posh
Ayush Mahajan
@ay2306
Jun 07 2017 00:17
Is there something wrong with my code. Browser is not asking me persmission to disclose geolocation

var url = "https://api.darksky.net/forecast/" ;
var key = "5c66510a93c4925cb502c0e1a380ef6e/" ;
url+=key;
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
url+=position.coords.latitude;
url+=",";
url+=position.coords.longitude;
url+="&lang=en&units=si";
console.log(url);
});

}

var onLoad = function(data){
console.log(data);
};
$("document").ready(function(){
$.getJSON(url,onLoad,'jsonp');
});

Scott Schmitt
@Schmittyapolis
Jun 07 2017 00:21

I'm sure I'm missing something...

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

var a = 0;
var b = -30;
var c = -10;
var d = 0;
var e = 20;
var f = 30;

var fahrenheit = a 9/5 + 32;
b
9/5 + 32;
c 9/5 + 32;
d
9/5 + 32;
e 9/5 + 32;
f
9/5 + 32;
// Only change code above this line
return fahrenheit;
}

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

fadia19
@fadia19
Jun 07 2017 00:21
@revisualize thank you ... worked like a charm :D
CamperBot
@camperbot
Jun 07 2017 00:21
fadia19 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4108 | @revisualize |http://www.freecodecamp.com/revisualize
Ronique Ricketts
@RoniqueRicketts
Jun 07 2017 00:23
Hello guys I need some help with the document.querySelectorAll() Its not firing for my Pomodoro Clock but the document.querySelector() works fine. I wanted to use a single method that will allow me to grab all tags of a specific class.
Ayush Mahajan
@ay2306
Jun 07 2017 00:25
Hello anyone?
Ojini Chizoba Jude
@Deityhub
Jun 07 2017 00:25
thanks guys for your support have found my mistake, have been able to resolve the issue
Long Nguyen
@longnt80
Jun 07 2017 00:26
@Schmittyapolis what if I want to convert 3 celcius?
Oliver Vanderlip
@halfmeasures
Jun 07 2017 00:33
I'm having a lot of trouble understanding the Word Blank challenge in JavaScript

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

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("The " + myNoun + " is " + myAdjective + " and " + myVerb + myAdverb);

Ayush Mahajan
@ay2306
Jun 07 2017 00:35
Can anyone tell me why is browser not asking me permission to disclose location?
https://codepen.io/ayush2306/pen/LLVOEV
Ravi Kishore Thella
@ravikishorethella
Jun 07 2017 00:37
@halfmeasures you should not change the calling function parameters
Jean-Paul Sauve
@jp-sauve
Jun 07 2017 00:37
@ay2306 it could be your browser's settings. It asks me, in both FF and Chrome on Linux
Oliver Vanderlip
@halfmeasures
Jun 07 2017 00:38
@ravikishorethella explain that to me a little more

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

myNoun = "dog";
myAdjective = "big";
myVerb = "ran";
myAdverb = "quickly";
// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("The " + myNoun + " is " + myAdjective + " and " + myVerb + myAdverb);

Ravi Kishore Thella
@ravikishorethella
Jun 07 2017 00:39
@halfmeasures this is the given wordBlanks("dog", "big", "ran", "quickly");
Oliver Vanderlip
@halfmeasures
Jun 07 2017 00:39
@ravikishorethella right...i don't see where i've changed anything
Ayush Mahajan
@ay2306
Jun 07 2017 00:40

@jp-sauve <!DOCTYPE HTML>

<head>

<meta charset="utf-8">

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<script type="text/javascript" src="javascript/script.js"></script>
</head>

<body>
</body>
It tried same code on Linux Ubuntu Firefox and it still is neither showing log in console nor it is asking me for location..

Ravi Kishore Thella
@ravikishorethella
Jun 07 2017 00:40
@halfmeasures you should change the code inside the function
see this line inside the function//your code above this line
Oliver Vanderlip
@halfmeasures
Jun 07 2017 00:41
@ravikishorethella so i need to create new variables to complete the sentence?
ArchivalBoat50
@ArchivalBoat50
Jun 07 2017 00:42
the callback at end of link
Ravi Kishore Thella
@ravikishorethella
Jun 07 2017 00:42
@halfmeasures no. reset the code and start from scratch. This is just one line challenge. I will help you/
ROBUSTO8
@ROBUSTO8
Jun 07 2017 00:43
hi guys, i just finished my "Local Weather App" challenge and was wondering if there's any way I can load the page faster? Or what's making it load so slowly? codepen: https://codepen.io/ROBUSTO/pen/Wjaqab
Jean-Paul Sauve
@jp-sauve
Jun 07 2017 00:43
@ay2306 check the javascript console in your browser
Ayush Mahajan
@ay2306
Jun 07 2017 00:43
@jp-sauve its blanck
*blank
Oliver Vanderlip
@halfmeasures
Jun 07 2017 00:44
@ravikishorethella okay...i've reset the code...do i need to add variables identifying myNoun, myVerb etc...?
Hammad
@newnewb
Jun 07 2017 00:45
@ROBUSTO8 let me check your pen
Ravi Kishore Thella
@ravikishorethella
Jun 07 2017 00:46
@halfmeasures word_blanks is nothing but fill in the Blanks style sentence.
so, in the code we have a var result with empty strings , var result = "";
so now we nned to store somw funny string with the help of these given four parameters
Hammad
@newnewb
Jun 07 2017 00:47
@ROBUSTO8 it's pretty fast with me... ?
ROBUSTO8
@ROBUSTO8
Jun 07 2017 00:47
@newnewb oh yeah? hm nvm then maybe it's just me
Hammad
@newnewb
Jun 07 2017 00:48
@ROBUSTO8 try this one? https://codepen.io/newnewb/pen/owNBbw
Oliver Vanderlip
@halfmeasures
Jun 07 2017 00:49
@ravikishorethella so, something like result = "The" + myNoun + "is not" + myAdjective" etc...?
Ravi Kishore Thella
@ravikishorethella
Jun 07 2017 00:49
@halfmeasures yes but there should be spaces like "The "+myNoun+ " is "+...
@halfmeasures you are in the right track :clap:
ROBUSTO8
@ROBUSTO8
Jun 07 2017 00:51
@newnewb yeah that takes a while to load too so it's probably just my end
ArchivalBoat50
@ArchivalBoat50
Jun 07 2017 00:51
@ArchivalBoat50
Does anybody know what that callback thing means "https://api.darksky.net/forecast/97b4f9f4d8061a8a423d2c53ad8bde5f/"+lat+","+longi+"?callback=?";
the callback at end of link
Oliver Vanderlip
@halfmeasures
Jun 07 2017 00:52
@ravikishorethella cool...i got it now...thanks!...it was much easier than i was making it out to be...it was just hard understanding exactly what the challenge was asking for, as so much was thrown in there
CamperBot
@camperbot
Jun 07 2017 00:52
halfmeasures sends brownie points to @ravikishorethella :sparkles: :thumbsup: :sparkles:
:cookie: 422 | @ravikishorethella |http://www.freecodecamp.com/ravikishorethella
Christopher McCormack
@cmccormack
Jun 07 2017 00:52
@ArchivalBoat50 jQuery uses that to parse the ajax call as JSONP
Ravi Kishore Thella
@ravikishorethella
Jun 07 2017 00:53
@halfmeasures :smile: :+1:
ArchivalBoat50
@ArchivalBoat50
Jun 07 2017 00:55
@cmccormack Is parsing kind of like organizing the data?
josenz
@josenz
Jun 07 2017 00:57
any help for 190 exercise
Christopher McCormack
@cmccormack
Jun 07 2017 00:57
It means jQuery analysis the URL and if it sees that string it runs some functionality that creates a JSONP request
@ArchivalBoat50 Go down the rabbit hole... http://api.jquery.com/jquery.getjson/#jsonp
ArchivalBoat50
@ArchivalBoat50
Jun 07 2017 00:59
@cmccormack whats JSONP ? never heard of that before
Christopher McCormack
@cmccormack
Jun 07 2017 01:00
ashleyberberich
@ashleyberberich
Jun 07 2017 01:02
I'm having trouble with this. It says in the instructions that "wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).". What does that mean?
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

result = "The " + myAdjective + myNoun + myVerb + myAdverb;
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks(" dog", "big", " ran", " quickly");
Coy Sanders
@coymeetsworld
Jun 07 2017 01:02
@ashleyberberich there needs to be spaces between the words
ashleyberberich
@ashleyberberich
Jun 07 2017 01:02
in the wordBlanks() function, right?
Coy Sanders
@coymeetsworld
Jun 07 2017 01:02
your result is going to look like this The dogbigranquickly
yes
Ravi Kishore Thella
@ravikishorethella
Jun 07 2017 01:03
@ashleyberberich add space between the words i.e in the results
Keon Samuel
@keonsam
Jun 07 2017 01:03
anyone can hack here?
Coy Sanders
@coymeetsworld
Jun 07 2017 01:03
oh i see, you did it in the call
no you want to have it in the function because it'll run other tests
Keon Samuel
@keonsam
Jun 07 2017 01:03
for good
Christopher McCormack
@cmccormack
Jun 07 2017 01:03
@cmccormack Also if you're interested I made a Vanilla JS JSONP implementation that can be used if you didn't want to use jQuery for whatever reason. https://codepen.io/cmccormack/pen/qmgezK
Keon Samuel
@keonsam
Jun 07 2017 01:04
try fetch()
Christopher McCormack
@cmccormack
Jun 07 2017 01:06
@keonsam who is that for? I don't think fetch supports JSONP. I haven't tried it to test though
Joseph
@revisualize
Jun 07 2017 01:07
Hello!
Christopher McCormack
@cmccormack
Jun 07 2017 01:07
@revisualize :wave:
Joseph
@revisualize
Jun 07 2017 01:07
How's them things?
Christopher McCormack
@cmccormack
Jun 07 2017 01:08
Fantastic
Keon Samuel
@keonsam
Jun 07 2017 01:08
@cmccormack I didn't know, it is the cool new thing says google.
Avery Biskup
@fraknard
Jun 07 2017 01:11
https://codepen.io/fraknard/pen/xdveGQ?editors=0010 how can I run a function over an over?
only running once the first time is finished
Christopher McCormack
@cmccormack
Jun 07 2017 01:12
@fraknard setInterval(callback, timer)
@fraknard setInterval returns an interval ID and you'll want to store that so you can stop the timer later as well with clearInterval(intervalid)
Avery Biskup
@fraknard
Jun 07 2017 01:13
Yeah.
But I need to change from break to session
Without clicking the button
Christopher McCormack
@cmccormack
Jun 07 2017 01:16
@fraknard use the same interval but change the limit once your count drops to 0
Avery Biskup
@fraknard
Jun 07 2017 01:16
limit?
Christopher McCormack
@cmccormack
Jun 07 2017 01:16
when your count is 0, check which timer your using (store that somehow) and if it's session, switch to break, or vice versa
@fraknard if your session timer is 25 minutes, the limit would be 25 minutes, that's all I mean. Then when that timer drops to 0, switch to break timer and start counting down again
Avery Biskup
@fraknard
Jun 07 2017 01:17
Okay.
Thanks @cmccormack, I think I can figure it out.
CamperBot
@camperbot
Jun 07 2017 01:17
fraknard sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 786 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Jun 07 2017 01:18
timer = timer === 'break' ? 'session' : 'break'; something like that
@fraknard gl
Long Nguyen
@longnt80
Jun 07 2017 01:19
@fraknard one thing though, setInterval is not accurate for timer
Avery Biskup
@fraknard
Jun 07 2017 01:21
Accuracy is not of great priority.
Long Nguyen
@longnt80
Jun 07 2017 01:24
@fraknard ok then
you're just missing out on learning the real thing in that project
Keon Samuel
@keonsam
Jun 07 2017 01:28
what language is Javascript wrote in?
like the language used to make Javascript?
Jason G
@Jay33Canada
Jun 07 2017 01:30
@keonsam that's an interesting question. I'm curious on the answer too
Paul Christian L. Catoera
@poncatoera
Jun 07 2017 01:31
function golfScore(par, strokes) {
if (strokes == 1) {
return "Hole-in-one!";
} else if (strokes <= par - 2) {
return "Eagle";
} else if (strokes == par - 1) {
return "Birdie";
} else if (strokes == par) {
return "Par";
} else if (strokes == par + 1) {
return "Bogey";
} else if (strokes == par + 2) {
return "Double Bogey";
} else if (strokes >= par + 3) {
return "Go Home!";
}
// Only change code above this line
}
is this good practice?
Avery Biskup
@fraknard
Jun 07 2017 01:33
@longnt80 Oh, what's the real thing, I thought it was for setInterval..
Long Nguyen
@longnt80
Jun 07 2017 01:35
@fraknard that's what I said, setInterval is not accurate to measure time. If you working with clock, and your clock is running wrong then the construction of that clock is bad
Avery Biskup
@fraknard
Jun 07 2017 01:36
I agree it's not accurate, but isn't setInterval what fCC is expecting us to use?
Stephen James
@sjames1958gm
Jun 07 2017 01:36
@poncatoera That is about all you can do for that challenge
Ogechi Ike
@BlackMG27
Jun 07 2017 01:36
@poncatoera I would venture to say yes.
Paul Christian L. Catoera
@poncatoera
Jun 07 2017 01:36
okay thank you guys
Ogechi Ike
@BlackMG27
Jun 07 2017 01:36
@poncatoera What do you find dissatisfactory about it?
Stephen James
@sjames1958gm
Jun 07 2017 01:36
@keonsam V8 the engine in node and chrome is all c++
Long Nguyen
@longnt80
Jun 07 2017 01:36

I agree it's not accurate, but isn't setInterval what fCC is expecting us to use?

@fraknard no, FCC doesn't expect you to use anything

Avery Biskup
@fraknard
Jun 07 2017 01:37
Okay
What did you use?
Paul Christian L. Catoera
@poncatoera
Jun 07 2017 01:38
@BlackMG27 nothing really, just wanna see if i missed something. thanks
CamperBot
@camperbot
Jun 07 2017 01:38
poncatoera sends brownie points to @blackmg27 :sparkles: :thumbsup: :sparkles:
:cookie: 178 | @blackmg27 |http://www.freecodecamp.com/blackmg27
Long Nguyen
@longnt80
Jun 07 2017 01:38
@fraknard you have to use the Date object to grab the correct millisecond which help to output the correct second
Avery Biskup
@fraknard
Jun 07 2017 01:38
ok
Avery Biskup
@fraknard
Jun 07 2017 01:41
Okay, I tried using the Date() function in the beginning, but realized it would be more difficult. I wasn't sure how to save the current date into a variable that could be compared to the later date when you should stop the timer.
Garo
@Garabed96
Jun 07 2017 01:41
@JLuboff that's why I decided to start backend bfr finishing front end, get some of the projects done. I noticed the second you complete one project... the momentum can carry you most of the way and it becomes so much easier.
Proconsul
@proconsu1
Jun 07 2017 01:41

trying to tighten up my code a bit and this one is nagging at me. I feel like I am missing an obvious way to shorten this function (this is Sum All Number in a Range challenge)

function sumAll(arr) {
  var j = (Math.max(arr[0],arr[1])-1);
  for ( i = Math.min(arr[0],arr[1]) ; i < j ; i++ ) {
    arr.push(i+1);
  }
  return arr.sort(function(a,b){return a - b;}).reduce(function(a,b){return a + b;}, 0);

}

sumAll([1, 4]);

Can anyone clue to me a shorter, more efficient way, maybe some way of eliminating that for loop or something?

Christopher McCormack
@cmccormack
Jun 07 2017 01:43
@proconsu1 There is a mathematical formula for summations you could use
Proconsul
@proconsu1
Jun 07 2017 01:44
@cmccormack lay it on me, man
Christopher McCormack
@cmccormack
Jun 07 2017 01:45
I'm trying to remember what it is for a range that doesn't start from 1 - from 1 you can do (n * ( n + 1)) / 2
hmm might be n+1 let me check
yeah n+1
Christopher McCormack
@cmccormack
Jun 07 2017 01:50
I think the summation for a range greater 1 would be var summation = (m,n) => ((n-m+1) * (n + m)) / 2
Manuel
@manny45
Jun 07 2017 01:52
thx @hannabeasiam
CamperBot
@camperbot
Jun 07 2017 01:52
manny45 sends brownie points to @hannabeasiam :sparkles: :thumbsup: :sparkles:
:cookie: 213 | @hannabeasiam |http://www.freecodecamp.com/hannabeasiam
Christopher McCormack
@cmccormack
Jun 07 2017 01:53

So you can basically think of a summation like a pyramid:

*
* *
* * *
* * * *

If you take that pyramid, copy it, rotate it 180 degrees and attach it to the right of the existing pyramid, it becomes a rectangle:

* * * * *
* * * * *
* * * * * 
* * * * *

But notice the width is now 1 more than the max value was, so that's why in the first formula we had (n + 1). Now you have a rectangle, you can basically do length * width / 2 to get the area, which is the same as the sum of all values. With a range, you basically add the min to the max and multiply that by (max - min + 1). Basic algebra works well for this kind of problem.

Proconsul
@proconsu1
Jun 07 2017 01:53
@cmccormack so i could just plug that formula in, substituting Math.min(arr[0],arr[1]) for m and Math.max(arr[0],arr[1]) for n, and wouldn't need a loop, sort, or reduce?
Christopher McCormack
@cmccormack
Jun 07 2017 01:53
@proconsu1 Right! Although that may defeat the purpose :D
Proconsul
@proconsu1
Jun 07 2017 01:55
@cmccormack yeah, i suppose it would defeat the educational purpose of teaching me Math.min and .reduce, but I have now learned those...more or less, so for learning to tighten up my code that would be kaleidoscopic! :-) thanks
CamperBot
@camperbot
Jun 07 2017 01:55
proconsu1 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 787 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Jun 07 2017 01:55
@proconsu1 haha kaleidoscopic
Proconsul
@proconsu1
Jun 07 2017 02:02
@cmccormack sweetness. worked a treat. of course i went in all pedestrian and declared the variables n and m with the Math.min/max variants as initial values just to make it readable so I could refer back to it later. bot won't give a cookie for it, but thanks again
CamperBot
@camperbot
Jun 07 2017 02:02
:warning: proconsu1 already gave cmccormack points
proconsu1 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
Christopher McCormack
@cmccormack
Jun 07 2017 02:03
@proconsu1 no worries care to share your code?
Proconsul
@proconsu1
Jun 07 2017 02:03
@cmccormack i'll post before and after, with the before commented out:
function sumAll(arr) {
  /*
  var j = (Math.max(arr[0],arr[1])-1);
  for ( i = Math.min(arr[0],arr[1]) ; i < j ; i++ ) {
    arr.push(i+1);
  }
  return arr.sort(function(a,b){return a - b;}).reduce(function(a,b){return a + b;}, 0);
  */
  var m = Math.min(arr[0],arr[1]), n = Math.max(arr[0],arr[1]);
  return (((n-m+1) * (n + m)) / 2);
}

sumAll([1, 4]);
MadeForBacon
@MadeForBacon
Jun 07 2017 02:04
hey can someone help me with my project, its my pizza website and this code is supposed to put all the values together its working but its putting 5 more "0"
this is the code: function charge(){
qty += document.getElementById('numone').value;
qty += document.getElementById('numtwo').value;
qty += document.getElementById('numthree').value;
qty += document.getElementById('numfour').value;
qty += document.getElementById('numfive').value;
qty += document.getElementById('numsix').value;
qty += document.getElementById('numseven').value;
var standardpizza = 9.50;
var total = qty * standardpizza;
document.getElementById('total').innerHTML = 'Total charge $' + total;
}
Christopher McCormack
@cmccormack
Jun 07 2017 02:05
@MadeForBacon Convert value to a number first each time
@MadeForBacon you may also want to consider using document.getElementsByClassName('pizza') or some class you add to all those elements and then looping over the array that is returned to sum the qty.
Proconsul
@proconsu1
Jun 07 2017 02:08
@cmccormack seeing i need to revisit the math i learned about 35 years ago for a refresher
heidisdad2
@heidisdad2
Jun 07 2017 02:08
@proconsu1 hey man hows it going?
MadeForBacon
@MadeForBacon
Jun 07 2017 02:08
so you mean make a <div class="pizza"
@cmccormack
Proconsul
@proconsu1
Jun 07 2017 02:08
@heidisdad2 pretty good, cochise. how are you makin' out?
heidisdad2
@heidisdad2
Jun 07 2017 02:09
doing better
Christopher McCormack
@cmccormack
Jun 07 2017 02:09
@MadeForBacon whatever those elements are that you are calling .value on. div doesn't have a value property. numone, numtwo, etc...
heidisdad2
@heidisdad2
Jun 07 2017 02:09
just jumping back on since last night
Proconsul
@proconsu1
Jun 07 2017 02:09
@heidisdad2 better is always a good thing. me, too. only got back on about 30 mins ago
heidisdad2
@heidisdad2
Jun 07 2017 02:11
ahh cool you gonna be on a bit?
MadeForBacon
@MadeForBacon
Jun 07 2017 02:12
@cmccormack whats the best way to convert them in numbers
?
heidisdad2
@heidisdad2
Jun 07 2017 02:12
@proconsu1 im also on pacific time
MadeForBacon
@MadeForBacon
Jun 07 2017 02:13
because i have been trying to but iv'e been having problems
Proconsul
@proconsu1
Jun 07 2017 02:13
@heidisdad2 me, too, but it doesn't mean much at my end. my sleep schedule has basically no relation to the clock or the sun. think it may be under the influence of one of Jupiter's moons or sumthin' :-P
Christopher McCormack
@cmccormack
Jun 07 2017 02:14
@MadeForBacon you can just use Number(str)
Proconsul
@proconsu1
Jun 07 2017 02:14
@heidisdad2 yep, not going anywhere for a while yet
Christopher McCormack
@cmccormack
Jun 07 2017 02:15
@MadeForBacon parseInt(str) should also work
Proconsul
@proconsu1
Jun 07 2017 02:15
@heidisdad2 if i am slow in answering it is because i am working on challenges myself, so i only look in on the chat window when i pause to scratch my head or wave away the smoke coming outta my ears
MadeForBacon
@MadeForBacon
Jun 07 2017 02:16
do you think i have to do that to all of my input or just have one be i put all my values in to the string "qty"
becouse*
Christopher McCormack
@cmccormack
Jun 07 2017 02:18
@MadeForBacon I was just suggesting a nicer way to get the values. If you add the same class to all the inputs that you're trying to sum up, you can just loop through to get the sum of the values
Luc Neesby
@lucneesby
Jun 07 2017 02:18
var divisibleNum = 5;
while (divisibleNum < 51){
if (divisibleNum % 5 === 0 && divisibleNum % 3 === 0) {
console.log(divisibleNum);
divisibleNum++;
}
} Hey guys so here I created a script that finds numbers between 5 and 51 that are divisible by both 5 and 3. Problem there's an infinite loop issue and my browser cant load it. Are there any errors you guys can point out at first glance?
Proconsul
@proconsu1
Jun 07 2017 02:18
Are there any hazards inherent to nesting one .filter inside another?
@lucneesby you are only incrementing divisibleNum when you get a match on the if statement. it should increment on every iteration of the while loop whether there is a match or not - short version: move the increment statement outside the if statement
Luc Neesby
@lucneesby
Jun 07 2017 02:24
@proconsu1 Oh i see it now. Thanks
CamperBot
@camperbot
Jun 07 2017 02:24
lucneesby sends brownie points to @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 186 | @proconsu1 |http://www.freecodecamp.com/proconsu1
anirudh duggal
@anirudhdggl
Jun 07 2017 02:25
can anyone help me figure out error in my code
Proconsul
@proconsu1
Jun 07 2017 02:25
@anirudhdggl lay it on us
anirudh duggal
@anirudhdggl
Jun 07 2017 02:25

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

// Change these values to test your function
lookUpProfile("Akira", "likes");
Christopher McCormack
@cmccormack
Jun 07 2017 02:25
@MadeForBacon I made an example for you if it helps: https://codepen.io/cmccormack/pen/yXNjoO
MadeForBacon
@MadeForBacon
Jun 07 2017 02:26
@cmccormack thanks!
CamperBot
@camperbot
Jun 07 2017 02:26
madeforbacon sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 788 | @cmccormack |http://www.freecodecamp.com/cmccormack
anirudh duggal
@anirudhdggl
Jun 07 2017 02:27
@proconsu1 figured out the error?
Moisés Man
@moigithub
Jun 07 2017 02:28
NO dot notation with variables like prop
also u returning no contact too soon at first mismatch
anirudh duggal
@anirudhdggl
Jun 07 2017 02:28
@moigithub why??
@proconsu1 lemme have a look at it
Moisés Man
@moigithub
Jun 07 2017 02:29
cuz whatever follow the dot.. mean its a string literal.. a real property of the object

if u check ur object

    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },

it DONT have any property named "prop" literally

anirudh duggal
@anirudhdggl
Jun 07 2017 02:31
@moigithub I got your point, so instead i should use bracket notation as
return contacts[i][prop];
Moisés Man
@moigithub
Jun 07 2017 02:31
yep
Proconsul
@proconsu1
Jun 07 2017 02:31
@anirudhdggl :+1:
anirudh duggal
@anirudhdggl
Jun 07 2017 02:32
@proconsu1 It didn't strike me to use hasOwnProperty to check the property. I could have save alot of hard work
thanks @moigithub and @proconsu1 for correcting me!
CamperBot
@camperbot
Jun 07 2017 02:32
:cookie: 187 | @proconsu1 |http://www.freecodecamp.com/proconsu1
anirudhdggl sends brownie points to @moigithub and @proconsu1 :sparkles: :thumbsup: :sparkles:
:star2: 3334 | @moigithub |http://www.freecodecamp.com/moigithub
Proconsul
@proconsu1
Jun 07 2017 02:34
I think that No such contact thing must be one of the most commonly made errors in the early lessons. everyone (including me) seems to want to put that one inside their for loop the first time around.
anirudh duggal
@anirudhdggl
Jun 07 2017 02:37
@proconsu1 meaning?
Proconsul
@proconsu1
Jun 07 2017 02:39
@anirudhdggl that bit @moigithub mentioned earlier, about that final return statement being too soon. that is a very common mistake ppl make when they get to that particular challenge. i made it, too. that last catchall return statement, for when all the tests are false, needs to be outside the loop or the loop will never iterate
anirudh duggal
@anirudhdggl
Jun 07 2017 02:41
@proconsu1 okay I got your point
Proconsul
@proconsu1
Jun 07 2017 02:42
@anirudhdggl got to remember that return ends a function call, including any loop
anirudh duggal
@anirudhdggl
Jun 07 2017 02:42
@proconsu1 so where should I use the "return" call
Proconsul
@proconsu1
Jun 07 2017 02:43
@anirudhdggl that very last one, the "all is false" return, which in your case is this one: return "No such contact"; --- needs to be OUTSIDE the for loop, but before the end of the entire function
MadeForBacon
@MadeForBacon
Jun 07 2017 02:44
@cmccormack hey i understand your pen code intill "((acc, item) => {
return acc + Number(item.value)
}, 0)"
anirudh duggal
@anirudhdggl
Jun 07 2017 02:44
@proconsu1 but the remaining ones, that return the value, should they be inside the for loop only?
Manish Giri
@Manish-Giri
Jun 07 2017 02:44
@xp0sr where's the code?
anirudh duggal
@anirudhdggl
Jun 07 2017 02:45
@Manish-Giri follow the link and you'll reach there
Proconsul
@proconsu1
Jun 07 2017 02:46
@anirudhdggl yeah, the return statements that constitute positive matches, those ready to be output back to the function call, should be inside the loop, so that the loop doesn't keep running past the point that it serves any further purpose
Manish Giri
@Manish-Giri
Jun 07 2017 02:46
@anirudhdggl why don't you follow it and reach there?
Proconsul
@proconsu1
Jun 07 2017 02:46
@xp0sr not seeing a problem yet. those for loop conditions look like a workable place to begin
Manish Giri
@Manish-Giri
Jun 07 2017 02:47
@xp0sr in the loop, checking the length of each word might be a good thing to begin with.
Christopher McCormack
@cmccormack
Jun 07 2017 02:47
@MadeForBacon that's arrow notation, I can change it to the older notation if it helps
jorgeguz15
@jorgeguz15
Jun 07 2017 02:49
in the counting cards exercise what method should i use?
Christopher McCormack
@cmccormack
Jun 07 2017 02:49
@MadeForBacon but that code snippet you pasted basically sets the accumulator to 0 (}, 0)), then stores the value of the accumulator + the items numerical value in the accumulator to then be used in the next iteration of the reduce method.
jorgeguz15
@jorgeguz15
Jun 07 2017 02:50
i made one that is working fine, but the page dont approve
lesleywayne
@Lwave
Jun 07 2017 02:50
Can anyone show me how to finish up my lookup test? I'm missing something in my code and I'm not sure what it is
Christopher McCormack
@cmccormack
Jun 07 2017 02:51
@jorgeguz15 you can use switches or if statements, up to you, although switches are nice and clean for that exercise
Proconsul
@proconsu1
Jun 07 2017 02:51
@jorgeguz15 can you post your code?
jorgeguz15
@jorgeguz15
Jun 07 2017 02:51
i used switch
sure
lesleywayne
@Lwave
Jun 07 2017 02:52
It's only asking me to change the code between certain things, and I have changed my switch to an object array
jorgeguz15
@jorgeguz15
Jun 07 2017 02:52

var count = 0;

function cc(card) {
// Only change code below this line
switch(card) {
case 2:
case 3:
case 4:
case 5:
case 6:count++;
break;
case 7:
case 8:
case 9:count+=0;
break;
case 10:
case "J":
case "Q":
case "K":
case "A": count--;
break;
}
if (count>0){
return +count+ " Bet ";}
else {
return +count+ " Hold ";
}
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

Proconsul
@proconsu1
Jun 07 2017 02:52
@Lwave what do you have so far, code wise?
Christopher McCormack
@cmccormack
Jun 07 2017 02:53
@jorgeguz15 get rid of those spaces after Hold and Bet
@jorgeguz15 the + before count is unnecessary as well
Proconsul
@proconsu1
Jun 07 2017 02:54
@jorgeguz15 first the nitpicky bit. There is no need for this count+=0; since it doesn't actually do anything (so it and all the cases which call it can be removed)
now the non-nitpicky: make sure any string output is an EXACT match for what instructions expect
lesleywayne
@Lwave
Jun 07 2017 02:56
@proconsu1 I can send you the link or post it. which one do you prefer?
Proconsul
@proconsu1
Jun 07 2017 02:56
@Lwave best if you post the code using the triple backtick notation ```
@Lwave that makes it easy for us to copy and paste notable sections of your code
lesleywayne
@Lwave
Jun 07 2017 02:59
okay.. at the start of the code?
Proconsul
@proconsu1
Jun 07 2017 02:59
Public Service Announcement: there is a button in the lower right of the input section of this chat window with an icon showing M+. that opens a window which shows the markdown symbols this chat window recognizes. cool stuff there
@Lwave yep. best to see it all
Gebre Mesquitta
@MtZionCode
Jun 07 2017 02:59
Hey folks....whassup? Does anyone know the fastest way to learn JavaScript?
lesleywayne
@Lwave
Jun 07 2017 03:00

``` function phoneticLookup(val) {
var result = "";

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

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

Proconsul
@proconsu1
Jun 07 2017 03:00
@MtZionCode you already found it! THIS site is the fastest way (IMO) :-)
lesleywayne
@Lwave
Jun 07 2017 03:01

``` function phoneticLookup(val) {
var result = "";

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

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

Gebre Mesquitta
@MtZionCode
Jun 07 2017 03:01
@Giveback007 I'm trying to get my Front-End Cert by the end of August.....but I want to learn faster....and I want to complete the fron-end dev projects fast!
Proconsul
@proconsu1
Jun 07 2017 03:01
@Lwave the triple backticks need to be on lines by themselves both above and below your code section.
now to the case. if i remember this challenge correctly, it is trying to teach you how to use the switch function.
lesleywayne
@Lwave
Jun 07 2017 03:01
?? I'm having trouble getting that format decision to work heh
Gebre Mesquitta
@MtZionCode
Jun 07 2017 03:02
@proconsu1 LOL!
Christopher McCormack
@cmccormack
Jun 07 2017 03:03
@Lwave put the backticks on their own line
```
code
```
You can also edit previous posts
Proconsul
@proconsu1
Jun 07 2017 03:03
@Lwave so what you want to do is review the syntax for how to setup a switch (which is much like a for loop) and then adapt it to what the instructions are wanting you to do
@Lwave yeah, the little triple dots ... to the right of the timestamp can be clicked on to let you reply to, edit, etc. whatever message you are looking at
jorgeguz15
@jorgeguz15
Jun 07 2017 03:04
@proconsu1 @cmccormack thanks both, it was the "extra space" after hold and bet
CamperBot
@camperbot
Jun 07 2017 03:04
jorgeguz15 sends brownie points to @proconsu1 and @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 188 | @proconsu1 |http://www.freecodecamp.com/proconsu1
:cookie: 789 | @cmccormack |http://www.freecodecamp.com/cmccormack
lesleywayne
@Lwave
Jun 07 2017 03:05
No, it's not. This is what is wants: https://www.freecodecamp.com/challenges/using-objects-for-lookups @proconsu1
Christopher McCormack
@cmccormack
Jun 07 2017 03:05
Proconsul
@proconsu1
Jun 07 2017 03:06
@Lwave my bad. misremembered that challenge. one sec
lesleywayne
@Lwave
Jun 07 2017 03:06
@proconsu1 alright.
Proconsul
@proconsu1
Jun 07 2017 03:09
@Lwave ahh, just reviewed it. basically what they want you to do is convert that entire switch and all its cases into a single object, with the key-value pairs dictated by the individual cases of the switch. then add a simple return statement to call any particular value based on the key provided by the function call's parameter, i.e. val
Fareed F
@IamFareel
Jun 07 2017 03:10
im confused on challenge Make Object Properties Private. This is what i have so far but i dont know how to plug in the numbers. can someone give me a few hints?
var myCar = new Car();

var myBike = new Bike(); {
  var gear;
  this.getGear = function(){

  };
  this.setGear = function (){
    return gear;
  };
}
Steven
@LemonTruth
Jun 07 2017 03:11
You guys have any tips for making my code more efficient? seems like I always write very verbose algorithms.
lesleywayne
@Lwave
Jun 07 2017 03:11
@proconsu1 It's in an object literal.. I just need way to get the result to work, I suppose.
@LemonTruth maybe. Depends on what the code looks like already.
Proconsul
@proconsu1
Jun 07 2017 03:12
@Lwave not quite. the exercise is trying to show how an object can more efficiently replicate the use of a lengthy switch, so if you want to learn what the exercise is trying to teach, consider it a conversion from a switch to an object
Steven
@LemonTruth
Jun 07 2017 03:13
function repeatStringNumTimes(str, num) {
  // repeat after me
  var cabbage = str;
  if (num > 0) {
    for (i = 1; i < num; i++){
  cabbage += str;
  }
  return(cabbage);
} else {
  return "";
}
} 
repeatStringNumTimes("abc", 7);
@Lwave this just repeats the string the amount you set as num
@Lwave Does it seem like I could have written this more concise?
lesleywayne
@Lwave
Jun 07 2017 03:15
@LemonTruth I mean, It's possible, but I havent been coding for more than a year and that seems a little on the concise side to me. haha
Proconsul
@proconsu1
Jun 07 2017 03:16
@LemonTruth this bit here: if (num > 0) { for (i = 1; i < num; i++){ is redundant. if num is NOT greater than zero, then the loop will never execute anyway, will it?
Steven
@LemonTruth
Jun 07 2017 03:18
@proconsu1 ahh, good thinking. Let me try getting rid of that
Proconsul
@proconsu1
Jun 07 2017 03:21
It's all about learning to think like a fewkin' computer....which I freely admit I am still very much working on
lesleywayne
@Lwave
Jun 07 2017 03:23
@proconsu1 but wheres the mistake in my code?
Proconsul
@proconsu1
Jun 07 2017 03:28
@Lwave when you eliminated the if did you check how the curly brackets were going to affect the execution of what was left? (hint: a return statement ends a function all, including any loop in progress)
Steven
@LemonTruth
Jun 07 2017 03:28
function repeatStringNumTimes(str, num) {
  // repeat after me
  var cabbage = str;
    for (i = 1; i < num; i++){
  cabbage += str;
  }
  return(cabbage);
} 
  return "";
}
repeatStringNumTimes("abc", 7);
Proconsul
@proconsu1
Jun 07 2017 03:28
AFK for a bit
Steven
@LemonTruth
Jun 07 2017 03:28
but then the second return is impossible to reach
umm
Justin Woodward
@jwoo92
Jun 07 2017 03:30
@LemonTruth What is your goal with your current code?
FlashHero
@FlashHero
Jun 07 2017 03:31
@LemonTruth return ""; is not needed
and you don't need the parenthesis in return
Steven
@LemonTruth
Jun 07 2017 03:34
@FlashHero yeah, In a practical case I don't need the return "" but it requires me to return an empty string
FlashHero
@FlashHero
Jun 07 2017 03:35
return an empty string for what
Steven
@LemonTruth
Jun 07 2017 03:35
@FlashHero return an empty string when num < 0
@FlashHero so I guess I do have to use an if else statement
FlashHero
@FlashHero
Jun 07 2017 03:36
yes exactly first check if num < 0 if yes then return ""
@LemonTruth but you might want to make an empty array and push the values there because if num < 0, still you have the var cabbage = str; which means it will still return 'abc' so making an array and pushing the values there would be better
Steven
@LemonTruth
Jun 07 2017 03:39
@FlashHero @proconsu1 @Lwave alrighty, thanks guys. I'm a bit more comfortable with my code now
CamperBot
@camperbot
Jun 07 2017 03:39
lemontruth sends brownie points to @flashhero and @proconsu1 and @lwave :sparkles: :thumbsup: :sparkles:
:cookie: 191 | @flashhero |http://www.freecodecamp.com/flashhero
:cookie: 211 | @lwave |http://www.freecodecamp.com/lwave
:cookie: 189 | @proconsu1 |http://www.freecodecamp.com/proconsu1
Steven
@LemonTruth
Jun 07 2017 03:41
@FlashHero that is why I used the +=. It adds whatever to the variable
Austin Wiggins
@austinwiggins
Jun 07 2017 03:45
Hey All! Anyone willing to help me with the JS Challenge 'Where do I belong'?
Justin Woodward
@jwoo92
Jun 07 2017 03:45
@LemonTruth
function repeatStringNumTimes(str, num) {
  var ans = [""];
  for (var i = num - 1; i >= 0; i--){
    ans.push(str);
  }
  return ans.join('');
}
ArchivalBoat50
@ArchivalBoat50
Jun 07 2017 03:46
https://codepen.io/ArchivalBoat50/pen/OgJZGR
Why is my screen not loading,? What is wrong with my code currently
Justin Woodward
@jwoo92
Jun 07 2017 03:46
@austinwiggins Sure thing, what do you have so far?
Yannick Wiley
@ywiley94
Jun 07 2017 03:47

Hey everybody, Would anyone happen to know why my (1, 1) should be Hole in one, (4, 2) should be eagle, (5, 2) "", (4, 3) should be birdie. Keep return as par? Any Suggestions on how to get the math right?

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

return "Hole-in-one!";
}

// Only change code above this line
}

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

Austin Wiggins
@austinwiggins
Jun 07 2017 03:47

@jwoo92 So far this is what I've got:

function getIndexToIns(arr, num) {
arr = arr.sort();
return num;
}

getIndexToIns([40, 60], 50);

FlashHero
@FlashHero
Jun 07 2017 03:48
@LemonTruth oh forgot, it was supposed to be like num<=0 i didn't put the equal sign that's why it was returning unexpected values
Austin Wiggins
@austinwiggins
Jun 07 2017 03:49
I understand what I need to be doing, I just do not really get how to do it, if you know what I mean @jwoo92
ArchivalBoat50
@ArchivalBoat50
Jun 07 2017 03:49
https://codepen.io/ArchivalBoat50/pen/OgJZGR
Why is my screen not loading?
Bency
@bbchacko
Jun 07 2017 03:49
a should have a value of 7
b should have a value of 7
a should be assigned to b with =
how do I assigne a should be assigned to b with =
Justin Woodward
@jwoo92
Jun 07 2017 03:50
@austinwiggins Oh yeah, I know exactly what you mean. So given what you said, what do you think you need to do?
Jonathan Carroll
@gkcodeman
Jun 07 2017 03:50
function nextInLine(arr, item) {
  // Your code here

  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));
not sure why this isn't working
would appreciate any help you guys can offer
ricpconsulting
@ricpconsulting
Jun 07 2017 03:51
Hi guys. I am learning code, making a wp website and trying really hard. I finished a section on my home page but i dont know why is getting weird. Can someone help me? http://imgur.com/a/rkvaB
Austin Wiggins
@austinwiggins
Jun 07 2017 03:52
@jwoo92 I believe that I need to sort the array and then somehow figure out if the number is equal to, greater than, or less than the different numbers in the array and count the number of the numbers in the array that are less than the amount of the parameter num
Aditya Soni
@adist98
Jun 07 2017 03:53

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


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

    }else{
        return "No such property";
    }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
help needed
i need to access just the property name in the object, how do i do that
Jonathan Carroll
@gkcodeman
Jun 07 2017 03:55
@adist98 can you possibly use a " for in" loop to pull out just the property names in the object
Brooks
@Brodavis
Jun 07 2017 03:56
What am i doing wrong here?
```
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a || b < 0 ) ;
    return undefined;


  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
Aditya Soni
@adist98
Jun 07 2017 03:56
well if i have any way to access just the names, i dont think i need the loop @gkcodeman
Justin Woodward
@jwoo92
Jun 07 2017 03:56
@austinwiggins You are on the right path. It may make it easier if you somehow insert the new number first before sort. Then check out the indexOf() method on MDN .
Gebre Mesquitta
@MtZionCode
Jun 07 2017 03:57
Hey folks...question....what does this statement mean... "expected an assignment or function call and instead saw an expression" ??????
Proconsul
@proconsu1
Jun 07 2017 03:57
@ywiley94 as a matter of form it is good practice to enclose mathematical operations inside parens when testing them, so if (strokes >= par + 3)... would become this: if (strokes >= (par + 3))...
also, this is problematic: } else if ( par > strokes) {return "Hole-in-one!";. what if par is 4 but strokes is 2? is that a hole in one?
Aditya Soni
@adist98
Jun 07 2017 03:57
contacts[i].prop gives me the value of property, not the name, i need the name only @gkcodeman
@Brodavis
(a<0) || (b<0)
Justin Woodward
@jwoo92
Jun 07 2017 04:01
@austinwiggins Let me know how you are coming along with it. Once you get it solved, I can help you understand it better :)
Brooks
@Brodavis
Jun 07 2017 04:02
@MtZionCode An assignment is something like var or function(), and expression is the other things on the right side of an "=" in var = "blah blah"
Gebre Mesquitta
@MtZionCode
Jun 07 2017 04:02
@Brodavis thanks
CamperBot
@camperbot
Jun 07 2017 04:02
mtzioncode sends brownie points to @brodavis :sparkles: :thumbsup: :sparkles:
:cookie: 139 | @brodavis |http://www.freecodecamp.com/brodavis
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:03
@adist98 weird from what I'm reading it seems like what you have should be working
@adist98 its something simple we are both not seeing, I'll take another look
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:04
@adist98 contacts[i][prop] because .prop would look for a property called "prop".
Aditya Soni
@adist98
Jun 07 2017 04:04

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


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

    }else{
        return "No such property";
    }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:04
yes
I kept thinking that too
Aditya Soni
@adist98
Jun 07 2017 04:05
why does it not work @gkcodeman
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:05
but then got sidetracked cause the arg seemed correct passed in
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:05
@adist98 Also you are returning no such property at every iteration. Only return it if the firstname matches but it has no prop!
Brooks
@Brodavis
Jun 07 2017 04:05
@adist98 if (a<0) || (b<0);
return undefined;
what am i doing wrong?
Proconsul
@proconsu1
Jun 07 2017 04:05
@adist98 wasn't there a condition in which you needed to return "No such contact"?
Aditya Soni
@adist98
Jun 07 2017 04:06
wait i will check
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:06
@adist98 refer to @ivancsicsmarkus i think he is on to something there
Justin Woodward
@jwoo92
Jun 07 2017 04:06
@adist98 Checking out the .filter() method on MDN may help you out!
ArchivalBoat50
@ArchivalBoat50
Jun 07 2017 04:06
not page but pen
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:06
can anyone check this and tell me where I may be going wrong
function nextInLine(arr, item) {
  // Your code here

  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));
Proconsul
@proconsu1
Jun 07 2017 04:07
@gkcodeman didn't the instructions also tell you to take something OUT OF the array?
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:08
@proconsu1 checking
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:08
@gkcodeman also with returning arr.push you return the length of the array.
Aditya Soni
@adist98
Jun 07 2017 04:08

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


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

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

    }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
it has all the conditions
ArchivalBoat50
@ArchivalBoat50
Jun 07 2017 04:08
https://codepen.io/ArchivalBoat50/pen/OgJZGR
Why is my pen not loading? What is wrong with my code?
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:09
@adist98 If you return if the firstname does not match it will return at the first iteration. + only return no such property if the firstname matches

@ArchivalBoat50

var api = "https://api.darksky.net/forecast/55e71c3c2c92c82cb6e9c1fe2b175a9c/"+lat+","+long+"?callback=?";

you were missing a +

Brooks
@Brodavis
Jun 07 2017 04:10
@ArchivalBoat50 Unexpected identifier
Aditya Soni
@adist98
Jun 07 2017 04:12
@ivancsicsmarkus please elaborate
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:13
@adist98 Also you are returning no such property at every iteration. Only return it if the firstname matches but it has no prop!
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:13
@proconsu1
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
@proconsu1 it says to return the element that was removed
@proconsu1 I didn't remove any elements though
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:13
@gkcodeman The exercise says you to remove an element. You are only pushing one.
Brooks
@Brodavis
Jun 07 2017 04:13
why does this work:
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:14

@ivancsicsmarkus

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.

Proconsul
@proconsu1
Jun 07 2017 04:14
@gkcodeman "I didn't remove any elements though" - so this is what you need to address now, removing the item specified in the instructions
Bency
@bbchacko
Jun 07 2017 04:14
If speed is greater than 80, use console.log to print "Slow down"
Otherwise (else), use console.log to print "Drive safe"
Brooks
@Brodavis
Jun 07 2017 04:15
  if (a<0)
     return undefined;
    else if (b<0)
    return undefined;
but not this
if (a || b < 0 ) ;
    return undefined;
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:15
@gkcodeman then remove the first element of array ~ you did not do this
Brooks
@Brodavis
Jun 07 2017 04:15
whats the dif between those two codes
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:15
@ivancsicsmarkus ahhhhh im an idiot
or just tired as h#ll
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:16
@Brodavis You could make it:
if (a < 0 || b < 0 )
    return undefined;
Netrunner21
@Netrunner21
Jun 07 2017 04:16
I had asked a question earlier and I'm not sure if I got the response I needed. I'm still confused. On Record Collection, is the console purposely not functional?
Justin Woodward
@jwoo92
Jun 07 2017 04:16
@Brodavis the ; is in the incorrect spot.
SunXiong
@sunxiong
Jun 07 2017 04:16
yeah
Proconsul
@proconsu1
Jun 07 2017 04:16
@Brodavis this if (a || b < 0 ) ; doesnt do anthying with a
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:16
@Brodavis the logical or operator will return the truthy value, and a or b can be truthy no matter of zero.
@gkcodeman :D
Aditya Soni
@adist98
Jun 07 2017 04:17

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

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

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

Proconsul
@proconsu1
Jun 07 2017 04:17
how about as ivan said, if (a < 0|| b < 0 ) ;?
Aditya Soni
@adist98
Jun 07 2017 04:17
i think my code does the task
where is the error exactly??????
Brooks
@Brodavis
Jun 07 2017 04:17
@jwoo92 @proconsu1 @ivancsicsmarkus thanks guys
CamperBot
@camperbot
Jun 07 2017 04:17
brodavis sends brownie points to @jwoo92 and @proconsu1 and @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 190 | @proconsu1 |http://www.freecodecamp.com/proconsu1
:cookie: 421 | @jwoo92 |http://www.freecodecamp.com/jwoo92
:cookie: 587 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
Bency
@bbchacko
Jun 07 2017 04:17
how do i write this If speed is greater than 80, use console.log to print "Slow down"
Otherwise (else), use console.log to print "Drive safe"
Justin Woodward
@jwoo92
Jun 07 2017 04:17
@adist98 What do you currently have?
Zach Hope
@Baipanda11
Jun 07 2017 04:18
Hello everyone, I am having trouble wth the ++i operator in the question where it asks you to increment the variable by one
Proconsul
@proconsu1
Jun 07 2017 04:18
@adist98 it's partly a matter of ordering your conditions logically. if both are true, do this. else if only the first is true, do that, end loop, so that since neither was true do the other thing
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:18
@bbchacko
if (something) {
    then…
}
else {
    then…
}
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:18

@ivancsicsmarkus pays to read the instructions in life carefully kids, stay in school

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

return arr.shift([0]); // Change this line
}

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

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

Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:18
@bbchacko your something will be a speedtest
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:18
workin now
Proconsul
@proconsu1
Jun 07 2017 04:19
@gkcodeman lol
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:19
@gkcodeman nice
Tú T. Đỗ
@Young1906
Jun 07 2017 04:19
Hi, anyone on 225?
Netrunner21
@Netrunner21
Jun 07 2017 04:19
@sunxiong were you responding to what I asked?
Aditya Soni
@adist98
Jun 07 2017 04:19

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


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

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

    }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
it's coming
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:19
@gkcodeman You don’t need to pass [0] to the shift method.
Proconsul
@proconsu1
Jun 07 2017 04:19
@Young1906 the challenges don;t have numbers as far as i know. what's the name of the one you're on?
Aditya Soni
@adist98
Jun 07 2017 04:19
@jwoo92
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:19
@ivancsicsmarkus really
ArchivalBoat50
@ArchivalBoat50
Jun 07 2017 04:20
Justin Woodward
@jwoo92
Jun 07 2017 04:20
@bbchacko
function checkSpeed(speed){
  var msg = speed > 80 ? "Slow down" : "Drive safe";
  console.log(msg);
}

checkSpeed(90);
Tú T. Đỗ
@Young1906
Jun 07 2017 04:20
@proconsu1 : Using Objects for Lookups
Aditya Soni
@adist98
Jun 07 2017 04:20
@jwoo92

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


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

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

    }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Justin Woodward
@jwoo92
Jun 07 2017 04:20
@adist98 Looking at it now.
Tú T. Đỗ
@Young1906
Jun 07 2017 04:20
I can't pass the test case when val = ""
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:20
@ivancsicsmarkus why not?
Aditya Soni
@adist98
Jun 07 2017 04:20
check the conditions
Persefonee
@Persefonee
Jun 07 2017 04:21
Hi, I am stuck at the "Use Conditional Logic with If Statements" question, I have answered the question but it won't complete. Does anyone have any suggestions?
ArchivalBoat50
@ArchivalBoat50
Jun 07 2017 04:21
Proconsul
@proconsu1
Jun 07 2017 04:21
@Young1906 okay. with you now. have you coded any of it yet? if so, could you past what you have done so far?
Justin Woodward
@jwoo92
Jun 07 2017 04:21
@adist98 What challenge is this again?
Tú T. Đỗ
@Young1906
Jun 07 2017 04:21
// Setup
function phoneticLookup(val) {
  var result = "";

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

  result = lookup(val);

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

// Change this value to test
phoneticLookup("charlie");
Aditya Soni
@adist98
Jun 07 2017 04:21
https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afor%20(var%20i%3D0%3B%20i%20%3C%20contacts.length%3B%20i%2B%2B)%0A%09if%20((contacts%5Bi%5D.firstName%20%3D%3D%20firstName)%20%26%26%20(contacts%5Bi%5D.hasOwnProperty(prop)%3D%3D%3Dtrue))%7B%0A%09%20%20%20%20return%20contacts%5Bi%5D.prop%3B%0A%0A%09%7Delse%20if%20(contacts%5Bi%5D.firstName%20!%3D%20firstName)%7B%0A%09%09return%20%22No%20such%20contact%22%3B%0A%09%7Delse%20if%20(contacts%5Bi%5D.hasOwnProperty(prop)%3D%3D%3Dfalse)%20%7B%0A%20%20%20%20%20%20%20%20return%20%22No%20such%20property%22%3B%0A%20%20%20%20%20%20%0A%20%20%20%20%7D%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
@jwoo92
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:21
@ArchivalBoat50 you were missing some closing tags:
$(document).ready(function(){
  var long;
  var lat;
  var button = document.createElement("button");

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

  var api = "https://api.darksky.net/forecast/55e71c3c2c92c82cb6e9c1fe2b175a9c/"+lat+","+long+"?callback=?";
  $.getJSON(api, function (data){
    var weatherType = data.currently.summary;
    var wIcon = data.currently.icon;
    var fTemp = data.currently.temperature.toFixed();
    var cTemp = ((fTemp -32 )* 5/9).toFixed();

    $("#degrees").html(fTemp);
    $("#weatherType").html(weatherType);


   }); // end getJSON function
  }); // end geolocation 
 }
}); //end document ready
Jonathan Carroll
@gkcodeman
Jun 07 2017 04:21
that link tho
spoons4u
@spoons4u
Jun 07 2017 04:22
I am stuck on the Record Collection.
function updateRecords(id, prop, value) {

  if (value==='') {
      delete collection[id][prop];
      } else if (prop!=='tracks'){

        collection[id][prop] = value;

      } else {

        collection[id][prop].push(value);
  }

return collection;  
}
Netrunner21
@Netrunner21
Jun 07 2017 04:22
@spoons4u are you able to see what you return in the console?
Zach Hope
@Baipanda11
Jun 07 2017 04:22
is anyone familiar with the sytax for the ++ operator?
Proconsul
@proconsu1
Jun 07 2017 04:22
@Young1906 this: result = lookup(val); - the variable lookup is calling a position, so use square brackets, not parens
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:23
@Baipanda11 Yes, it is simple.
Tú T. Đỗ
@Young1906
Jun 07 2017 04:23

// Setup

```
function phoneticLookup(val) {
var result = "";

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

result = lookup(val);

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

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

Aditya Soni
@adist98
Jun 07 2017 04:23
@jwoo92 Profile Lookup
Markus Ivancsics
@ivancsicsmarkus
Jun 07 2017 04:23
@Baipanda11
var i = 3;
i++; // i is now 3
Austin Wiggins
@austinwiggins
Jun 07 2017 04:23
@jwoo92 So sorry, I hadn't checked the chat in a while. I did finish it, here is the code:
function getIndexToIns(arr, num) {
  arr = arr.sort(function(a,b) {
    return a-b;
  });
for(var i = 0; i<arr.length; i++) {
if (arr[i] >= num) break;
}
return i;
}
getIndexToIns([40, 60], 50);
Tú T. Đỗ
@Young1906
Jun 07 2017 04:23
@proconsu1 Ohh thanks. got it
CamperBot
@camperbot
Jun 07 2017 04:23
young1906 sends brownie points to @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 191 | @proconsu1 |http://www.freecodecamp.com/proconsu1
spoons4u
@spoons4u
Jun 07 2017 04:23
@Netrunner21 it works for everything except
After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
Netrunner21
@Netrunner21
Jun 07 2017 04:24
Then I must have a bug. My console isn't returning anything. Or I'm just not doing it right.
Jun
@kysnazz
Jun 07 2017 04:24
function sumPrimes(num) {
  var m=[];
  var n=[];
  var u=[];
  for(var i = 2; i <= num; i++){
    m.push(i);
  }
  n = m.filter(function(val){
    return val%2 !== 0;
  })
  for(var j = 0; j < n.length; j++){
    for(var x = 0; x < n.length; x++){
      if(n[j] !== n[x] && n[j]%n[x] !== 0){
        u.push(n[j]);
      }
    }
  }

  return u;  // OuT put [ 3, 3, 3, 5, 5, 5, 7, 7, 7, 9, 9 ]
}

sumPrimes(10);
Netrunner21
@Netrunner21
Jun 07 2017 04:24
Let me rephrase, it's not returning anything I do. It's returning the entire collection no matter what.
Zach Hope
@Baipanda11
Jun 07 2017 04:24
@ivancsicsmarkus oh i see i is just a generic name for whatever variable you are trying increment
Thank you
Jun
@kysnazz
Jun 07 2017 04:25
how can i change it to [3,5,7]
Proconsul
@proconsu1
Jun 07 2017 04:25
gahh. you'd think the fewkin' dog would know better than to eat weeds, after the last 4E26 times weeds made him hurl. gotta bolt and do some serious carpet cleaning
Jun
@kysnazz
Jun 07 2017 04:25
how can i change it to [3,5,7]
spoons4u
@spoons4u
Jun 07 2017 04:26
the tests have two options for id 5439, as it initially only an album prop, it adds an artist prop and Abba value
Aditya Soni
@adist98
Jun 07 2017 04:26
can anyone help me with this

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


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

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

    }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Jun
@kysnazz
Jun 07 2017 04:26
how can i change it to [3,5,7]
function sumPrimes(num) {
  var m=[];
  var n=[];
  var u=[];
  for(var i = 2; i <= num; i++){
    m.push(i);
  }
  n = m.filter(function(val){
    return val%2 !== 0;
  })
  for(var j = 0; j < n.length; j++){
    for(var x = 0; x < n.length; x++){
      if(n[j] !== n[x] && n[j]%n[x] !== 0){
        u.push(n[j]);
      }
    }
  }

  return u;  // OuT put [ 3, 3, 3, 5, 5, 5, 7, 7, 7, 9, 9 ]
}

sumPrimes(10);
Justin Woodward
@jwoo92
Jun 07 2017 04:26
@austinwiggins Nice! Here is my version:
function getIndexToIns(arr, num) {
  return arr.concat(num).sort(function(a,b){ return a-b; }).indexOf(num);
}
@austinwiggins .concat() concats num into the array arr, then I sort it least to greatest, then I get the index of num.
Aditya Soni
@adist98
Jun 07 2017 04:28
@jwoo92 did you look at the link
Austin Wiggins
@austinwiggins
Jun 07 2017 04:28
@jwoo92 Clever!
Justin Woodward
@jwoo92
Jun 07 2017 04:29
@austinwiggins If you are an ES6 guy, here it is with an arrow function.
function getIndexToIns(arr, num) {
  return arr.concat(num).sort((a,b) => a-b).indexOf(num);
}
ArchivalBoat50
@ArchivalBoat50
Jun 07 2017 04:30
@ivancsicsmarkus thanks
CamperBot
@camperbot
Jun 07 2017 04:30
archivalboat50 sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 588 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
JaedMon
@JaedMon
Jun 07 2017 04:30
Hi, I'm having trouble with the Stand in Line challenge in JS. I'm not sure how to push/unshift inside a function?
Austin Wiggins
@austinwiggins
Jun 07 2017 04:31
@jwoo92 I still need to familiarize myself with ES6 a bit
@jwoo92 Thanks for the help and good night! :sleeping:
CamperBot
@camperbot
Jun 07 2017 04:32
austinwiggins sends brownie points to @jwoo92 :sparkles: :thumbsup: :sparkles:
:cookie: 422 | @jwoo92 |http://www.freecodecamp.com/jwoo92
Aditya Soni
@adist98
Jun 07 2017 04:32
can anybody here help me
BeggarLewis
@BeggarLewis
Jun 07 2017 04:35
什么问题?
Ogundele Olumide
@Lumexralph
Jun 07 2017 04:36
@JaedMon just write the code in the function body
@adist98 with what?
Aditya Soni
@adist98
Jun 07 2017 04:36
@Lumexralph https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afor%20(var%20i%3D0%3B%20i%20%3C%20contacts.length%3B%20i%2B%2B)%7B%0A%09if%20((contacts%5Bi%5D%5BfirstName%5D%20%3D%3D%20firstName)%20%26%26%20(contacts%5Bi%5D.hasOwnProperty(prop)%3D%3D%3Dtrue))%7B%0A%09%20%20%20%20return%20contacts%5Bi%5D%5Bprop%5D%3B%0A%0A%09%7Delse%20if%20(contacts%5Bi%5D.firstName%20!%3D%20firstName)%7B%0A%09%09return%20%22No%20such%20contact%22%3B%0A%09%7Delse%20if%20(contacts%5Bi%5D.hasOwnProperty(prop)%3D%3D%3Dfalse)%20%7B%0A%20%20%20%20%20%20%20%20return%20%22No%20such%20property%22%3B%0A%20%20%20%20%20%20%0A%20%20%20%20%7D%0A%7D%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
Dillon Orr
@dillorr
Jun 07 2017 04:37
i feel like this is such a simple question but somehow I'm missing something with just fahrenheit = (celcius*(9/5)+32);
Cesar Fernandez
@Diamond713
Jun 07 2017 04:37
Whats wrong with this anybody?
var fahrenheit = 0 9/5 + 32;
var fahrenheit = -30
9/5 + 32;
var fahrenheit = -10 * 9/5 + 32;
Ogundele Olumide
@Lumexralph
Jun 07 2017 04:37
@dillorr celsius * 9 / 5 + 32
Dillon Orr
@dillorr
Jun 07 2017 04:37
does that variable need to be declared in javascript?
separately
doesn't the function declare it?
oh no parenthesis?
Ogundele Olumide
@Lumexralph
Jun 07 2017 04:38
@dillorr it's the name of your parameter
Dillon Orr
@dillorr
Jun 07 2017 04:38
fahrenheit = celcius*9/5+32;
now I've got this and it still doesn't like it
Konstantin von Brocke
@vonbrocke
Jun 07 2017 04:39
@adist98 I am at the same problem with a very similar code. I understand that my code only runs through the loop until it has a first result but not through the entire loop. If anyone can help and give the final hint, I'd really appreciate it.

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


function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0 ; i < contacts.length ; i++) {    
    if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
        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
}

// Change these values to test your function
lookUpProfile("Harry", "number");
Ogundele Olumide
@Lumexralph
Jun 07 2017 04:39
@Diamond713 use this formula celsius * 9 / 5 + 32 assign it to fahrenheit without var
HappyRedditor59
@HappyRedditor59
Jun 07 2017 04:39
for the Stand in Line challenge, am i supposes to use array methods?
Ogundele Olumide
@Lumexralph
Jun 07 2017 04:39
@dillorr it's celsius
@HappyRedditor59 yes, 2..... push and shift
Dillon Orr
@dillorr
Jun 07 2017 04:40
oh im an idiot thanks @Lumexralph
CamperBot
@camperbot
Jun 07 2017 04:40
dillorr sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1874 | @lumexralph |http://www.freecodecamp.com/lumexralph
HappyRedditor59
@HappyRedditor59
Jun 07 2017 04:40
thank @Lumexralph
CamperBot
@camperbot
Jun 07 2017 04:40
happyredditor59 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1875 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 07 2017 04:40
@vonbrocke @adist98
Here's an outline, if you follow it step-wise it'll help a great deal in telling you what to do or step you missed
1. you need a loop to pick each objects in the contacts array
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                  return the value of prop in the object
                 1.1.1.2  return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
Cesar Fernandez
@Diamond713
Jun 07 2017 04:40
Thanks Ogundele
Ogundele Olumide
@Lumexralph
Jun 07 2017 04:41
@dillorr @HappyRedditor59 :+1:
Cesar Fernandez
@Diamond713
Jun 07 2017 04:42
@Ogundele Olumide so whats var for?
Ogundele Olumide
@Lumexralph
Jun 07 2017 04:43
@Diamond713 it's a keyword in JS used to declare a variable but if it's already been declared as it has in your function, you just use the name not declaring with var again
Konstantin von Brocke
@vonbrocke
Jun 07 2017 04:45
@Lumexralph Thank you! I thought I pick each object at a time with the for loop, which, with my current thinking, should do exactly that...
CamperBot
@camperbot
Jun 07 2017 04:45
vonbrocke sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1876 | @lumexralph |http://www.freecodecamp.com/lumexralph
Cesar Fernandez
@Diamond713
Jun 07 2017 04:46
@ ogundele oh ok, got it thanks
Aditya Soni
@adist98
Jun 07 2017 04:46
@vonbrocke please share the solution
Ogundele Olumide
@Lumexralph
Jun 07 2017 04:47
@vonbrocke yes, but you need to nest the conditions
Justin Woodward
@jwoo92
Jun 07 2017 04:47
@adist98
function lookUpProfile(firstName, prop){
  var results = contacts.filter(function(c){ return c.firstName === firstName; });
  if (!results.length) return "No such contact";
  return (typeof results[0][prop] === 'undefined') ? "No such property" : results[0][prop];
}
@vonbrocke Check out my latest mention. The filter() method is perfect for this challenge :)
@austinwiggins Anytime!
Fernando Garibaldi
@Ferngari95
Jun 07 2017 04:50
Can someone help me with the Truncate a string algorithm challenge.
Can someone please explain why this does not work for the case im testing

function truncateString(str, num) {
// Clear out that junk in your trunk
var DotStr = "...";
var newStr = "";
if(str.length > num){
newStr = newStr.slice(0,num-3);
newStr = newStr.concat(DotStr);
}
return newStr;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);

HappyRedditor59
@HappyRedditor59
Jun 07 2017 04:52

can someone point out what is wrong with my code? i'm in the Stand in Line challenge. My code is as follows:

function nextInLine(arr, item) {
  // Your code here
  function nextInLine(){
    item = arr.pop();
    item = arr.unshift(item);
  }
  return item;  // Change this line
}

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

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

it displays the following:

Before: [1,2,3,4,5]
6
After: [1, 2, 3, 4, 5]
^^pls dont mind the spaces in the after part thatt was not intended
Mukul Agrawal
@mukul09
Jun 07 2017 04:54
@HappyRedditor59 you should use .push() instead of .pop() and .shift() instead of .unshift() methods
Konstantin von Brocke
@vonbrocke
Jun 07 2017 04:54
@adist98 Will do so as soon as I have it...
Ogundele Olumide
@Lumexralph
Jun 07 2017 04:54
@Ferngari95 are you to truncate with ... or ---
Aditya Soni
@adist98
Jun 07 2017 04:55
@vonbrocke no problem - i solved it
thanks @Lumexralph
CamperBot
@camperbot
Jun 07 2017 04:55
adist98 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1877 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 07 2017 04:55
@HappyRedditor59 push item into arr and then use shift to remove the first element which you have to return
@adist98 cool
Justin Woodward
@jwoo92
Jun 07 2017 04:57
@adist98 Did you understand my code?
Aditya Soni
@adist98
Jun 07 2017 04:57
@jwoo92 nope
but thanks anyways
Mario Ley Tello
@23marioley
Jun 07 2017 04:59

// 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"]"; // Change this line

Konstantin von Brocke
@vonbrocke
Jun 07 2017 05:00
Thanks @jwoo92. Am now trying to understand it ;)
CamperBot
@camperbot
Jun 07 2017 05:00
vonbrocke sends brownie points to @jwoo92 :sparkles: :thumbsup: :sparkles:
:cookie: 423 | @jwoo92 |http://www.freecodecamp.com/jwoo92
Mario Ley Tello
@23marioley
Jun 07 2017 05:00
can u tell me what's wrong with my code?
I need the program to print "maps"
Ogundele Olumide
@Lumexralph
Jun 07 2017 05:00
@23marioley it shouldn't be a string, remove the quotes
Justin Woodward
@jwoo92
Jun 07 2017 05:00
@adist98 I used the filter() method to slim down the contacts array to only contain objects with contacts[i].firstName equal to firstName parameter. Then if the object length is nonexistent ( less than 1), I return the statement for such. Next, I use a ternary operator which is basically a shorthand version of if, else while returning it at the same time.
@vonbrocke No problem!
Mario Ley Tello
@23marioley
Jun 07 2017 05:01
@Lumexralph oh, that was quick! thank you so much Mr.
CamperBot
@camperbot
Jun 07 2017 05:01
23marioley sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1878 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 07 2017 05:01
@23marioley you're welcome
Aditya Soni
@adist98
Jun 07 2017 05:02
@jwoo92 i can understand it, but i didn't knew these methods beforehand
Justin Woodward
@jwoo92
Jun 07 2017 05:03
@adist98 That is okay, it is how you learn :) I can’t say I learned them overnight either. No where close to the time it took me to be honest!
I am headed to bed, guys. It’s been fun! Later
Konstantin von Brocke
@vonbrocke
Jun 07 2017 05:03
@jwoo92 I am getting there. What I am wondering about now is that it returns the value 0994372684. Why is that? Per instructions, it should return other values.
Justin Woodward
@jwoo92
Jun 07 2017 05:04
@vonbrocke Throw your code up real quick and I will take a peak.
Konstantin von Brocke
@vonbrocke
Jun 07 2017 05:05

´´´

//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 = contacts.filter(function(c){ return c.firstName === firstName; });
if (!results.length) return "No such contact";
return (typeof results[0][prop] === 'undefined') ? "No such property" : results[0][prop];

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "number");

```

@jwoo92 It's exactly the code you shared before. It passes the freecodecamp test but returns this value that I cannot explain.
@jwoo92 oh never mind, I figured it out.. it's Harry's number ;)
Michael Cordero
@CyberPutty
Jun 07 2017 05:17
is it really tho?
Markus Kiili
@Masd925
Jun 07 2017 05:19
@Lumexralph Morning.
@vonbrocke You should use hasOwnProperty for the property existence test. Property can exist and have value undefined.
Justin Woodward
@jwoo92
Jun 07 2017 05:21
@vonbrocke Good find! im headed to bed, later!
Markus Kiili
@Masd925
Jun 07 2017 05:25
@vonbrocke Filter is also unefficient method here, because you are checking all the contacts even though the first could be the one you look for.
SNoon85
@SNoon85
Jun 07 2017 05:32
complete newbie here
-Assign the value 7 to variable a.
-Assign the contents of a to variable b.
here is what my code looks like
var a = 7;
var b = var a;
Markus Kiili
@Masd925
Jun 07 2017 05:34
@SNoon85 var keyword can only exist at the start of the line.
You declared a on the first line so after that you can just use a.
jeffdcruzj
@jeffdcruzj
Jun 07 2017 05:35
I am stuck with stand in line section
Markus Kiili
@Masd925
Jun 07 2017 05:37
@jeffdcruzj What have you done so far?
SNoon85
@SNoon85
Jun 07 2017 05:37
@Masd925 thank you very much, ughhh so simple
CamperBot
@camperbot
Jun 07 2017 05:37
snoon85 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4211 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 07 2017 05:38
@SNoon85 :+1:
Paul Christian L. Catoera
@poncatoera
Jun 07 2017 05:40
how to link my code here?
jeffdcruzj
@jeffdcruzj
Jun 07 2017 05:40
after researching I did like this, var addNum= testArr.push(item);
It did one part of the question. However, the function has 2 arguments. One is 'arr', second is 'item'. Arr is defined as testArr outside the function. But I do not know where the 'item' comes from
Markus Kiili
@Masd925
Jun 07 2017 05:40
@poncatoera Copy/paste it here using formatting. See link below:
'''
CamperBot
@camperbot
Jun 07 2017 05:40
:bulb: to format code use backticks! ``` more info
Paul Christian L. Catoera
@poncatoera
Jun 07 2017 05:41

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

if (count >= 1) {
string = " Bet";
} else {
string = " Hold";
}

return count + string;
// Only change code above this line
}

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

CamperBot
@camperbot
Jun 07 2017 05:41
:bulb: to format code use backticks! ``` more info
jeffdcruzj
@jeffdcruzj
Jun 07 2017 05:41

'''function nextInLine(arr, item) {
// Your code here
var addNum= testArr.push(item);

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

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

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

CamperBot
@camperbot
Jun 07 2017 05:41
:bulb: to format code use backticks! ``` more info
Paul Christian L. Catoera
@poncatoera
Jun 07 2017 05:41
var count = 0;
var string= "";
function cc(card) {
  // Only change code below this line
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count = count + 1;
      break;
    case 7:
    case 8:
    case 9:
      count = count + 0;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count = count -1;
      break;
  }

  if (count >= 1) {
    string = " Bet";
  } else {
    string = " Hold";
  }

  return count + string;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
is this good practice? or are there better ways to complete this task
Markus Kiili
@Masd925
Jun 07 2017 05:42
@jeffdcruzj Don't use testArr. Use function parameters arr and item that automatically hold the passed array and number from the function call.
@poncatoera Don't use a global variables like that string. They can mess up FCC tests.
pahosler
@pahosler
Jun 07 2017 05:42
there are def better ways, but learning switch/case is ok too
Paul Christian L. Catoera
@poncatoera
Jun 07 2017 05:43
so i should put var inside the function?
Markus Kiili
@Masd925
Jun 07 2017 05:44
@poncatoera You should declare the string variable inside the function.
@poncatoera That way is fine. Just a bit long and cumbersome. Here are some other ways:
function cc(card) {
  var VALUES = {2:1,3:1,4:1,5:1,6:1,7:0,8:0,9:0,10:-1,J:-1,Q:-1,K:-1,A:-1};
  count += VALUES[card];
  return String(count) + (count>0 ? " Bet" : " Hold");
}

function cc(card) {
  if (typeof card==="string" || card===10) count--;
  if (card<=6) count++;
  return String(count) + (count>0 ? " Bet" : " Hold");  
}
jeffdcruzj
@jeffdcruzj
Jun 07 2017 05:45
@Masd925 . Could you please explain, how is testArr value is pushed into the arguments in the function. Secondly where and what are items value. ?
Ahh. I got it sorry
It is called below in the console.log
Markus Kiili
@Masd925
Jun 07 2017 05:46
@jeffdcruzj Parameters get values when the function is called nextInLine([2], 1) and executed.
Konstantin von Brocke
@vonbrocke
Jun 07 2017 05:46
@Masd925 Thanks Markus. This code works well actually; it does solve the problem. If you have an alternate one, please share. I first tried it with a for loop and hasOwnProperty but didn't get the wanted results..
CamperBot
@camperbot
Jun 07 2017 05:46
vonbrocke sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4212 | @masd925 |http://www.freecodecamp.com/masd925
Paul Christian L. Catoera
@poncatoera
Jun 07 2017 05:47
@Masd925 thanks, also why is that if i but the count var inside the function it doesnt work?
CamperBot
@camperbot
Jun 07 2017 05:47
poncatoera sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4213 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 07 2017 05:47
@vonbrocke This way is pretty standard:
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i=0; i<contacts.length; i++) {
    if (contacts[i].firstName===firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      }
      return "No such property";
    }
  }
  return "No such contact";
// Only change code above this line
}
Paul Christian L. Catoera
@poncatoera
Jun 07 2017 05:48
i put*
Markus Kiili
@Masd925
Jun 07 2017 05:48
@poncatoera That global count variable count a running value affected by many function calls.
carlospala96
@carlospala96
Jun 07 2017 05:48

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++){
for (var j = 0; j < arr[i].length; j++){
product *= 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]]);

Paul Christian L. Catoera
@poncatoera
Jun 07 2017 05:49
okay thanks
carlospala96
@carlospala96
Jun 07 2017 05:49
why it returns me the typeerror: cannot read property '0' of undefined??
ShirazPirzada
@ShirazPirzada
Jun 07 2017 05:49
// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;
var b = 7;
var a = b;
How can i assigne a to b with = ??
Markus Kiili
@Masd925
Jun 07 2017 05:49
@carlospala96 multiplyAll is the function. Use arr instead.
pahosler
@pahosler
Jun 07 2017 05:50
@poncatoera this was my solution..
function cc(card) {

  if (card >=2 && card <=6) {
    count++;
  } else if (card >=7 && card <=9) {
    count=count;
  } else {
    count--;
  }

  if (count <= 0) {
    return count+" Hold";
  } else {
    return count+" Bet";
  }

}
carlospala96
@carlospala96
Jun 07 2017 05:50
oooh you are rigth thanks!! @Masd925
CamperBot
@camperbot
Jun 07 2017 05:50
carlospala96 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4214 | @masd925 |http://www.freecodecamp.com/masd925
Paul Christian L. Catoera
@poncatoera
Jun 07 2017 05:53
@pahosler ohh. thanks
CamperBot
@camperbot
Jun 07 2017 05:53
poncatoera sends brownie points to @pahosler :sparkles: :thumbsup: :sparkles:
:cookie: 367 | @pahosler |http://www.freecodecamp.com/pahosler
pahosler
@pahosler
Jun 07 2017 05:56
@poncatoera these days instead of using the two separate returns I'd do this...
return count + count <= 0 ? " Hold" : " Bet"
Shivam Mishra
@codifiedzio
Jun 07 2017 05:59
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.
Markus Kiili
@Masd925
Jun 07 2017 05:59
@pahosler I think return String(count) + (count<=0 ? " Hold" : " Bet"); is much easier to read and understand. Matter of taste of course.
Shivam Mishra
@codifiedzio
Jun 07 2017 05:59
I am stuck with this
ShirazPirzada
@ShirazPirzada
Jun 07 2017 06:00
// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;
var b = 7;
var a = b;
How can i assigne a to b with = ??
Markus Kiili
@Masd925
Jun 07 2017 06:01
@ShirazPirzada Assignment is from right side to left.
pahosler
@pahosler
Jun 07 2017 06:03
@Masd925 been learning ruby the past three weeks, all my code is getting much more turse, even the javascript ;)
Shivam Mishra
@codifiedzio
Jun 07 2017 06:03
??
Veronica Eulenberg
@HappyViki
Jun 07 2017 06:05
@ShirazPirzada Why did you assign 7 to a and be like that?
Shivam Mishra
@codifiedzio
Jun 07 2017 06:05
How to add the number to the end of the array, then remove the first element of array in JS. ??
pahosler
@pahosler
Jun 07 2017 06:06
push/unshift
Johnny Meza
@XLpacman805
Jun 07 2017 06:09
Anybody have any advice for building a pomodoro click?
pahosler
@pahosler
Jun 07 2017 06:11
have fun with it, be creative... learn setInterval... that about covers it I guess...
ShirazPirzada
@ShirazPirzada
Jun 07 2017 06:13
@HappyViki Ill try it afterwords right now really tired
Cesar Fernandez
@Diamond713
Jun 07 2017 06:13
What is wrong with this var fahrenheit = celsius 9/5 + 32;
fahrenheit = celsius
9/5 + 32;
fahrenheit = celsius 9/5 + 32;
fahrenheit = celsius
9/5 + 32;
fahrenheit = celsius * 9/5 + 32;
pahosler
@pahosler
Jun 07 2017 06:16
order of operation... js does multiplication first...
so it's going to celsius times 9 divided by 5 plus 32
you could say 1.8 instead of 9/5
celsius*1.8+32
Cesar Fernandez
@Diamond713
Jun 07 2017 06:21
Ok
Tatwamsiddha
@Tatwamsiddha-Nanda
Jun 07 2017 06:21

function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr.sort(function(a,b){
return a-b;
});
for(var i=1;i<arr.length-1;i++) { if (arr[i]>=num&&arr[i+1]<=num) return i;

}

if (arr[0]>=num ) return 0;
else if(arr[arr.length-1]<=num ) return arr.length-1;

}

getIndexToIns([40, 60], 50);
need help

Cesar Fernandez
@Diamond713
Jun 07 2017 06:21
Thats what i tought but this fcc still let me pass
Markus Kiili
@Masd925
Jun 07 2017 06:22
@Tatwamsiddha-Nanda The solution is much simpler if you first push num into arr and then sort.
Tatwamsiddha
@Tatwamsiddha-Nanda
Jun 07 2017 06:23
oh
but still where did i go wrong
Pearl
@Jiaaa1014
Jun 07 2017 06:23
function checkCashRegister(price, cash, cid) {
  var i,
      cid2,
      really = [],
      allIhave = 0,
      change = cash - price;    //要找的錢price-cash

for(i in cid){                  //相加好了

  allIhave = allIhave + cid[i][1];
}

if(allIhave.toFixed(2) == change) return "Closed";
if(allIhave.toFixed(2) <= change) return "Insufficient Funds";

if(allIhave.toFixed(2) >= change) {

  cid2 = [[0.01, cid[0][1]], [0.05, cid[1][1]], [0.1, cid[2][1]], [0.25, cid[3][1]], [1, cid[4][1]], [5, cid[5][1]], [10, cid[6][1]],          [20, cid[7][1]], [100, cid[8][1]]];


  for(i=cid.length-1;i>=0;i--){

    if(change >= cid2[i][0]){

      cid[i][1] = Math.floor(change/cid2[i][0])*cid2[i][0];  

      if(cid[i][1] <= cid2[i][1]) {
        really.push(cid[i]);
        change -= cid[i][1];
      } else {
        cid[i][1] = Math.floor(change/cid2[i][0]-1)*(cid2[i][0]);
        really.push(cid[i]);
        change -= cid[i][1];

      }

    } else{
      continue;
    }
  }
  return really;
} 

}
[["TWENTY", 60.00], ["TEN", 20.00], ["FIVE", 15.00], ["ONE", 1.00], ["QUARTER", 0.50], ["DIME", 0.20], ["PENNY", 0.04]]
but my "Penny" always only has 0.03
Markus Kiili
@Masd925
Jun 07 2017 06:26
@Jiaaa1014 Only interegers <9007199254740992 are guaranteed to have an exact representation as float (all JS numbers are 64bit floats). So you are bound to encounter precision problems if you use decimal numbers.
Only robust way to avoid them is to use penny amounts that are safe integers.
Tatwamsiddha
@Tatwamsiddha-Nanda
Jun 07 2017 06:28
@Masd925 where did i go wrong
Markus Kiili
@Masd925
Jun 07 2017 06:29
@Tatwamsiddha-Nanda Hard to say. That way the solution has so many cases to cover.
pahosler
@pahosler
Jun 07 2017 06:30
@Jiaaa1014 change = Math.round(change *100)/100
Sudeesh P
@sudhi735
Jun 07 2017 06:33
how to insert screenshot
Markus Kiili
@Masd925
Jun 07 2017 06:33
@sudhi735 Drag and drop might work.
Sudeesh P
@sudhi735
Jun 07 2017 06:33
@Masd925 thank you
CamperBot
@camperbot
Jun 07 2017 06:33
sudhi735 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4215 | @masd925 |http://www.freecodecamp.com/masd925
pahosler
@pahosler
Jun 07 2017 06:34
@Tatwamsiddha-Nanda it looks like your code is returning either 0 or the length or the array-1, and you should be retuning the index of where the num is inserted
kirbyedy
@kirbyedy
Jun 07 2017 06:34
@sudhi735 if you want to show your code maybe its smarter to use this guide: https://github.com/freecodecamp/freecodecamp/wiki/code-formatting
calistaL
@calistaL
Jun 07 2017 06:34

var myStr="This is the start." + "This is the end."

doesn't ^ give the value of "This is the start. This is the end." ??

pahosler
@pahosler
Jun 07 2017 06:34
help format
Sudeesh P
@sudhi735
Jun 07 2017 06:34
@kirbyedy thank you
CamperBot
@camperbot
Jun 07 2017 06:34
sudhi735 sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 2093 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
Tatwamsiddha
@Tatwamsiddha-Nanda
Jun 07 2017 06:35
thanks @Masd925 and @pahosler
CamperBot
@camperbot
Jun 07 2017 06:35
tatwamsiddha-nanda sends brownie points to @masd925 and @pahosler :sparkles: :thumbsup: :sparkles:
:cookie: 368 | @pahosler |http://www.freecodecamp.com/pahosler
:star2: 4216 | @masd925 |http://www.freecodecamp.com/masd925
kirbyedy
@kirbyedy
Jun 07 2017 06:35
@calistaL you are missing a space either at the end of the sentence after the dot, or before the beginning of the second sentence
Long Nguyen
@longnt80
Jun 07 2017 06:35
@pahosler Math.round is not the answer
pahosler
@pahosler
Jun 07 2017 06:35
help
/help
calistaL
@calistaL
Jun 07 2017 06:35
@kirbyedy ohh i see, thank you!
CamperBot
@camperbot
Jun 07 2017 06:35
calistal sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 2094 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
pahosler
@pahosler
Jun 07 2017 06:36
help is broken again
kirbyedy
@kirbyedy
Jun 07 2017 06:36
cbot
CamperBot
@camperbot
Jun 07 2017 06:36
you called?
pahosler
@pahosler
Jun 07 2017 06:36
@longnt80 it works
kirbyedy
@kirbyedy
Jun 07 2017 06:36
'''
CamperBot
@camperbot
Jun 07 2017 06:36
:bulb: to format code use backticks! ``` more info
Joseph
@revisualize
Jun 07 2017 06:37
About @revisualize
CamperBot
@camperbot
Jun 07 2017 06:37
:star2: 4108 | @revisualize |http://www.freecodecamp.com/revisualize
Long Nguyen
@longnt80
Jun 07 2017 06:37
@pahosler are you sure? It still need decimal after the .
Math.round just remove it
lagasi
@lagasi
Jun 07 2017 06:38
@Jiaaa1014 It's a floating point rounding error. If you step through each calculation, you'll find you only have slightly less than 0.04 at the end like 0.0399999
pahosler
@pahosler
Jun 07 2017 06:38
spoilers live here, but you can check out my code if you like... https://github.com/pahosler/freecodecamp/blob/master/advanced_javascript/exact_change.js
Sudeesh P
@sudhi735
Jun 07 2017 06:39
Screenshot (98).png might not be correct but i am getting the correct output though and not able to move forward
not sure what i am doing wrong there
lagasi
@lagasi
Jun 07 2017 06:40
@Jiaaa1014 One possible solution is to convert everything to cents and round every step, then convert back at the end
Sudeesh P
@sudhi735
Jun 07 2017 06:40
its the profile lookup challange
javascript
Long Nguyen
@longnt80
Jun 07 2017 06:40
@pahosler thanks
CamperBot
@camperbot
Jun 07 2017 06:40
:cookie: 369 | @pahosler |http://www.freecodecamp.com/pahosler
longnt80 sends brownie points to @pahosler :sparkles: :thumbsup: :sparkles:
pahosler
@pahosler
Jun 07 2017 06:47
try this in repl.it
console.log(Math.round(.235 * 100)/100)
Long Nguyen
@longnt80
Jun 07 2017 06:48
@pahosler I did
pahosler
@pahosler
Jun 07 2017 06:48
or in a console if you have nodejs on your pc
works right?
cool stuff ;)
Sudeesh P
@sudhi735
Jun 07 2017 06:49
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
    if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
     return contacts[i][prop]; 
  }
}
  for (i = 0; i < contacts.length; i++) {
    if (firstName === contacts[i].firstName && !(contacts[i].hasOwnProperty(prop))) {
      return "No Such Property";
  } 
} 
  for (i = 0; i < contacts.length; i++) {
    if (firstName !== contacts[i].firstName) {
      return "No Such contact";
  } 
}


// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Bob", "number");
Markus Kiili
@Masd925
Jun 07 2017 06:49
@sudhi735 It is better to use only one loop through contacts array.
erkais
@erkais
Jun 07 2017 06:49
Hello guys, what does "myStr should have encoded text with the proper escape sequences and no spacing." this mean?
Sudeesh P
@sudhi735
Jun 07 2017 06:51
@Masd925 I am getting the correct output but i am not able to move forward. And I literarly don't know how to get it done with just one loop. I tired with if, else if but it didn't work
what i did, is it wrong?
Markus Kiili
@Masd925
Jun 07 2017 06:51
@sudhi735 Check the spelling of those return strings.
@sudhi735 You could refactor the code somewhat. To more efficient and readable code.
Sudeesh P
@sudhi735
Jun 07 2017 06:54
@Masd925 that worked thank you so much. do u mean that it can be converted into a single if - elseif statement under a single loop
CamperBot
@camperbot
Jun 07 2017 06:54
sudhi735 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: sudhi735 already gave masd925 points
Markus Kiili
@Masd925
Jun 07 2017 06:55
@sudhi735 Two nested if's inside the contact loop and the returns is enough.
Sudeesh P
@sudhi735
Jun 07 2017 06:55
@Masd925 okk i will give it a try
Tatwamsiddha
@Tatwamsiddha-Nanda
Jun 07 2017 06:56
function rot13(str) { // LBH QVQ VG!
var s=""; var k;
for (i=0;i<str.length;i++){ k=str.charCodeAt(i); if (k>=65&&k<=90)
{
if (k<=77) s=s+String.fromCharCode(k+13);
else s=s+String.fromCharCode((90-k)+13);
}
s=s+str.charAt(i);
}
return s;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
where am i worng again?
ms-dosx86
@ms-dosx86
Jun 07 2017 06:58

steamrollArray([[["a"]], [["b"]]]) should return ["a", "b"].

var array = [];

function steamrollArray(arr) {
  // I'm a steamroller, baby
  for (var i = 0; i < arr.length; i++) {
    if (Array.isArray(arr[i]))
      steamrollArray(arr[i]);
    else
      array.push(arr[i]);
  }
  return array;
}

steamrollArray([[["a"]], [["b"]]]);

return ["a","b"]

whats wrong?)

Markus Kiili
@Masd925
Jun 07 2017 06:59
@ms-dosx86 Don't use a global variable like that.
Messes up FCC tests.
ms-dosx86
@ms-dosx86
Jun 07 2017 06:59
why?
:c
Markus Kiili
@Masd925
Jun 07 2017 06:59
Tests call that function several times but the global variable doesn't reset.
ms-dosx86
@ms-dosx86
Jun 07 2017 06:59
im sad
Markus Kiili
@Masd925
Jun 07 2017 07:00
@ms-dosx86 You can make it work by wrapping the variable and the function on a wrapper function that calls the inner function.
Or by changing the logic.
Tatwamsiddha
@Tatwamsiddha-Nanda
Jun 07 2017 07:00

function rot13(str) { // LBH QVQ VG!
var s=""; var k;
for (i=0;i<str.length;i++){ k=str.charCodeAt(i); if (k>=65&&k<=90)
{
if (k<=78) s=s+String.fromCharCode(k+13);
else s=s+String.fromCharCode((k-78)+65);
}
s=s+str.charAt(i);
}
return s;
}

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

ms-dosx86
@ms-dosx86
Jun 07 2017 07:01
@Masd925 I'm going to try it now
Markus Kiili
@Masd925
Jun 07 2017 07:02
@Tatwamsiddha-Nanda Why s=s+str.charAt(i); ?
Try to format and indent the code so it can be read better. And try to use desriptive variable names.
Tatwamsiddha
@Tatwamsiddha-Nanda
Jun 07 2017 07:03

function rot13(str) { // LBH QVQ VG!
var s=""; var k;
for (i=0;i<str.length;i++){ k=str.charCodeAt(i); if (k>=65&&k<=90)
{
if (k<=77) s=s+String.fromCharCode(k+13);
else s=s+String.fromCharCode((k-78)+65);
}
else
s=s+str.charAt(i);
}
return s;
}

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

got that right
Markus Kiili
@Masd925
Jun 07 2017 07:04
Yeah.
Tatwamsiddha
@Tatwamsiddha-Nanda
Jun 07 2017 07:04
how do i take screenshots?
thanks @Masd925
CamperBot
@camperbot
Jun 07 2017 07:04
:warning: tatwamsiddha-nanda already gave masd925 points
tatwamsiddha-nanda sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
Vivek Ranjan
@vivekranjan92
Jun 07 2017 07:09
hey I am facing issue in "Comparisons with the Logical And Operator"

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

if (val<=50) &&{
if (val>=25) {
return "Yes";
}
}

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

// Change this value to test
testLogicalAnd(10);

this is what I have done so far
can anyone help me
?
I have tried to put both the condition in same if statement but still not working
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:13
@vivekranjan92 use if( val<=50 && val>=25) don;t know about your logic but this is how syntax should be.
Vivek Ranjan
@vivekranjan92
Jun 07 2017 07:14
yeah i have tried that as well but is not working @saifsmailbox98
that's what i have mentioned with my question
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:14
@vivekranjan92 post your task link
Vivek Ranjan
@vivekranjan92
Jun 07 2017 07:15
i have tried to put bith the condition in same if statement
Russ Houlden
@MonkeyRusSH
Jun 07 2017 07:16
anybody else stuck on the javascript change to fahrenheit challenge
Alexandru Higyedi
@Journeytojah
Jun 07 2017 07:17
I passed it a few hours ago
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:17
@vivekranjan92

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

  if (val<=50 && val>=25) {

       return "Yes";

  }


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

// Change this value to test
testLogicalAnd(10);
Alexandru Higyedi
@Journeytojah
Jun 07 2017 07:17
This javascript part is tricky and confusing :/
Vivek Ranjan
@vivekranjan92
Jun 07 2017 07:17
@saifsmailbox98 yeah now t worked but i was also doing same thing till now
thanks @saifsmailbox98
CamperBot
@camperbot
Jun 07 2017 07:18
vivekranjan92 sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 418 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:18
image.png
@vivekranjan92
this is why it was not working.
Vivek Ranjan
@vivekranjan92
Jun 07 2017 07:18
ohhh
:clap:
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:19
@vivekranjan92 :+1:
Alexandru Higyedi
@Journeytojah
Jun 07 2017 07:20
Im stuck at the word blanks exercise
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:20
@Journeytojah post your code
Alexandru Higyedi
@Journeytojah
Jun 07 2017 07:22
I dont really understand what i have to do...
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:22
@Journeytojah
You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.
Alexandru Higyedi
@Journeytojah
Jun 07 2017 07:23

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

// Your code above this line
return result;
}

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

Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:23
@Journeytojah you haven't even tried..
Alexandru Higyedi
@Journeytojah
Jun 07 2017 07:23
oh
Yes i did :)
I think i understand now, thanks :thumbsup:
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:24
@Journeytojah yw
Russ Houlden
@MonkeyRusSH
Jun 07 2017 07:24
@Journeytojah did you struggle on the celsuis change task?
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:25
@MonkeyRusSH are you stuck ?
YozhikM
@YozhikM
Jun 07 2017 07:25
Hello
Russ Houlden
@MonkeyRusSH
Jun 07 2017 07:25
@saifsmailbox98 indeed I am.
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:25
@MonkeyRusSH do you have the formula?
YozhikM
@YozhikM
Jun 07 2017 07:25
How I can refactoring this code? https://jsfiddle.net/2vxjqvpa/
Russ Houlden
@MonkeyRusSH
Jun 07 2017 07:25
the formula is celsius * 9/5 + 32
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:26
@MonkeyRusSH yes, now assign this whole thing to fahrenheit.
Alexandru Higyedi
@Journeytojah
Jun 07 2017 07:26
@MonkeyRusSH i took a 5 minute break for that one and it just made sense after
Sometimes you dont see whats right in front of you
Like me, now :)
Russ Houlden
@MonkeyRusSH
Jun 07 2017 07:26
meaning var sum= celsius * 9/5 + 32 @saifsmailbox98 @Journeytojah would that be right
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:27
@MonkeyRusSH yes but to fahrenheit not to sum
Russ Houlden
@MonkeyRusSH
Jun 07 2017 07:27
or would it have to be reversed
Alexandru Higyedi
@Journeytojah
Jun 07 2017 07:27
Im still stuck here, going to take a break to clear my head and come back
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:28
@MonkeyRusSH also don't use var to assign it any value if its already defined using var
Russ Houlden
@MonkeyRusSH
Jun 07 2017 07:28
@saifsmailbox98 cause in the code var fahrenheit is already defined
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:28
@MonkeyRusSH yes
so you don't need to use var again.
just the assignment operator =
Rick Willcox
@willcoxDev
Jun 07 2017 07:29

var Person = function(firstAndLast) {
    this.getFirstName = function(){
      return firstAndLast.split(" ")[0];  
    };

    this.getLastName = function(){
      return firstAndLast.split(" ")[1];
    };

    this.getFullName = function() {
      return firstAndLast;
    };

    this.setFirstName = function(first){
      return first + " " + firstAndLast.split(" ")[1];
    };

    this.setLastName = function(last){
      return firstAndLast.split(" ")[0] + " " + last;
    };  

    this.setFullName = function(firstAndLast){
      return firstAndLast;
    };

};

var bob = new Person('Bob Ross');
bob.setFullName("Haskell Curry");
Can anyone shed some light on why this doesn't work for any of the setters? when I manaully input the tests it returns the correct names each time. Unsure what I am doing wrong. I feel like I should be setting something in the set area but I dont have any variables to set...
Russ Houlden
@MonkeyRusSH
Jun 07 2017 07:30
@saifsmailbox98 but then theres no identifier
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:31
@MonkeyRusSH post your corrected code
Russ Houlden
@MonkeyRusSH
Jun 07 2017 07:31

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

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

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

Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:32
@MonkeyRusSH insted of this =convertToF * 9/5 + 32; put this fahrenheit= 9/5 * celsius +32;
Markus Kiili
@Masd925
Jun 07 2017 07:33
@willcoxDev That parameter firstAndLast holds the information about the name of the person. Setters should change that parameter value.
Russ Houlden
@MonkeyRusSH
Jun 07 2017 07:33
@saifsmailbox98 thats got it, so basically, i was trying to be too clever with the convert to code. and my code was in the wrong order?
Markus Kiili
@Masd925
Jun 07 2017 07:33
You could also use private variable(s) for holding the info.
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:33
@willcoxDev in setFirstName you are returning something,
Markus Kiili
@Masd925
Jun 07 2017 07:34
@willcoxDev I found it easy when I stored the first and last names on two private variables.
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:35
@MonkeyRusSH you were not paying attention on the previous challenges. Goodluck for the next one.
Vaibhav Agrawal
@vaibhav1729
Jun 07 2017 07:40
function lookUpProfile(firstName, prop){
// Only change code below this line
  var flag = 0;
  var i = 0;
for(i;i<contacts.length;i++){
  if(contacts[i].firstName==firstName){
    flag = 1;
    break;
  }

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

// Only change code above this line
}
Is there any better method to do profile lookup
dragos0897
@dragos0897
Jun 07 2017 07:40
Hi everyone! I'm stuck for 1h at this topic : "Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found"." And i cant figure it out, any ideas?
Ogundele Olumide
@Lumexralph
Jun 07 2017 07:41
@Masd925 Hallo!
Markus Kiili
@Masd925
Jun 07 2017 07:41
@vaibhav1729 The simplest way is two nested if's inside the contact loop and then just the returns on correct spots.
@Lumexralph Hi.
ms-dosx86
@ms-dosx86
Jun 07 2017 07:43
@Masd925 i did it! thanks very much
function steamrollArray(arr) {
  // I'm a steamroller, baby
  var array = [];
  f(arr);
  function f(arr) {
    for (var i = 0; i < arr.length; i++) {
      if (Array.isArray(arr[i]))
        f(arr[i]);
      else 
        array.push(arr[i]);
    }
  }

  return array;
}

steamrollArray([1, [2], [3, [[4]]]]);
CamperBot
@camperbot
Jun 07 2017 07:43
ms-dosx86 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4217 | @masd925 |http://www.freecodecamp.com/masd925
Ogundele Olumide
@Lumexralph
Jun 07 2017 07:43
@dragos0897 you'll need an if statement with the help of object method hasOwnproperty to check if checkProp is a property of the object myObj then you return the value of that property and if it's not a property you return Not Found
Vaibhav Agrawal
@vaibhav1729
Jun 07 2017 07:43
then how to check firstName
@Lumexralph
Markus Kiili
@Masd925
Jun 07 2017 07:44
@ms-dosx86 You could do it without the inner function by changing the logic a bit:
function steamrollArray(arr) {
    if (Array.isArray(arr)) {
        var result = [];
        for (var i=0;i<arr.length;i++) {
            result = result.concat(steamrollArray(arr[i]));
        }
        return result;
    }
    else return arr;
}
rugano
@rugano
Jun 07 2017 07:45
Hello campers,
Markus Kiili
@Masd925
Jun 07 2017 07:45
(sniff sniff, bark) :dog: property.
Joshua Frias
@Juke-Magic
Jun 07 2017 07:47
guys can i use this?

function palindrome(str) {

var expression = /str/gi;

rugano
@rugano
Jun 07 2017 07:47
In DNA pairing,how can i create an array of arrays?an example code please,
ms-dosx86
@ms-dosx86
Jun 07 2017 07:47
@Masd925 Okay, but it works :) I understand that I chose not the most effective way. This is what I was able to implement
Joshua Frias
@Juke-Magic
Jun 07 2017 07:47
can i use the str like that?
Markus Kiili
@Masd925
Jun 07 2017 07:47
@ms-dosx86 Yours is fine too.
Vaibhav Agrawal
@vaibhav1729
Jun 07 2017 07:47
@Lumexralph , ian your case is there any need of for loop
in*
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:48
@21-Orange this will create a regex that can be used to literally find "str" in your string
Joshua Frias
@Juke-Magic
Jun 07 2017 07:48
@saifsmailbox98 how can i use the var str then?
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:48
@21-Orange I used replace to replace all non alpha-numeric characters to ""
str = str.replace(/[^a-z0-9]/gi, "");
Joshua Frias
@Juke-Magic
Jun 07 2017 07:49
@saifsmailbox98 uhmm haha sorry i dont get it :(
Hussain Haider
@HussainHaider
Jun 07 2017 07:49
Hello EveryOne!! I'm doing "Title Case a Sentence"
Joshua Frias
@Juke-Magic
Jun 07 2017 07:49
im at basic javascrript
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:50
@21-Orange you can use this then str = str.replace(/[^a-z0-9]/gi, "");
Joshua Frias
@Juke-Magic
Jun 07 2017 07:50
@saifsmailbox98 thanks but from what source did you get that?
CamperBot
@camperbot
Jun 07 2017 07:50
21-orange sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 419 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:51
@21-Orange I created it, using regex
Joshua Frias
@Juke-Magic
Jun 07 2017 07:52
@saifsmailbox98 it removes anything but the letters and numbers
Saif Ur Rahman
@saifsmailbox98
Jun 07 2017 07:52
@21-Orange yes