21st
May 2016
Keenen Garnett
@Wallyw4
May 21 2016 00:00
But how can u compare numbers produced in a for loop?
Dan Couper
@DanCouper
May 21 2016 00:02
@Wallyw4 what are you trying to do?
Wiktor
@Wkredz1
May 21 2016 00:02
if (str.charAt[str.length]==='n') will this check for N ?
Keenen Garnett
@Wallyw4
May 21 2016 00:03
I have a loop that gives me the length of strings within an array but I need to know which is the largest.
@DanCouper
Dan Couper
@DanCouper
May 21 2016 00:03
2 secs
Rafał Goławski
@rago4
May 21 2016 00:04
Keenen Garnett
@Wallyw4
May 21 2016 00:05
Find the longest word challenge
CamperBot
@camperbot
May 21 2016 00:05
find the longest word challenge
nothing found
Dan Couper
@DanCouper
May 21 2016 00:06
@Wkredz1 You’re original code was absolutely fine except for the fact that you were trying to do an impossible piece of maths. The simple version is this (you don’t need anything else, it returns true or false)
return str.substr(str.length - target.length, str.length) === target
Keenen Garnett
@Wallyw4
May 21 2016 00:06
Find the longest word in the sentence challenge
CamperBot
@camperbot
May 21 2016 00:06
find the longest word in the sentence challenge
nothing found
Keenen Garnett
@Wallyw4
May 21 2016 00:07
Idk what the bot is doing lol @rago4
Dan Couper
@DanCouper
May 21 2016 00:09
@Wallyw4 you’re basically there. There are a few ways to do it, but simplest is just push all the lengths into an array, you can use Math.max to find the largest - see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max#Examples
llamatarianism
@llamatarianism
May 21 2016 00:10
@Wallyw4 find is a bot command, like help or wiki
wiki clojure
CamperBot
@camperbot
May 21 2016 00:10

# Clojure The Basics

### Getting Started

Before we begin, you may want to install Clojure and Leiningen (which is a tool for managing projects in Clojure). This will let you run Clojure in the command line using a REPL (Read-Evaluate-Print-Loop).

llamatarianism
@llamatarianism
May 21 2016 00:10
shameless plug for my own articles
Keenen Garnett
@Wallyw4
May 21 2016 00:11
Lol oh ok
Rafał Goławski
@rago4
May 21 2016 00:11
@Wallyw4 I can send u solution if u want
@Wallyw4 cause i dont know how to explain it :D
I know but it is a little complicated :)
Keenen Garnett
@Wallyw4
May 21 2016 00:11
I don't want solution @rago4
I want to learn @rago4
Rafał Goławski
@rago4
May 21 2016 00:12
@Wallyw4
ok, first of all, you have to split your string into an array
llamatarianism
@llamatarianism
May 21 2016 00:12
@Wallyw4 each word in the sentence is separated by a space
Rafał Goławski
@rago4
May 21 2016 00:12
I guess u did that
llamatarianism
@llamatarianism
May 21 2016 00:13
you probably know how to split things on certain characters
since I think several other challenges require you to do that
Rachel Melville
@rjmelville
May 21 2016 00:13
Can anyone help me figure out why the reduce method isn't working to flatten the array of arrays?
1ety
@1ety
May 21 2016 00:14
Again: is someone can fix the following code?
Rachel Melville
@rjmelville
May 21 2016 00:14
function largestOfFour(arr) {
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr[i].length; j++){
arr[i].sort(function(a,b) { return (b-a);}).splice(1).reduce(function(a,b) { return a.concat(b);},[]);
}
}
return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Keenen Garnett
@Wallyw4
May 21 2016 00:14
Yea hold on my browser crashed @rago4
1ety
@1ety
May 21 2016 00:14

function confirmEnding(str, target) {

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

llamatarianism
@llamatarianism
May 21 2016 00:15
@1ety you're trying to subtract a string from a number
although JS is probably fine with that, because screw JS and screw loose typing
nickpuma
@nickpuma
May 21 2016 00:15
@Typhic I just finished record collection
llamatarianism
@llamatarianism
May 21 2016 00:15
str.length-target
1ety
@1ety
May 21 2016 00:15
Am I ?
I see.
Keenen Garnett
@Wallyw4
May 21 2016 00:16

function findLongestWord(str) {
var strArr = str.split(" ");
for (var t = 0; strArr.length; t++) {
return strArr[t].length;
}
}

findLongestWord("The quick brown fox jumped over the lazy dog");
@rago4
1ety
@1ety
May 21 2016 00:17
so should i have str.charAt(str.length)-target?
llamatarianism
@llamatarianism
May 21 2016 00:17
nonono
make target a number, don't make str.length into a string
substr needs numbers
Keenen Garnett
@Wallyw4
May 21 2016 00:18
that gives me 3 but i tested i t and it goes through all the indexes
llamatarianism
@llamatarianism
May 21 2016 00:18
str.length - target.length
Rafał Goławski
@rago4
May 21 2016 00:18
@Wallyw4 when you will return something once, this will escape loop
Keenen Garnett
@Wallyw4
May 21 2016 00:19
yea i did this to test and f runs through them all @rago4
function findLongestWord(str) {
var strArr = str.split(" ");
for (var t = 0; strArr.length; t++) {
var f = strArr[t].length;
while (f > 3) {
return true;
}
}
}

findLongestWord("The quick brown fox jumped over the lazy dog");
i just need to test which is larger and print it out
1ety
@1ety
May 21 2016 00:20
@llamatarianism thank you. It works.
CamperBot
@camperbot
May 21 2016 00:20
1ety sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
Rafał Goławski
@rago4
May 21 2016 00:20
for (var t = 0; strArr.length; t++)
should be
for (var t = 0; t < strArr.length; t++)
Robert Richey
@0x0936
May 21 2016 00:21
Keenen Garnett
@Wallyw4
May 21 2016 00:21
llamatarianism
@llamatarianism
May 21 2016 00:21
@1ety also, that whole if else is unnecessary.
Robert Richey
@0x0936
May 21 2016 00:21
@Wallyw4 your code only iterates once through the loop
llamatarianism
@llamatarianism
May 21 2016 00:21
@1ety you're basically writing if (maybe true) then true else false
Rafał Goławski
@rago4
May 21 2016 00:22
@Wallyw4 and instead of while I think u wanted to use if statement :)
llamatarianism
@llamatarianism
May 21 2016 00:22
@1ety you can just return the condition, because conditions like maybe true evaluate to true or false
Keenen Garnett
@Wallyw4
May 21 2016 00:22
ok so the if statment will let me test it @rago4
Rafał Goławski
@rago4
May 21 2016 00:23
This message was deleted
Keenen Garnett
@Wallyw4
May 21 2016 00:23
so like f >f.reverse maybe?
Dan Couper
@DanCouper
May 21 2016 00:24
@Wallyw4 if you’re doing it this way, have a variable for length, then update that if(?),
then return it at the end
Rafał Goławski
@rago4
May 21 2016 00:24
@Wallyw4
no, you need to check length of each array element and compare them, and get this which is the largest
Keenen Garnett
@Wallyw4
May 21 2016 00:24
could i use Math.max() at all @rago4
Dan Couper
@DanCouper
May 21 2016 00:25
@Wallyw4 you can, but if you do that, you need the lengths saved in an array to check which is the largest.
Rafał Goławski
@rago4
May 21 2016 00:26
@Wallyw4 and you need index of the largest word in array, to be able to return it
Tati
@tdoyle01
May 21 2016 00:26
I'm having issues understanding how to add a second album in terms of syntax - it isn't very clear. Anyone know?

var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}

];
Keenen Garnett
@Wallyw4
May 21 2016 00:26
the only way to get something from no array to an array is split it again @rago4
right?
Rafał Goławski
@rago4
May 21 2016 00:27
@Wallyw4 split() creates an array from string
Keenen Garnett
@Wallyw4
May 21 2016 00:28
@rago4 so i cant put these in an array to do Math.max()
Robert Richey
@0x0936
May 21 2016 00:28
with the spread operator, you can pass an array to Math.max(...array)
otherwise, the old way is Math.max.apply(null, array)
Dan Couper
@DanCouper
May 21 2016 00:29
@Wallyw4 You already have an array of words, and you are looping through that array, you’ve already done most of the work, and there is nothing stopping you pushing things into a new array: having a variable that’s an empty array, and pushing on every loop of the loop.
Keenen Garnett
@Wallyw4
May 21 2016 00:30
@DanCouper ok so i gotta figure out how to put them in a new array ok new goal thank you
CamperBot
@camperbot
May 21 2016 00:30
wallyw4 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
llamatarianism
@llamatarianism
May 21 2016 00:30
In
Keenen Garnett
@Wallyw4
May 21 2016 00:30
and once in array i can Math.max(...strArr) @DanCouper
llamatarianism
@llamatarianism
May 21 2016 00:31
bloody mobile keyboards I swear to christ
Rafał Goławski
@rago4
May 21 2016 00:31
@Wallyw4 you can do this without Math.max(),
1. split your string to an array
2. make variable max and assing to it first element of your array
3. create variable index and assign 0 to it
now we suppose that index = 0 of array is the largest word
4. do for loop like you did it and check if there is something larger than your max
if it is larger assign its value to your max, and its index to your variable index
Keenen Garnett
@Wallyw4
May 21 2016 00:32
ok @rago4 i will try that also
llamatarianism
@llamatarianism
May 21 2016 00:32
@rago4 ehhh not a fan
that relies on mutability
mutability is a crutch
Keenen Garnett
@Wallyw4
May 21 2016 00:32
if you guys are on when i figure this out ill let you know
wait what is @llamatarianism talking about
llamatarianism
@llamatarianism
May 21 2016 00:33
@Wallyw4 basically: reassigning variables is bad
Dan Couper
@DanCouper
May 21 2016 00:33
@llamatarianism it is, but using functional/immutable methods is adding in quite a bit more overhead
llamatarianism
@llamatarianism
May 21 2016 00:33
it's not terrible at this sort of scale
but creating and changing new variables and passing references around too much is bound to make your code buggy
Stephen James
@sjames1958gm
May 21 2016 00:34
@tdoyle01 The elements in an array are seperated by a comma
llamatarianism
@llamatarianism
May 21 2016 00:34
@DanCouper it's not really any more complex. IMO it's less complicated
just use map then Math.max
Dan Couper
@DanCouper
May 21 2016 00:35
Yes, I completely agree, that is the best solution by miles as well. (however, just advise using consteverywhere and watch the confused howls :smile)
Tati
@tdoyle01
May 21 2016 00:36
@sjames1958gm like this? I don't understand
var myMusic = [
{
"artist": "Billy Joel", "me",
"title": "Piano Man", "title",
"release_year": 1973, 1854,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true, false
}
];
Rafał Goławski
@rago4
May 21 2016 00:37
@llamatarianism I'm just a noobie, it passed the exam so .. :D
Norvin Burrus
@ndburrus
May 21 2016 00:37
This message was deleted
@tdoyle01 which challenge is this?
Dan Couper
@DanCouper
May 21 2016 00:39
@llamatarianism Teaching functional/declarative/immutable methods from the get-go is possibly painful though. I’d say definitely makes things much easier in the long run. I would rather there wasn’t a focus on imperative, too many footguns. I find it difficult to tell if why I think that is because I have a fair amount of experience using functional languages (or just functional style in JS) though
Tati
@tdoyle01
May 21 2016 00:39
@ndburrus Introducing JavaScript Object Notation JSON
llamatarianism
@llamatarianism
May 21 2016 00:40
@DanCouper yeah the problem is, immutability isn't really how our brains reason about stuff
we think of the world, and our code, as a bunch of stuff that changes
Rafał Goławski
@rago4
May 21 2016 00:40
@DanCouper @llamatarianism you guys think that FCC can prepare for first job as a programmer?
llamatarianism
@llamatarianism
May 21 2016 00:41
the important thing to realise is that code is not the real world, it is data, and data shouldn't change
Robert Richey
@0x0936
May 21 2016 00:41
@llamatarianism :+1:
llamatarianism
@llamatarianism
May 21 2016 00:41
if I take multiple readings from an instrument in a scientific experiment, I don't replace the old ones
@rago4 probably. it depends how much effort you put into the projects.
Norvin Burrus
@ndburrus
May 21 2016 00:41
@tdoyle01 ok, the code should follow the exact format of the example code given.... some examples that do not are: me, title, multiple years, and false... etc. see?
llamatarianism
@llamatarianism
May 21 2016 00:42
a nice portfolio of finished, well-polished projects will definitely help out
MachinistWoW
@MachinistWoW
May 21 2016 00:42

God exists 360 degrees
Like unsolved mysteries your mind's tortured by demonic beast
It's so fatal no instrumental they hit your central nervous system
You die without a funeral for real
My eyes still exist with a terror
Living without the guide of my father
Everyday is like a war we're going through
Agent orange man yo is coming after you
So get cut like ninja movie with a drama
All the way from Hong Kong straight up to China
Who needs yah chigidycheck with the mistah
The devil talkin on the fuckin speaker
You lay back you push back you turn back you pull back
Save the fuckin day like yo master kojak
As the clock tigiditac you be runnin like a maniac
You be talking shit up
Well I just think you suck

Agent Orange get up get up get up
Agent Orange come up come up come up
Agent Orange get up get up get up
Agent Orange you gotta get up yo
Agent Orange get up get up get up
Agent Orange come up come up come up
Agent Orange get up get up get up
You gotta get up yo

It's the year 99 come and don't waste time
I'm just a young man oh boy spittin rhymes
I shine the pain's penetrating to my spine
Unexplainable it can't be defined
They're hating me stabbing me playing me
Still I deal with the hate of the enemy
I'm hunted by fear when you speak and you mimic
Terrorize my mind like I'm Johnny Mnemonic
Explode like atomic deadly with the technic
Dance to a song even though without the music
So diggidy slide diggidy jump watch the way I flow
We all gonna die if you mess with the crow
So get victimized when you close your eyes
Hit one two and you mesmerize
Surprise I never tell you lies muthafucka rise
Before they televise get wise

Agent Orange get up get up get up
Agent Orange come up come up come up
Agent Orange get up get up get up
Agent Orange you gotta get up yo
Agent Orange get up get up get up
Agent Orange come up come up come up
Agent Orange get up get up get up
You gotta get up yo

I close my eyes, I close my mind, and still I burn inside [4x]
Look away, look away, and still I burn inside [4x]

Agent Orange get up get up get up
Agent Orange come up come up come up
Agent Orange get up get up get up
Agent Orange you gotta get up yo
Agent Orange get up get up get up
Agent Orange come up come up come up
Agent Orange get up get up get up
You gotta get up yo

Dan Couper
@DanCouper
May 21 2016 00:42
wtf
llamatarianism
@llamatarianism
May 21 2016 00:42
sik beatz yo
Robert Richey
@0x0936
May 21 2016 00:42
it's taken me quite a long time to appreciate immutable coding - since the language supports mutability, it takes decisive effort to not use mutable methods
Chrissy Albert
@chrissyalbert
May 21 2016 00:43
thanks @leftynaut for your help with Checkpoint: Profile Lookup
CamperBot
@camperbot
May 21 2016 00:43
chrissyalbert sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
Rafał Goławski
@rago4
May 21 2016 00:43
XD ok I need to go cause it is 2:40am in my country, thanks guys
thanks @llamatarianism ,
bye
CamperBot
@camperbot
May 21 2016 00:43
rago4 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
llamatarianism
@llamatarianism
May 21 2016 00:43
@0x0936 I'm trying to write some actual games in common lisp with minimal mutability
Robert Richey
@0x0936
May 21 2016 00:43
nice :)
llamatarianism
@llamatarianism
May 21 2016 00:43
@rago4 no prob. night!
Dan Couper
@DanCouper
May 21 2016 00:44
@0x0936 immutable.js is ok, had pretty good experience so far
llamatarianism
@llamatarianism
May 21 2016 00:44
@0x0936 planning to write minesweeper. I'll represent the board as a list of lists and use map to modify it
Norvin Burrus
@ndburrus
May 21 2016 00:44
@tdoyle01 what we are doing here is creating an additional record object that has properties... those properties need to be in the appropriate format...
llamatarianism
@llamatarianism
May 21 2016 00:44
then pass it around the state in a rescursive main function
Tati
@tdoyle01
May 21 2016 00:45
@ndburrus I just don't understand the syntax, if you could give me an example that's all I need and I'd be really grateful
Norvin Burrus
@ndburrus
May 21 2016 00:45
@tdoyle01 the code example given is very useful. can you see it?, notes: in the artist line, there is extra data ("me"), in the title line, same - extra data ("title"), etc. making more sense?
var ourMusic = [
{
"artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP" ],
"gold": true
}
];
Dan Couper
@DanCouper
May 21 2016 00:45
@tdoyle01 arrays need square brackets
was the only thing I noticed at a glance
Tati
@tdoyle01
May 21 2016 00:47
@ndburrus I added that extra data, but it's telling me it's a syntax error
Dan Couper
@DanCouper
May 21 2016 00:47
you had some stuff floating around that looked like it should be in an array, but might not be supposed to be there anyway, looking at the example, as @ndburrus says
llamatarianism
@llamatarianism
May 21 2016 00:48
@tdoyle01 stuff like gold: true, false is a syntax error
Tati
@tdoyle01
May 21 2016 00:48
@DanCouper How would I add a second artist to this object correctly?
llamatarianism
@llamatarianism
May 21 2016 00:48
@tdoyle01 each key in the object has to only have one value
Norvin Burrus
@ndburrus
May 21 2016 00:48
@tdoyle01 exactly, that is because it is extra data (data that does not comply with appropriate formatting). we need to create an entirely seperate (new) record object. it should be modelled just like the example.... :) hint: one could copy & paste the example code and insert new/changed/desired values (for the new/additional record object)... getting clearer?
llamatarianism
@llamatarianism
May 21 2016 00:49
@tdoyle01 like var ourMusic = [ { first record }, { second record } ];
Dan Couper
@DanCouper
May 21 2016 00:51
:point_up:
If you’re just trying out stuff to see what works, you’d could put it in an array, or make another property ({“second_artist”: “Baz Foobar”})
tesfie
@tesfie
May 21 2016 00:51
hi guys help me about problem with this code.

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");

Tati
@tdoyle01
May 21 2016 00:51
@DanCouper @ndburrus Ahh I was just missing the comma between the first and second albums, thank you so much!
CamperBot
@camperbot
May 21 2016 00:51
tdoyle01 sends brownie points to @dancouper and @ndburrus :sparkles: :thumbsup: :sparkles:
Norvin Burrus
@ndburrus
May 21 2016 00:53
@tdoyle01 ok, i didn't see that - the entire code wasn't posted... great work :+1:
@tesfie which challenge is that?
tesfie
@tesfie
May 21 2016 00:53
what is worng with this one
Dan Couper
@DanCouper
May 21 2016 00:54
@tdoyle01 this is the entire spec for JSON (it’s just a hundred or so words + 5 diagrams), it shows you what you can and can’t use
http://www.json.org/
tesfie
@tesfie
May 21 2016 00:54

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");

@ndburrus
Tati
@tdoyle01
May 21 2016 00:54
@DanCouper Thanks, I'll definitely take a look!
CamperBot
@camperbot
May 21 2016 00:54
tdoyle01 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:warning: tdoyle01 already gave dancouper points
Norvin Burrus
@ndburrus
May 21 2016 00:54
@tesfie ok, we need to build a complete sentence... what is the challenge name? it looks like there need to be some spaces in the sentence...
tesfie
@tesfie
May 21 2016 00:55
Word Blanks @ndburrus
Norvin Burrus
@ndburrus
May 21 2016 00:56
@tesfie ok, what sentence are you building? right now, the sentence would be: dogbigranquickly - no spaces or punctuation/s. see that? further, this is not a complete sentence...
tesfie
@tesfie
May 21 2016 00:57
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib)
Rahul Jangid
@rjcool9
May 21 2016 00:57
@tesfie we should also provide a additonal string at start
tesfie
@tesfie
May 21 2016 00:57
where @rjcool9
Rahul Jangid
@rjcool9
May 21 2016 00:57
at start
tesfie
@tesfie
May 21 2016 00:58
could u please tell me how @rjcool9
Rahul Jangid
@rjcool9
May 21 2016 00:58
in result just add one more string
Norvin Burrus
@ndburrus
May 21 2016 00:58
@tesfie you could start by making a complete sentence using the variables given (myNoun, myAdjective, etc.) ... ...such as "The big dog ran quickly." Next, build that result string (ensuring spaces & punctuation are included).... :) making sense?
tesfie
@tesfie
May 21 2016 00:59
i didn't get u @ndburrus
Rahul Jangid
@rjcool9
May 21 2016 01:01
declare an aditonal variable in function worldbank and set it to "the" .and then add it to result
@tesfie
Norvin Burrus
@ndburrus
May 21 2016 01:02
@tesfie ...do we still have a pulse?
tesfie
@tesfie
May 21 2016 01:02
ok i will try
Norvin Burrus
@ndburrus
May 21 2016 01:02
@tesfie ok, great...
tesfie
@tesfie
May 21 2016 01:02
sure
Norvin Burrus
@ndburrus
May 21 2016 01:03
@tesfie a var/iable may be useful in building the string - to hold the pieces (words) as they are being added.... how is it going? ok... is what you're doing making sense?
tesfie
@tesfie
May 21 2016 01:10
nothing i am still try it
@ndburrus
Joseph
@revisualize
May 21 2016 01:13
YO!
@tesfie Oh, I just saw your code. You're missing spaces.
@tesfie + " " + see the space in between the "s?
@tesfie Also the variable is result not string.result.
DwayneCode
@DwayneCode
May 21 2016 01:16
@tdoyle01 add a comma after true, proceed to enter the details of the second album
Chris Cullen
@123xylem
May 21 2016 01:31
I want my results to reset after each search and I want my search Items to be listed in a more comparted way (have their own space)... Any ideas or links to use?! http://codepen.io/123xylem/pen/aNxREJ?editors=1011
Joseph
@revisualize
May 21 2016 01:33
Xavier
@zayy862
May 21 2016 01:35
how do you add images to the chat room?
I'm supposed to get 3rd party confirmation before I report this bug I found in the website
anudelman
@anudelman
May 21 2016 01:36
Having trouble with lookup tables. How do I assign the associated string of val to result variable?
tommy
@tommygebru
May 21 2016 01:37
anyone want to pair program the intermediate challenges? :smile_cat:
anudelman
@anudelman
May 21 2016 01:38

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

// Only change code below this line
var lookup = {

bravo:"Boston",
charlie: "Chicago",
delta: "Denver",
echo: "Easy",
foxtrot: "Frank"

};

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

// Change this value to test
phoneticLookup();
Kelly Kovalcik
@kellykov
May 21 2016 01:39
Can someone help me with Local Scope and Functions please?
Xavier
@zayy862
May 21 2016 01:39
what's the issue you are having @kellykov ?
Norvin Burrus
@ndburrus
May 21 2016 01:41
@kellykov basically, the lesson is informing us that variables created within a function have a scope that valid only within that function (this is what is being referred to as local scope)... make sense?
Diego Mayer
@Chrono79
May 21 2016 01:41
@anudelman use val as lookup property and assign that to result
Xavier
@zayy862
May 21 2016 01:43
how fast did it take you guys to complete the front web cert? Those that have.
Norvin Burrus
@ndburrus
May 21 2016 01:45
@anudelman which challenge is this? alright, got it
Kelly Kovalcik
@kellykov
May 21 2016 01:45
@zayy862 I'm just stuck in general I'm not quite sure what I'm doing wrong
@ndburrus Okay yes thank you
CamperBot
@camperbot
May 21 2016 01:45
kellykov sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Norvin Burrus
@ndburrus
May 21 2016 01:46
@kellykov ok, does it make a little sense? all that is need is the creation of a var/iable within the function. this makes it a local variable.... the variable myVar is given to create.
Kelly Kovalcik
@kellykov
May 21 2016 01:49
Yeah I think that helped me understand the idea, I'm just not sure what I'm doing wrong in the process
This is what I have:
function myLocalScope() {
var myVar ="";
console.log(myVar);
}
myLocalScope();
console.log(myVar);
@ndburrus
Norvin Burrus
@ndburrus
May 21 2016 01:50
@kellykov alright - good start... did we want the variable to be empty?
Kelly Kovalcik
@kellykov
May 21 2016 01:50
@ndburrus I'm not sure what to make the value
Norvin Burrus
@ndburrus
May 21 2016 01:51
Kelly Kovalcik
@kellykov
May 21 2016 01:51
@ndburrus Oh so I can just make it anything?
Norvin Burrus
@ndburrus
May 21 2016 01:52
@kellykov try it... and then remember to follow the comment/s: "// now remove the console log line to pass the test"
Kelly Kovalcik
@kellykov
May 21 2016 01:53
@ndburrus Okay. Thanks again for the help :)
CamperBot
@camperbot
May 21 2016 01:53
kellykov sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: kellykov already gave ndburrus points
Norvin Burrus
@ndburrus
May 21 2016 01:53
@kellykov did it pass?
Kelly Kovalcik
@kellykov
May 21 2016 01:53
@ndburrus Yes :)
Norvin Burrus
@ndburrus
May 21 2016 01:53
@kellykov you're welcome... great work! :+1:
Islam Ibakaev
@dagman
May 21 2016 01:54
oh guys i'm so tired... spend a lot of time working on my new portfolio.
what do you think? try it under 480. need you feedback.
http://codepen.io/dagman/pen/wGZLWv
Kelly Kovalcik
@kellykov
May 21 2016 01:57
It looks great. The animations are awesome @dagman
Islam Ibakaev
@dagman
May 21 2016 01:57
@kellykov thx happy to hear it :smile:
CamperBot
@camperbot
May 21 2016 01:57
dagman sends brownie points to @kellykov :sparkles: :thumbsup: :sparkles:
Greg Duncan
@GregatGit
May 21 2016 01:59
@dagman Looks brilliant! My young daughter just happened to walk in the room as your page loaded and commented "Woah - that looks so cool!" Great work
Joseph
@revisualize
May 21 2016 01:59
@anudelman You're not modifying result.
May 21 2016 02:02
@dagman hey it's actually a little too busy for me. I don't like the slow pace of the Bio - I want to read at my own pace; as a potential client browsing dev websites, I'd probably close it because it's too much time waiting for it to load. The pulsating of "About" is hard on my eyes as well. This may all be a personal preference, but I thought I'd share my opinion. You clearly used some good tools and have a handle on animation, so that's a plus; but yeah it's a little too much for me.
Krishna Sahu
@dvlprkrishna
May 21 2016 02:03
help
Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.
Note that inserting the three dots to the end will add to the string length.
However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.
what i dont understand is after str length is less than or equal to 3 what does that mean?
Islam Ibakaev
@dagman
May 21 2016 02:04
CamperBot
@camperbot
May 21 2016 02:04
dagman sends brownie points to @gregatgit and @radascript :sparkles: :thumbsup: :sparkles:
Islam Ibakaev
@dagman
May 21 2016 02:04
i was just trying to make it look non-trivial
Allan
@gitlucen
May 21 2016 02:06

Hi guys, good day. Anyone familiar with the "Smallest Common Multiple" challenge?

#291.

does it require a limited time to output the result?

on my unit test I get the correct results although it takes around 5min to output larger results XD

May 21 2016 02:07
@Kripsahu it means that if the string is short (<=3), it wants you to chop off the number that it says and then add the dots. If it's long, it wants you to chop off the number, then replace the last three slots with dotdotdot

so like ("123456789", 2) should end up being "1234..."

but ("123", 2) should end up being "1..."

@gitlucen yeah I was stuck on that one for a while. I don't think there's technically a time limit, if your browser isn't freaking out, but some solutions are more elegant than others.
Krishna Sahu
@dvlprkrishna
May 21 2016 02:11
CamperBot
@camperbot
May 21 2016 02:11
kripsahu sends brownie points to @radascript :sparkles: :thumbsup: :sparkles:
Allan
@gitlucen
May 21 2016 02:11
@Radascript, thanks , a little more speed tweak then :D
CamperBot
@camperbot
May 21 2016 02:11
gitlucen sends brownie points to @radascript :sparkles: :thumbsup: :sparkles:
Peter Weinberg
@no-stack-dub-sack
May 21 2016 02:24
Hey guys, what am I missing here? I solved this recursively yesterday, but wanted to make sure I could do it iteratively as well and am not passing the last test - although, not sure why 0 factorialized should equal 1 anyway?

function factorialize(num) {
var fac = num;
while (num > 1) {
fac = fac * (num-1);
num--;
}
return fac;
}

factorialize(10);
This is the Factorialize a Number basic algorithm challenge
rkDeason
@rkDeason
May 21 2016 02:27
@no-stack-dub-sack prbly need to add the if condition for when num is 0
prbly just one of those crazy math definitions LOL
Peter Weinberg
@no-stack-dub-sack
May 21 2016 02:28
@rkDeason ok... i'll try that, thanks
CamperBot
@camperbot
May 21 2016 02:28
no-stack-dub-sack sends brownie points to @rkdeason :sparkles: :thumbsup: :sparkles:
rkDeason
@rkDeason
May 21 2016 02:28
u welcome @no-stack-dub-sack ! hope it works!
Peter Weinberg
@no-stack-dub-sack
May 21 2016 02:29
Yeah, it's strange. Am I wrong, or crazy? shouldn't the factorial of 0 be 0? I was never a math whiz so maybe I'm off
May 21 2016 02:29
@no-stack-dub-sack factorial of 0 is 1
@no-stack-dub-sack it's done that way to satisfy some math frameworks I believe
@no-stack-dub-sack like factorial is usually used in combinatorics
Peter Weinberg
@no-stack-dub-sack
May 21 2016 02:30
@Radascript how that makes sense is beyond me.... why??? Actually, you're bringing back some 8th grade memories - I seem to recall my teacher saying it made no sense but that we had to accept it haha
May 21 2016 02:30
@no-stack-dub-sack if factorial of 0 was 0, then a lot of calculations of combinatorics would be off
@no-stack-dub-sack oversimplified way of understanding it is that in combinatorics you use it to say that there is only 1 way to arrange 0 elements
@no-stack-dub-sack rather than 0 ways
Peter Weinberg
@no-stack-dub-sack
May 21 2016 02:32
@Radascript so even though something make zero sense, we force it to make the environment around us work. Human ingenuity, love it.
@Radascript I guess that makes sense. Anyway, solved it! Thanks @rkDeason & @Radascript!
function factorialize(num) {
var fac = num;
if (num === 0) {
return num +=1;
}
while (num > 1) {
fac = fac * (num-1);
num--;
}
return fac;
}

factorialize(10);
CamperBot
@camperbot
May 21 2016 02:33
no-stack-dub-sack sends brownie points to @radascript and @rkdeason :sparkles: :thumbsup: :sparkles:
:warning: no-stack-dub-sack already gave rkdeason points
May 21 2016 02:33
@no-stack-dub-sack you welcome! But yeah I mean it's definitely unintuitive but at the same time like
Camille Garcia
@camgarcia53
May 21 2016 02:33
Hello
May 21 2016 02:34
as opposed to say, addition and subtraction that have very clear physical representations
Camille Garcia
@camgarcia53
May 21 2016 02:34
I'm having trouble with the Stand in Line problem
May 21 2016 02:34
factorial was created as a tool
Camille Garcia
@camgarcia53
May 21 2016 02:34
Here is my code so far

function nextInLine(arr, item) {
function queue(arr, item) {

arr.push(item);
return arr.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([], 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

return item; // Change this line
}

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

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

May 21 2016 02:35
Help Format
CamperBot
@camperbot
May 21 2016 02:35

# Multi line Code

js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

 ⇦ Type 3 backticks, then press [enter ⏎]

# Single line Code

This an inline <paste code here> code formatting with a single backtick() at _start_ and _end_ around thecode.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

May 21 2016 02:35
function nextInLine(arr, item) {
function queue(arr, item) {

arr.push(item);
return arr.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([], 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
@camgarcia53 once you return, your function stops running
you don't need to write a function within a function for this challenge
and you just need one return
I see you are trying to use console.log to check what your array looks like atm
you are better off console.logging throughout your code
tommy
@tommygebru
May 21 2016 02:39
Camille Garcia
@camgarcia53
May 21 2016 02:39
@Radascript so i can erase the first function?
May 21 2016 02:39
function nextInLine(arr, item) {
console.log("Array before pushing is "+ arr);
arr.push(item);
console.log("Array after pushing is "+ arr);
return arr.shift();

}
tommy
@tommygebru
May 21 2016 02:40
May 21 2016 02:40
@tommygebru does what work? I'm trying to help Camille
Norvin Burrus
@ndburrus
May 21 2016 02:41
@camgarcia53 ...use testArr in this line...
console.log(nextInLine([], 1)); // Modify this line to test
May 21 2016 02:41
Hello guys
Norvin Burrus
@ndburrus
May 21 2016 02:41
hi wellington
May 21 2016 02:41
Help me in Word Blanks
CamperBot
@camperbot
May 21 2016 02:41
no wiki entry for: me in word blanks
Norvin Burrus
@ndburrus
May 21 2016 02:41
@DrNadson ok, do you have a sentence you'd like to build?
rkDeason
@rkDeason
May 21 2016 02:41
good job @no-stack-dub-sack ! :)
May 21 2016 02:42
Hi @ndburrus
Norvin Burrus
@ndburrus
May 21 2016 02:42
May 21 2016 02:43

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");

* should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
Norvin Burrus
@ndburrus
May 21 2016 02:44
@DrNadson ok, what sentence (madlib) would you like to build? the sentence should contain all the elements provided (basically a noun, adjective, verb, & adverb).
May 21 2016 02:45
@DrNadson do you understand what it wants from you?
May 21 2016 02:46
Not exactly
I know that wordBlanks should return ("dog", "big", "ran", "quickly")
rkDeason
@rkDeason
May 21 2016 02:48
@DrNadson things you will need: the argument names + spaces + the period at end
May 21 2016 02:48
rkDeason
@rkDeason
May 21 2016 02:49
@DrNadson It makes a sentence out of the words.
Tati
@tdoyle01
May 21 2016 02:49
How do I access the values in this JSON object? I'm getting this error: TypeError: Cannot read property 'ABBA' of undefined
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

if (collection[id][prop][value] !== "" && collection[id][prop] !== "tracks") {
collection[id][prop][value]  = value;
} else if (collection[id][prop][value]  !== "" && collection[id][prop] === "tracks") {
collection[id][prop].push(value);
} else if (collection[id][prop][value] === "") {
delete collection[id][prop];
}

return collection;
}
May 21 2016 02:52
@camgarcia53 just erase the outer wrapped function; it's redundant, then it passes
Camille Garcia
@camgarcia53
May 21 2016 02:52
@Radascript ok thank you for the help
CamperBot
@camperbot
May 21 2016 02:52
camgarcia53 sends brownie points to @radascript :sparkles: :thumbsup: :sparkles:
May 21 2016 02:53
@camgarcia53 you should just have
function nextInLine(arr, item) {blablabla}
rather than
function nextInLine(arr, item) {function nextInLine(arr, item) {blablabla}}
@camgarcia53 you are welcome happy coding
Norvin Burrus
@ndburrus
May 21 2016 02:55
@tdoyle01 ok, the way the code is attempting to access values is incorrect. the key/s lead to accessing the value/s. hint: one doesn't need to indicate value (as a reference) to access value
May 21 2016 02:56
@tdoyle01 hey - first, I think most of your logic statements don't need the last bit with [value] since you are trying to see if there is such and such property
Tati
@tdoyle01
May 21 2016 02:56
@ndburrus @Radascript Is this right? It's not accomplishing the correct tasks though.
  if (collection[id][prop] !== "" && collection[id] !== "tracks") {
collection[id][prop]  = value;
} else if (collection[id][prop]  !== "" && collection[id] === "tracks") {
collection[id].push(value);
} else if (collection[id][prop] === "") {
delete collection[id];
}
May 21 2016 02:58
@tdoyle01 I gotta jet for a bit but if you haven't solved your issue when I'm back I'll take a look, @ndburrus probably got it though. GL
Norvin Burrus
@ndburrus
May 21 2016 02:58
@tdoyle01 hmmm... the 1st else if statement doesn't appear to mirror (match) the logic in the requirement. the code logic (for the second condition requirement) says - else if prop is not blank & id is equal to tracks.... the second requirement wants: if prop is TRACKS & VALUE is not blank... getting clearer?
May 21 2016 03:02
@Radascript , @rkDeason and @ndburrus , thanks for yours help. (y)
CamperBot
@camperbot
May 21 2016 03:02
drnadson sends brownie points to @radascript and @rkdeason and @ndburrus :sparkles: :thumbsup: :sparkles:
rkDeason
@rkDeason
May 21 2016 03:03
Norvin Burrus
@ndburrus
May 21 2016 03:03
@DrNadson you're welcome...did you get it?
May 21 2016 03:03
I found the solution
Norvin Burrus
@ndburrus
May 21 2016 03:03
@DrNadson excellent! kudos to you!! :+1:
@tdoyle01 how are we doing?
Chris Cullen
@123xylem
May 21 2016 03:04
QUick Question: Why is my $output.empty(); function not emptying previous search results!?http://codepen.io/123xylem/pen/aNxREJ?editors=1111 Wellington Nadson @DrNadson May 21 2016 03:04 within the function is assigned to a variable Tati @tdoyle01 May 21 2016 03:05 @ndburrus I was trying to say when the property is not equal to "tracks"...I am not completely clear on how to access the property, I assumed it would be collections[id] but I now realize that doesn't quite make sense. However, collections[id][prop] seems like it would access the value within the property. Norvin Burrus @ndburrus May 21 2016 03:06 @tdoyle01 you are totally correct! so, can we update and post code? Tati @tdoyle01 May 21 2016 03:07 @ndburrus But I want to access the property, not the value, so doesn't collections[id][prop] not make sense? Here's what I have now, though function updateRecords(id, prop, value) { if (collection[id][prop] !== "" && collection[id] !== "tracks") { collection[id][prop] = value; } else if (collection[id][prop] !== "" && collection[id][prop] === "tracks") { collection[id][prop].push(value); } else if (collection[id] === "") { delete collection[id]; } return collection; } Jarod Spiewak @Memj May 21 2016 03:09 Can someone help me with the logic of my function? I'm working on the Twitch API and I'm trying to loop through my array and assign an ID to each channels div with the name of the channel. However, it's assigning the same ID to all of the elements... http://codepen.io/memj/pen/XdqEYq Norvin Burrus @ndburrus May 21 2016 03:09 @tdoyle01 ok, maybe i erred... why not use the logic, as it is given. let's start with: "If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop." we can use prop & value right from the input variables...to drive the conditions. next, when the conditions are met, we can use the properties to identify values to be changed... Samuel Palmeira @Inginex May 21 2016 03:09 @123xylem try to do this  if (searchTerm==''){ }else { // your code }  Tati @tdoyle01 May 21 2016 03:13 @ndburrus That first one seems to be working - it passes the test. However, I'm working on the next one, and I'm having issues finding the errors in my logic. Norvin Burrus @ndburrus May 21 2016 03:14 @tdoyle01 ok, lets see the second conditional.... to see what's going on.. can you post the second conditional? Tati @tdoyle01 May 21 2016 03:15 @ndburrus If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array. So I have } else if (collection[id][prop] !== "" && collection[id] === "tracks") { collection[id][prop].push(value); I think I am misunderstanding how the object is accessed. collection[id] should go within the given id, but how does it know which prop it's dealing with when comparing to "tracks"? Samuel Palmeira @Inginex May 21 2016 03:15 @Memj try it : var userName = '<div class="user" id="'+ channel +'"><p class="text">' + channel + '</p></div>' Kevin Schwert @kevinpschwert May 21 2016 03:16 Having trouble understanding the Make Object Properties Private exercise. This is what I have so far: var Car = function() { // this is a private variable var speed = 10; // these are public methods this.accelerate = function(change) { speed += change; }; this.decelerate = function() { speed -= 5; }; this.getSpeed = function() { return speed; }; }; var Bike = function() { // Only change code below this line. var gear = 0; this.getGear = function(shift) { gear += shift; }; this.setGear = function() { return gear; }; }; var myCar = new Car(); var myBike = new Bike(); Norvin Burrus @ndburrus May 21 2016 03:16 @tdoyle01 ok, why are we changing the way we set the conditions? We were using prop & value (indeed, the instructions also use these condition drivers). are these no longer worthy tools for us? Tati @tdoyle01 May 21 2016 03:17 @ndburrus But I am using prop and value? I'm confused Norvin Burrus @ndburrus May 21 2016 03:19 @tdoyle01 ok, we are keying off of the input variables.... we are going to make decisions/set actions based on what the input variables are.... the input variables are simply id, prop & value. Tati @tdoyle01 May 21 2016 03:21 @ndburrus Oh man you're so right, I don't even need to be accessing within the JSON object Norvin Burrus @ndburrus May 21 2016 03:21 @tdoyle01 you, are on fire !! :fire: ok, so can we code the second conditional (and resultant action)? Islam Ibakaev @dagman May 21 2016 03:21 Tati @tdoyle01 May 21 2016 03:22 @ndburrus Now that I realized that, I solved the whole thing in a minute. Thank you for your help, can't believe that I was that far down the wrong path! CamperBot @camperbot May 21 2016 03:22 tdoyle01 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles: :cookie: 383 | @ndburrus |http://www.freecodecamp.com/ndburrus Norvin Burrus @ndburrus May 21 2016 03:23 @tdoyle01 lol... you're very welcome! kudos to you.... great work :sparkles: Kevin Schwert @kevinpschwert May 21 2016 03:23 I flipped the this.setGear and this.getGear and I have gotten one correct answer but not the others: var Car = function() { // this is a private variable var speed = 10; // these are public methods this.accelerate = function(change) { speed += change; }; this.decelerate = function() { speed -= 5; }; this.getSpeed = function() { return speed; }; }; var Bike = function() { // Only change code below this line. var gear = 0; this.setGear = function(shift) { gear += shift; }; this.getGear = function() { return gear; }; }; var myCar = new Car(); var myBike = new Bike(); Kimberly Pennington @kimberlythegeek May 21 2016 03:25 Has anyone else had problems with Basic Algorithmic Scripting > Repeat a string repeat a string? Jarod Spiewak @Memj May 21 2016 03:26 @Inginex Thanks! CamperBot @camperbot May 21 2016 03:26 memj sends brownie points to @inginex :sparkles: :thumbsup: :sparkles: :cookie: 306 | @inginex |http://www.freecodecamp.com/inginex Kimberly Pennington @kimberlythegeek May 21 2016 03:26 I'm getting the correct output but it isn't counting as correct for some reason. Greg Duncan @GregatGit May 21 2016 03:27 @kimberlythegeek if there is the smallest typo difference it won't pass Samuel Palmeira @Inginex May 21 2016 03:27 @Memj :smile: Greg Duncan @GregatGit May 21 2016 03:28 @kimberlythegeek so if the answer is meant to be 'hello.' and 'hello' it will be wrong. Copy and paste your answer and the expected answer in notepad to see if there is any difference Kimberly Pennington @kimberlythegeek May 21 2016 03:29 Hm. I'll check again. For the test "abc",3 it came out abcabcabc. I'll try copy + paste and see if that works. @GregatGit yeah, I dunno. it's all printing correctly. repeatStringNumTimes("cow", 5); returns cowcowcowcowcow guess i'll figure it out later; Kevin Schwert @kevinpschwert May 21 2016 03:33 Did anyone get the code that I printed and need help on? Kimberly Pennington @kimberlythegeek May 21 2016 03:34 lol. think I've been doing this too long today... I just ended my sentence with a semicolon..... what output are you getting @kevinpschwert which ones are incorrect I think I see the problem Kevin Schwert @kevinpschwert May 21 2016 03:35 It says that when I call myBike.setGear(4) I get the correct answer but when I call myBike.setGear(3) and myBike.setGear(1) I get the wrong ones. But when I call myBike.setGear(3) it outputs 3. Kimberly Pennington @kimberlythegeek May 21 2016 03:36 when you setGear(), this.gear = newGear or shift, whatever you call it. you're not adding to it, you're setting a new value try that and see if that works? Miguel Asse @cubang8r May 21 2016 03:37 Hey Free Code Campers, stuck on the "Four Largest Numbers Function". I want to shift the first values off of each sub-array since I've gotten them sorted  function largestOfFour(arr) { // You can do this! for(var i = 0; i < arr.length; i++){ arr[i] = arr[i].sort(function(a, b){ return b - a; }); } return arr; } largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); Should I be thinking about putting the push as part of the first sort function? Greg Duncan @GregatGit May 21 2016 03:37 @kimberlythegeek I just had a look - it looks like a bug Miguel Asse @cubang8r May 21 2016 03:38 Or should I do a second for loop and think about iterating through that way? Kimberly Pennington @kimberlythegeek May 21 2016 03:38 @GregatGit okay cool, haha. glad I didn't bang my head too long for that one :) @cubang8r when you return b - a; you will be ending the function return is the end of a function's iteration and you need to return a set of the largest numbers. so an array containing the largest from each sub-array Miguel Asse @cubang8r May 21 2016 03:40 @kimberlythegeek how do you go about making sure it sorts in descending order without the return? regardless - thanks for the advice! Kimberly Pennington @kimberlythegeek May 21 2016 03:40 perhaps you could use a placeholder variable Miguel Asse @cubang8r May 21 2016 03:41 thanks @kimberlythegeek CamperBot @camperbot May 21 2016 03:41 cubang8r sends brownie points to @kimberlythegeek :sparkles: :thumbsup: :sparkles: :cookie: 132 | @kimberlythegeek |http://www.freecodecamp.com/kimberlythegeek Kimberly Pennington @kimberlythegeek May 21 2016 03:42 @cubang8r no problem :) bleujai @bleujai May 21 2016 03:50 hey Kimberly. I saw you said you've been doing this too long today. How long have you been in the chat room today? Are you completing the FCC curriculum? I'm fairly far along and thinking of taking time each day to help people with problems they have. Thompson Ike @hubhubace May 21 2016 03:53 hi room bleujai @bleujai May 21 2016 03:53 hey @hubhubace Thompson Ike @hubhubace May 21 2016 03:53 please why is this not passsing? function testElse(val) { var result = ""; // Only change code below this line if (val > 5 || val <= 5) { result = "Bigger than 5"; } else result = "5 or Smaller"; // Only change code above this line return result; } error testElse(4) should return "5 or Smaller" testElse(5) should return "5 or Smaller" Christopher Aguilar @chrisaguilar May 21 2016 03:54 @hubhubace You're missing a bracket after else and before return result; Thompson Ike @hubhubace May 21 2016 03:55 when i put the bracket it shows red alert but i try again bitgrower @bitgrower May 21 2016 03:55 I don't think it's actually needed, if you have just 1 line Christopher Aguilar @chrisaguilar May 21 2016 03:55 @bitgrower You're right, I always forget that works. 96street @96street May 21 2016 03:55 Trying to change the size(padding) of my nav when I scroll down, why isn't this code working? http://codepen.io/anon/pen/pyXBqL Thompson Ike @hubhubace May 21 2016 03:56 so what could be my setback? bitgrower @bitgrower May 21 2016 03:56 however, you are checking for both conditions in your first if statement, but returning "Bigger than 5" for either one ... so ... you are either returning "Bigger than 5" or result = "" you're never returning "5 or smaller" message Christopher Aguilar @chrisaguilar May 21 2016 03:57 Yeah you're basically saying "if value is greater than five or less than or equal to five" which is like ... every number bitgrower @bitgrower May 21 2016 03:58 exactly ! Thompson Ike @hubhubace May 21 2016 03:59 do i change the operand? Oh my Js lol not gonna quit now bitgrower @bitgrower May 21 2016 04:00 so ... pseudocode might be something like ... if val is greater than 5, return bigger than 5 message else return 5 or less message you just need to not look for <= equal -- just check if it's bigger than 5 ... anything else, by definition is going to be 5 or less ... eh ? Thompson Ike @hubhubace May 21 2016 04:01 so the || should o? bitgrower @bitgrower May 21 2016 04:01 you don't need the or at all you don't need that full expression ... you just need the > 5 part Christopher Aguilar @chrisaguilar May 21 2016 04:01 You don't really need it, to be honest. You just need to check if the value is greater than five Thompson Ike @hubhubace May 21 2016 04:02 ok let me see bitgrower @bitgrower May 21 2016 04:03 I haven't looked at that problem recently, but if there are only 2 possible returns, a simple (not compound) conditional statement is all you need in the if statement ... very simply: just remove everything in the conditional starting with the || Thompson Ike @hubhubace May 21 2016 04:03 ok bleujai @bleujai May 21 2016 04:03 @hubhubace The || in this case checks both sides and says that if either is true then it should do what is in the curly braces following. Thompson Ike @hubhubace May 21 2016 04:03 and @bleujai ok bitgrower @bitgrower May 21 2016 04:04 and ... nothing ... just remove the part of the conditional starting with the || Thompson Ike @hubhubace May 21 2016 04:04 @bitgrower ok will do now @bitgrower wow bleujai @bleujai May 21 2016 04:05 Like someone else said, it can be helpful to think of a problem on paper first or verbally. Some call it pseudo coding. Thompson Ike @hubhubace May 21 2016 04:05 @bleujai yeah bleujai @bleujai May 21 2016 04:05 Once you have an idea what you need to do then you can transfer it to the program. Thompson Ike @hubhubace May 21 2016 04:05 one sinle change all wAs done why was that? why only one conditional? bitgrower @bitgrower May 21 2016 04:06 how long have you been working on this today, @hubhubace ? Thompson Ike @hubhubace May 21 2016 04:06 i need to understand mpore @bitgrower i was on it last night just wokle up now ang dgot back bitgrower @bitgrower May 21 2016 04:07 you don't need the OR ( || ) because it includes ALL numbers, the way you have it stated ... Thompson Ike @hubhubace May 21 2016 04:07 yes bitgrower @bitgrower May 21 2016 04:07 ELSE behaves "like" an || -- only delayed ... Thompson Ike @hubhubace May 21 2016 04:08 but also i see i dont need the condition if val <= 5; bitgrower @bitgrower May 21 2016 04:08 If it's A -- do this if it's not A do that if it's A do this else do that those 2 lines will give you identical results ... because, by definition of mathematics, if it's NOT greater than 5, it's 5 or less ... This message was deleted Andrew Johnston @puchamungee May 21 2016 04:09 ‘’’js function nextInLine(arr, item) { // Your code here testArr.push(item); var returnFromArray = testArr.shift(item); return returnFromArray; } // Test Setup var testArr = [5,6,7,8,9]; // Display Code console.log("Before: " + JSON.stringify(testArr)); console.log(nextInLine(testArr, 1)); // Modify this line to test console.log("After: " + JSON.stringify(testArr)); anyone mind helping me out? stuck on the stand in line problem bitgrower @bitgrower May 21 2016 04:09 so if it's one, it can't be the other if it's the other, it can be the first @puchamungee -- I would HIGHLY recommend reviewing the previous 4 javascript challenges on the array functions of .push .pop .shift and .unshift tommy @tommygebru May 21 2016 04:10 @puchamungee dont use testArr bitgrower @bitgrower May 21 2016 04:10 you need 2, and only 2 of those functions ... bleujai @bleujai May 21 2016 04:10 @puchamungee where do you have testArr defined? bitgrower @bitgrower May 21 2016 04:11 yeah, that too ... don't use testArr (it's a global, @bleujai Thompson Ike @hubhubace May 21 2016 04:12 @bitgrower so any global we dont use in our code? bitgrower @bitgrower May 21 2016 04:12 not if they are passing it as a parameter to the function you are to modify ... Thompson Ike @hubhubace May 21 2016 04:12 ok bitgrower @bitgrower May 21 2016 04:12 in general GLOBALS ARE TO BE AVOIDED Thompson Ike @hubhubace May 21 2016 04:12 yep noted bitgrower @bitgrower May 21 2016 04:13 they use some in a few of the challenges, but it's very problematic to use them in production ... Andrew Johnston @puchamungee May 21 2016 04:14 @bitgrower Thanks! I was just going off of the problem they were giving me, but I’ll try your suggestions CamperBot @camperbot May 21 2016 04:14 puchamungee sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles: :star2: 1058 | @bitgrower |http://www.freecodecamp.com/bitgrower bitgrower @bitgrower May 21 2016 04:14 ...but especially if they are defining a global, then calling the function you are to modify with that global variable, you should be using the parameter passed to you in the function ... Thompson Ike @hubhubace May 21 2016 04:14 @tommygebru you use .push(item) and return.shift() bitgrower @bitgrower May 21 2016 04:14 not exactly, @hubhubace Thompson Ike @hubhubace May 21 2016 04:14 oh please explain i did so and it worked i want to understand fully bitgrower @bitgrower May 21 2016 04:15 return.shift() <-- you are probably mis-remembering ... that would give you an error Thompson Ike @hubhubace May 21 2016 04:16 i know .shft() removes first element and returns what is removed riht? @bitgrower pls fill me in bitgrower @bitgrower May 21 2016 04:17 lol, that information can be, and should be, confirmed via MDN, probably not the best to rely on other programmer's memories ... if I am in the least doubt, that's where I go ... Thompson Ike @hubhubace May 21 2016 04:19 so what is the explanation on that problem? bitgrower @bitgrower May 21 2016 04:19 ...the value of that practice is to get better and better at knowing and being comfortable using various functions ... For instance, there is no way I remember all the parameters that can be passed in a callback function in those functions that take them (like .sort, .filter, etc.) buckshot307 @buckshot307 May 21 2016 04:19 hey guys, I'm working on the simon says project and really stuck with how to get the buttons to light up. Any hints, tips or advice? bleujai @bleujai May 21 2016 04:19 @bitgrower brings up a good point. Many times it's worth it to double check your thoughts about a function that you think you remember well. bitgrower @bitgrower May 21 2016 04:20 @hubhubace -- that's not quite precisely the purpose of this room ... you can get hints and explanations of solutions in the FCC wiki ... help stand in line CamperBot @camperbot May 21 2016 04:20 ## :point_right: challenge stand in line [wiki] # Challenge Stand In Line About queues In Computer Science a queue is an abstract Data Structure_ where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the _queue. Instructions Write a function nextInLine which takes an "array" and an "item" as arguments. Add the item onto the end of the array, then remove the first element of the array. The nextInLine function should return the element that was removed. Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code. thinnling @thinnling May 21 2016 04:20 I feel like 'Counting Cards' was not explained very clearly. I had to find the solution online and there would be no way for me to figure it out on my own. buckshot307 @buckshot307 May 21 2016 04:21 I have the classes set and can get the first one to light up by calling it directly, but not sure how to iterate through the array I generate bitgrower @bitgrower May 21 2016 04:21 thanks, @bleujai ... :) I mean, if I haven't used .split in a while, I usually have to check to make sure I'm giving it the right parameter, or .sort, to make sure I'm sorting like I want ... CamperBot @camperbot May 21 2016 04:21 bitgrower sends brownie points to @bleujai :sparkles: :thumbsup: :sparkles: :cookie: 338 | @bleujai |http://www.freecodecamp.com/bleujai Thompson Ike @hubhubace May 21 2016 04:21 ok buckshot307 @buckshot307 May 21 2016 04:21 @thinnling I found that one pretty easy, but I've struggled on quite a few others Thompson Ike @hubhubace May 21 2016 04:22 @bitgrower thanks CamperBot @camperbot May 21 2016 04:22 hubhubace sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles: :star2: 1059 | @bitgrower |http://www.freecodecamp.com/bitgrower Thompson Ike @hubhubace May 21 2016 04:22 @bleujai thanks CamperBot @camperbot May 21 2016 04:22 hubhubace sends brownie points to @bleujai :sparkles: :thumbsup: :sparkles: :cookie: 339 | @bleujai |http://www.freecodecamp.com/bleujai Christopher Aguilar @chrisaguilar May 21 2016 04:22 @buckshot307 What exactly do you mean by "iterate through the array I generate"? Which array? Norvin Burrus @ndburrus May 21 2016 04:22 @thinnling would you like to walk through it and see if we can identify the clues that allow understanding the key points, and enable solving it from the instructions? thinnling @thinnling May 21 2016 04:23 yes, that would be great! Norvin Burrus @ndburrus May 21 2016 04:23 @thinnling ok, great...let me pull it up... buckshot307 @buckshot307 May 21 2016 04:23 @chrisaguilar Sorry, as soon as I sent that i realized I should have explained further. bitgrower @bitgrower May 21 2016 04:24 @thinnling -- do you have code where you have tried something ? In software development, there's an idea called "functional decomposition" -- where you break down a problem into parts ... In counting cards, it lends itself to an easy split into 2 tasks ... FIRST -- you must adjust the count variable, depending on the value of the card -- most people use a case statement for this SECOND -- after you have done that, you must determine whether you should send a "BET" or a "HOLD" message ... thinnling @thinnling May 21 2016 04:24 No, I'venever run accross '?' before. buckshot307 @buckshot307 May 21 2016 04:25 @chrisaguilar So for the light up sequence, I have an array inside an object generate random(ish) numbers from 1-4, and then that will be the stored sequence of lights. bitgrower @bitgrower May 21 2016 04:26 whenever tackling a problem that's "fighting back" ... figure out what you DO know ... it's kind of like solving a jigsaw puzzle ... you find the pieces you know and fit them into place, and then work out to the things you are less confident about -- go and do the read-search -- and EXPERIMENT ... see how the code works when you do certain things ... see how it actuallly behaves ... buckshot307 @buckshot307 May 21 2016 04:26 What I intended was to call each index from 0 to the round number. However, when I wrote one something like js sorry Christopher Aguilar @chrisaguilar May 21 2016 04:27 @buckshot307 Okay, so when I was doing my Simon project, I used a loop to go through my array of colors, and then window.setTimeout() to time it so that the colors wouldn't try to light up all at once buckshot307 @buckshot307 May 21 2016 04:27 $('#button' + game.genSequence[i]).animate({
opacity: 0.5
}, 500, function() {
$('#button' + game.genSequence[i]).stop().animate({ opacity: 1 }, 1000) }) bitgrower @bitgrower May 21 2016 04:27 here's a great site to play on: pythontutor.com/javascript.html (don't let the python in the domain name throw you ... ) oooh animation ... very cool ... not in my set of tools (yet) at least in straight js ... jquery -- different story ... :) Norvin Burrus @ndburrus May 21 2016 04:28 @thinnling ok, the card counting function is pre-created...and it receives a card value as input... so far , so good? thinnling @thinnling May 21 2016 04:28 @bitgrower ok, that kinda makes sense. I will look up functional decomposition. bitgrower @bitgrower May 21 2016 04:28 eh ... I'm afraid what you find if you look up the term might confuse you more than help ... Thompson Ike @hubhubace May 21 2016 04:28 how do i acsess wiki from my code page to read mporew about challenges? buckshot307 @buckshot307 May 21 2016 04:28 @chrisaguilar Okay so similar to mine then. My problem was that i would be different for the second part, in effect the buttons would light up but wouldn't turn back off unless it was the last in the list. bitgrower @bitgrower May 21 2016 04:29 it really doesn't give much simpler than the process I've described ... which is that you break down the task of the challenge in to sub-tasks ... buckshot307 @buckshot307 May 21 2016 04:29 @hubhubace on FreeCodeCamp website there is a link at the top for the Wiki Thompson Ike @hubhubace May 21 2016 04:29 ok ewill check again thinnling @thinnling May 21 2016 04:29 @ndburrus yes, that makes sense Thompson Ike @hubhubace May 21 2016 04:29 @buckshot307 thanks CamperBot @camperbot May 21 2016 04:29 hubhubace sends brownie points to @buckshot307 :sparkles: :thumbsup: :sparkles: :cookie: 315 | @buckshot307 |http://www.freecodecamp.com/buckshot307 bleujai @bleujai May 21 2016 04:30 @hubhubace It can be very tempting to look at stuff there too soon. I'm glad I didn't know about that until I was close to done with the FED stuff. bitgrower @bitgrower May 21 2016 04:30 in terms of personal process ... you can think of it as ... what is it I need to do ... and write out pseudocode before you try to write a single line of code ... with the pseudocode you have to worry less about punctuation, etc ... but you can describe your solution and then see if it covers what you need to cover (by reviewing your challenge requirements) Norvin Burrus @ndburrus May 21 2016 04:31 @thinnling alright. next we see that a decision structure is needed to evaluate what effect the received card has on the global count variable.... do you see this information in the instructions? buckshot307 @buckshot307 May 21 2016 04:31 @hubhubace Yeah fight the urge to just copy and paste what the Wiki has for the code. It will progress you further and you won't have learned it so could hurt you later on. bleujai @bleujai May 21 2016 04:31 pseudoCode, research, and then code thinnling @thinnling May 21 2016 04:31 @bitgrower I'vr never thought of it like that. Makes sense and I can see how that would help. *I've bitgrower @bitgrower May 21 2016 04:32 yeah, I think the first question I asked in the chat rooms was about Seek and Destroy -- I don't know if they changed the description ... but I know I didn't fully understand the arguments object ... it probably took me a couple of weeks to fully understand the wiki solution ... thinnling @thinnling May 21 2016 04:33 This message was deleted adily @adiyous May 21 2016 04:33 Profile Lookup help plz thinnling @thinnling May 21 2016 04:33 @hubhubace yes i see bitgrower @bitgrower May 21 2016 04:34 @buckshot307 very true -- when I looked at the seek and destroy solution, I was not satisfied until I understood that backward and forward ... (well, okay, except for the prototype statement that the MDN page supplies on the arguments object page... LOL ... ) Norvin Burrus @ndburrus May 21 2016 04:34 @thinnling super... now, what decision structure had you considered using while you were initially attempting the challenge? (typically if/else if or switch statement/s) bitgrower @bitgrower May 21 2016 04:34 @adily -- to get help, it usually helps if you post any code you've tried ... :) thinnling @thinnling May 21 2016 04:35 I was pretty much completely lost at first. I tried to figure it out with an if statement. adily @adiyous May 21 2016 04:35 ''' CamperBot @camperbot May 21 2016 04:35 :bulb: to format code use backticks!  more info adily @adiyous May 21 2016 04:35 function lookUpProfile(firstName, prop){ // Only change code below this line if(firstName === true && prop === true){ return prop; } if(firstName !== contacts ){ return "No such contact"; } if(prop !== contacts ){ return "No such property"; } // Only change code above this line } bitgrower @bitgrower May 21 2016 04:35 the only other thing I would suggest if you are shy of doing that is to go over all the various object challenges .... and use a tool like pythontutor.com/javascript.html Norvin Burrus @ndburrus May 21 2016 04:37 @thinnling ok, that could work... we're attempting to see that we can find a solution path from the information given. an if/else if statement/s can/could have provide/ed a solution... thinnling @thinnling May 21 2016 04:37 But I didn't know how to go about it. I felt completely lost. bitgrower @bitgrower May 21 2016 04:37 okay ... the firstName & prop contain variables which refer to PARTS of the object they provide you ... it's important to understand the parts of the object, in order to addressed (access, manipulate) the various parts ... Christopher Aguilar @chrisaguilar May 21 2016 04:37 @buckshot307 Wow, this is confusing. jQuery animations always mess me up. $('#button' + game.genSequence[i]).animate({
opacity: 0.5
}, 500, function() {
$('#button' + game.genSequence[i]).stop().animate({ opacity: 1 }, 1000) }) Okay, so you see the callback funciton after "500", I don't think you should use selector.stop().animate(), I think you should try to use just selector.animate(), because when the function is called, the original animation should have already completed. Also, double check and make sure that the callback function is calling .animate() on the same selector Norvin Burrus @ndburrus May 21 2016 04:37 @thinnling i understand... so, do you see that the global variable is set initially to zero, and needs to change based on the input card value? buckshot307 @buckshot307 May 21 2016 04:38 @chrisaguilar Yeah that's where it messes up, for some reason i changes by the time it gets to the callback function Thompson Ike @hubhubace May 21 2016 04:39 now this passed adily @adiyous May 21 2016 04:40 function lookUpProfile(firstName, prop){ // Only change code below this line if(firstName === true && prop === true){ return prop; } if(firstName !== contacts[] ){ return "No such contact"; } if(prop !== contacts[] ){ return "No such property"; } // Only change code above this line } Thompson Ike @hubhubace May 21 2016 04:40 but want to know why it did so swhithout a bracket in front of else function testElseIf(val) { if (val > 10) { return "Greater than 10"; } else if (val < 5) { return "Smaller than 5"; } else return "Between 5 and 10"; } Christopher Aguilar @chrisaguilar May 21 2016 04:40 @buckshot307 Okay, well, let's see. for (var i = 0; i < array.length; i++ { //Animate your button in here } You're doing this, right? bitgrower @bitgrower May 21 2016 04:40 @hubhubace - because you can do an if or an else without brackets if your if or else statement is only 1 line ... buckshot307 @buckshot307 May 21 2016 04:41 @chrisaguilar yeah the for loop was above what I sent earlier thinnling @thinnling May 21 2016 04:41 @ndburrus yes, I see that. buckshot307 @buckshot307 May 21 2016 04:41 js for (var i=0;i<game.count;i++)$('#button' + game.genSequence[i]).animate({
opacity: 0.5
}, 500, function() {
$('#button' + game.genSequence[i]).animate({ opacity: 1 }, 1000) }) bitgrower @bitgrower May 21 2016 04:41 if (condition) doA; else doB; <-- no brackets are required Thompson Ike @hubhubace May 21 2016 04:41 but this is not one line is it? Norvin Burrus @ndburrus May 21 2016 04:41 alright, then using the decision structure (if/else if - as you mentioned), we would setup the decision tree to accomodate the three potential changes (incrementing by one, no change, or decreasing the count var/iable by one) to the global variable (represented by three groupings of cards/card values: 2 through 6, 10 through A, and 7 through 9). does this process make sense? bitgrower @bitgrower May 21 2016 04:42 your ELSE is just one line ... it just returns a message ... (if I recall your code correctly still ... ) Thompson Ike @hubhubace May 21 2016 04:42 function testElseIf(val) { if (val > 10) { return "Greater than 10"; } else if (val < 5) { return "Smaller than 5"; } else return "Between 5 and 10"; } thinnling @thinnling May 21 2016 04:42 @ndburrus yes it does Thompson Ike @hubhubace May 21 2016 04:42 this one Christopher Aguilar @chrisaguilar May 21 2016 04:42 @buckshot307 Okay, so what does game.genSequence look like? Is it like [1, 2, 3, 4] or ['red', 'green', 'blue', 'yellow']? Thompson Ike @hubhubace May 21 2016 04:43 @bitgrower function testElseIf(val) { if (val > 10) { return "Greater than 10"; } else if (val < 5) { return "Smaller than 5"; } else return "Between 5 and 10"; } Christopher Aguilar @chrisaguilar May 21 2016 04:43 @buckshot307 Also, you should use for (var i = 0; i < game.genSequence.length; i++) {//code} bitgrower @bitgrower May 21 2016 04:44 @hubhubace -- a "line" in this case -- well, more correctly is "statement" -- as long as your if or else is just one statement, no brackets are needed ... For our purposes, a statement is defined by 1 or more lines which end with a semicolon ... Thompson Ike @hubhubace May 21 2016 04:44 ok thanks buckshot307 @buckshot307 May 21 2016 04:44 @chrisaguilar like [1, 2, 3, 4], so then '#button' + game.genSequence[i] shows up as '#button' + game.genSequence[0] or '#button' + game.genSequence[1] ect Norvin Burrus @ndburrus May 21 2016 04:44 @thinnling ok, so the only thing left to do after adjusting the count variable based on the input card value, is to provide a suitable output. this output would be the new/adjusted card count value and the action to be taken.... does it make sense how all the information needed is derived from the challenge now? bitgrower @bitgrower May 21 2016 04:45 yeah, sorry, my bad ... I should have said statement earlier instead of line ... buckshot307 @buckshot307 May 21 2016 04:45 @chrisaguilar also you are right, I deleted the for loop when I was testing and wrote it back wrong. oh wait no. bitgrower @bitgrower May 21 2016 04:45 and folks ... be sure to check out some of the other js resources FCC points to on the wiki help js resource CamperBot @camperbot May 21 2016 04:46 ## :point_right: js resources [wiki] # JavaScript Tutorials and other Resources :pencil: read more about js resources on the FCC Wiki Christopher Aguilar @chrisaguilar May 21 2016 04:46 @buckshot307 OOOOOOH I see your problem. game.genSequence[i+1] is what you'd need to use. thinnling @thinnling May 21 2016 04:46 @ndburrus yes, it is a little clearer. I feel more confident I can attempt this again. Thank you for your help! CamperBot @camperbot May 21 2016 04:46 thinnling sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles: :cookie: 384 | @ndburrus |http://www.freecodecamp.com/ndburrus buckshot307 @buckshot307 May 21 2016 04:46 I only want it to iterate through as many items as the count, since that's the "round" it's on bitgrower @bitgrower May 21 2016 04:46 I'm a BIG fan of the udemy course mentioned ... the first 3.5 hours are available for free on YouTube ... buckshot307 @buckshot307 May 21 2016 04:46 @chrisaguilar on the first call or the second? Christopher Aguilar @chrisaguilar May 21 2016 04:46 both wait lord help me CamperBot @camperbot May 21 2016 04:46 ## :point_right: adding environment variables [wiki] # Adding Envirioment Variables in Windows ### Via GUI 1. Download Varpanel. 2. Open Varpanel. 3. In PATH variable, add the relevant path (for example). ### Via Command Line Refer to this answer on Super User. Christopher Aguilar @chrisaguilar May 21 2016 04:47 Sorry i'm wrong and tired Norvin Burrus @ndburrus May 21 2016 04:47 @thinnling you're welcome... :sparkles: thinnling @thinnling May 21 2016 04:47 @ndburrus Thank you for clarifying in detail. You are awesome :) CamperBot @camperbot May 21 2016 04:47 thinnling sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles: :warning: thinnling already gave ndburrus points buckshot307 @buckshot307 May 21 2016 04:47 @chrisaguilar yeah then it skips over the first index Norvin Burrus @ndburrus May 21 2016 04:48 @thinnling you're too kind.... and brilliant too :+1: bitgrower @bitgrower May 21 2016 04:48 lovefest !!! Vivienne Sales @Natto278 May 21 2016 04:49 I've broken my hard coding habit on the Record Collection challenge, but I 'm getting this syntax error: illegal return statement. What am I doing wrong. Here's my code.// Setup var collection = { 2548: { album: "Slippery When Wet", artist: "Bon Jovi", tracks: [ "Let It Rock", "You Give Love a Bad Name" ] }, 2468: { album: "1999", artist: "Prince", tracks: [ "1999", "Little Red Corvette" ] }, 1245: { artist: "Robert Palmer", tracks: [ ] }, 5439: { album: "ABBA Gold" } }; // Keep a copy of the collection for tests var collectionCopy = JSON.parse(JSON.stringify(collection)); // Only change code below this line function updateRecords(id, prop, value) { if (value !== "" && prop != "tracks") collection[id][prop]=value; } { if (value !== "" && prop == "tracks") collection[id][prop].push(value); } { if (value === 0) collection[id].delete(prop); } return collection; // Alter values below to test your code updateRecords(5439, "artist", "ABBA"); thinnling @thinnling May 21 2016 04:49 Thank you! Christopher Aguilar @chrisaguilar May 21 2016 04:49 @buckshot307 can you link me to your project on codepen, so that I can look at it? bitgrower @bitgrower May 21 2016 04:49 that gif animation is annoying ... LOL ... Christopher Aguilar @chrisaguilar May 21 2016 04:49 @bitgrower very annoying bitgrower @bitgrower May 21 2016 04:50 well all, happy coding ... I'm gonna go continue my binge watching of numb3rs ... buckshot307 @buckshot307 May 21 2016 04:50 JohnQQ @JohnQQ May 21 2016 04:50 @Natto278 could you use code format or put it in jsfiddle so we can see whats the problem.. On the first look , looks like you've got empty brackets + return statement outside of function scope Christopher Aguilar @chrisaguilar May 21 2016 04:51 @buckshot307 I'll experiment and tell you if I figure anything out Vivienne Sales @Natto278 May 21 2016 04:51 What is jsfiddle? @JohnQQ Islam Ibakaev @dagman May 21 2016 04:52 @Natto278 codepen's brother buckshot307 @buckshot307 May 21 2016 04:52 @chrisaguilar Alright thanks man, been stuck on it for a while and I'm sure it's a lot simpler than I'm making it out to be. CamperBot @camperbot May 21 2016 04:52 buckshot307 sends brownie points to @chrisaguilar :sparkles: :thumbsup: :sparkles: :cookie: 335 | @chrisaguilar |http://www.freecodecamp.com/chrisaguilar Christopher Aguilar @chrisaguilar May 21 2016 04:53 @buckshot307 No problem :smile: Vivienne Sales @Natto278 May 21 2016 04:55 Will do @JohnQQ ! Thompson Ike @hubhubace May 21 2016 04:56 logic my logic lol guys?? function orderMyLogic(val) { if (val < 10) { return "Less than 10"; } else if (val < 5) { return "Less than 5"; } else { return "Greater than or equal to 10"; } } error orderMyLogic(4) should return "Less than 5" lol jgoldverg @jgoldverg May 21 2016 04:57 what number are you putting in? passing to the function Thompson Ike @hubhubace May 21 2016 04:57 4 6 and 10 4,6 and 10 6 and 10 passed but 4 is hanging Islam Ibakaev @dagman May 21 2016 04:58 @hubhubace <5 than < 10 Norvin Burrus @ndburrus May 21 2016 04:58 @Natto278 ok... it looks like the check for if value is not blank needs attention. right now it looks like the check is to see if it === 0. Thompson Ike @hubhubace May 21 2016 04:59 @dagman you mean swap the values? Norvin Burrus @ndburrus May 21 2016 04:59 @hubhubace it helps to structure the logic to eliminate cases that future decisions do not include... so, evaluating less than 5 would precede evaluating for less than 10... Thompson Ike @hubhubace May 21 2016 05:00 @ndburrus ?? in this case which do i eliminate? Christopher Aguilar @chrisaguilar May 21 2016 05:00 @buckshot307 I think I figured it out. for (var i = 0; i < game.count; i++) {$('#button' + game.genSequence[i].toString()).animate({opacity: 0.5}, 500, function() {console.log(game.genSequence[i]);
$('#button' + game.genSequence[i].toString()).animate({opacity: 1}, 1000); }); } Oops, I messed up the formatting. for (var i = 0; i < game.count; i++) {$('#button' + game.genSequence[i].toString()).animate({opacity: 0.5}, 500, function() {
console.log(game.genSequence[i]);
$('#button' + game.genSequence[i].toString()).animate({opacity: 1}, 1000); }); } Thompson Ike @hubhubace May 21 2016 05:01 @ndburrus ok Norvin Burrus @ndburrus May 21 2016 05:01 @hubhubace i think the order can be improved. the elements (decision nodes) are still useful.... does it make sense that if i check for cases that are less than 5, then check for cases that are less than ten - there is no overlap (or missed cases) than if the order of the checks is reversed? Christopher Aguilar @chrisaguilar May 21 2016 05:02 @buckshot307 You were missing brackets after your for loop, and I think that's what was causing the problems. Thompson Ike @hubhubace May 21 2016 05:02 @ndburrus yeah but the improvement i am thinkin how can val 4 pass? Christopher Aguilar @chrisaguilar May 21 2016 05:02 Because when I logged game.genSequence[i], it gave me two different values. Norvin Burrus @ndburrus May 21 2016 05:03 @hubhubace what is the challenge name for this one? Christopher Aguilar @chrisaguilar May 21 2016 05:03 @buckshot307 Oh, wait, nevermind, it worked once and then it stopped working :/ buckshot307 @buckshot307 May 21 2016 05:03 @chrisaguilar yeah still bugged. Thompson Ike @hubhubace May 21 2016 05:04 @ndburrus Logical Order in If Else Statements buckshot307 @buckshot307 May 21 2016 05:05 what's happening is the second game.genSequence[i] is calling game.genSequence[i + 1] or something. If the next number in game.genSequence is the same it will do the second animation but if not it fails. Norvin Burrus @ndburrus May 21 2016 05:05 @hubhubace ok, so can you order the logic so it makes sense? acgillette @acgillette May 21 2016 05:05 Can someone help me with my Ceasar code? Christopher Aguilar @chrisaguilar May 21 2016 05:06 @buckshot307 Does this work? I set game.genSequence[i] to a local variable that updates with the for loop, so that it doesn't call game.genSequence[i] again in the callback. for (var i = 0; i < game.count; i++) { var current = game.genSequence[i]; console.log(current);$('#button' + current).animate({opacity: 0.5}, 500, function() {
console.log(current);
$('#button' + current).animate({opacity: 1}, 1000); }); } acgillette @acgillette May 21 2016 05:06 Wait never mind I just got it lmao buckshot307 @buckshot307 May 21 2016 05:06 @chrisaguilar hmm. maybe the brackets were the problem though because when i change the second game.genSequence[i] to game.genSequence[i - 1] it seems to work. your solution may work better though down the line. Thompson Ike @hubhubace May 21 2016 05:07 @ndburrus you there? it makes sense for 2 vals but val 4 runs off buckshot307 @buckshot307 May 21 2016 05:08 @chrisaguilar yep. Man thanks so much lol. CamperBot @camperbot May 21 2016 05:08 buckshot307 sends brownie points to @chrisaguilar :sparkles: :thumbsup: :sparkles: :warning: buckshot307 already gave chrisaguilar points Norvin Burrus @ndburrus May 21 2016 05:09 @hubhubace yes.... basically there 3 cases to evaluate a) greater than 10, b) less than 10, and c) less than 5.. Christopher Aguilar @chrisaguilar May 21 2016 05:09 @buckshot307 Well you see where you set game.count = 1 after the user clicks the start button? I just set it to 10, and ALL of the buttons lit up at once, which is the same problem that I was having. You need to use window.setTimer() so that you can delay the execution for each of the buttons. tommy @tommygebru May 21 2016 05:09 Christopher Aguilar @chrisaguilar May 21 2016 05:09 No problem, I'm glad to help :) Thompson Ike @hubhubace May 21 2016 05:09 @ndburrus yes buckshot307 @buckshot307 May 21 2016 05:10 @chrisaguilar yeah I knew that was gonna be a problem in a bit, figured I'd cross that bridge when I got to it lol. Norvin Burrus @ndburrus May 21 2016 05:10 @tommygebru so, we need to order these evaluations so that all possible cases are accounted for - and there is no overlap... can you see how that would be done? tommy @tommygebru May 21 2016 05:11 @ndburrus what challenge do you need help with? Vivienne Sales @Natto278 May 21 2016 05:11 @ndburrus I went back to the value is not blank and and have tried different ways Still getting that illegal return statement error What am I doing wrong? // Setup var collection = { 2548: { album: "Slippery When Wet", artist: "Bon Jovi", tracks: [ "Let It Rock", "You Give Love a Bad Name" ] }, 2468: { album: "1999", artist: "Prince", tracks: [ "1999", "Little Red Corvette" ] }, 1245: { artist: "Robert Palmer", tracks: [ ] }, 5439: { album: "ABBA Gold" } }; // Keep a copy of the collection for tests var collectionCopy = JSON.parse(JSON.stringify(collection)); // Only change code below this line function updateRecords(id, prop, value) { if (value !== "" && prop != "tracks") collection[id][prop]=value; } { if (value !== "" && prop == "tracks") collection[id][prop].push(value); } { if (value === "") collection[id].delete(prop); } return collection; // Alter values below to test your code updateRecords(5439, "artist", "ABBA"); buckshot307 @buckshot307 May 21 2016 05:11 @chrisaguilar gonna have to read up on window.setTimer() now lol bleujai @bleujai May 21 2016 05:12 @Natto278 which challenge is this code for? Vivienne Sales @Natto278 May 21 2016 05:12 @bleujai For the Record Collection challenge tommy @tommygebru May 21 2016 05:12 @Natto278 this challenge is the problem.... so sorry... the instructions are not clear enough.... read other peoples solution google search Christopher Aguilar @chrisaguilar May 21 2016 05:13 @buckshot307 Lol that's exactly how I program! But yeah, the Simon game was really REALLY hard for me to figure out, especially timing the buttons to go off after each other. I was pulling my hair out for days. And it's really simple to use. window.setTimeout(function(){//do something}, delay); tommy @tommygebru May 21 2016 05:13 freecodecamp and .... is this record collection? Vivienne Sales @Natto278 May 21 2016 05:13 @tommygebru Yep. Norvin Burrus @ndburrus May 21 2016 05:13 @tommygebru im helping @hubhubace buckshot307 @buckshot307 May 21 2016 05:13 @chrisaguilar okay cool so I'd just wrap that around the function I already have? JohnQQ @JohnQQ May 21 2016 05:14 @Natto278 you are getting illegal return statement because the statement is out of function scope, told you that already tommy @tommygebru May 21 2016 05:14 @Natto278 yeah because the instructions does not clearly reference what IS parameter and what needs to be accessed @ndburrus well hubhubace has to constantly tell us what he is trying and what the output is :smile: but that is a very simple challenge read instructions... and comments Christopher Aguilar @chrisaguilar May 21 2016 05:16 @buckshot307 You know what, I kinda lied to you. They'd all just delay and then execute all at once. What you really need is window.setInterval(). If you give me a minute, I'll show you how it works. Norvin Burrus @ndburrus May 21 2016 05:16 @Natto278 ok, there are successive if statements, are you using the else if statements? otherwise, the logic looks good... bleujai @bleujai May 21 2016 05:16 @Natto278 I copied and pasted your code into the challenge and I see different areas where the curly braces are not matching up. buckshot307 @buckshot307 May 21 2016 05:17 @chrisaguilar Hmm well that part was just going to be for the first round, I was planning on adding something else for rounds 2-20 though that might not work. Christopher Aguilar @chrisaguilar May 21 2016 05:19 @buckshot307 Oh well you can definitely do whatever you want to do, I was just showing you what I ended up using to time the buttons to light up after each other. But if you're doing something different, then I'd be glad to help you with whatever you're trying to do. bleujai @bleujai May 21 2016 05:19 @Natto278 Make sure that your if statements follow the format of :smile: if (condition) { } Vivienne Sales @Natto278 May 21 2016 05:19 @bleujai Thank you. I'll recheck my curly braces. @tommygebru Do you mean my instructions or the instructions of the challenge. @JohnQQ I'm trying. CamperBot @camperbot May 21 2016 05:19 natto278 sends brownie points to @bleujai and @tommygebru and @johnqq :sparkles: :thumbsup: :sparkles: :cookie: 340 | @bleujai |http://www.freecodecamp.com/bleujai :cookie: 375 | @johnqq |http://www.freecodecamp.com/johnqq :cookie: 720 | @tommygebru |http://www.freecodecamp.com/tommygebru Vivienne Sales @Natto278 May 21 2016 05:20 I'm going to have brunch. Thou shall not code on an empty stomach. bleujai @bleujai May 21 2016 05:21 @Natto278 That's fun. I worked with someone who is about to go to brunch whereas I'm about to head to bed. buckshot307 @buckshot307 May 21 2016 05:22 @chrisaguilar Alright preciate it. Gonna have a look and try to decide how to proceed haha. tommy @tommygebru May 21 2016 05:22 @Natto278 instructions of the challenge.... :wink2: its not you brunch sounds good its late here I have to sleep .....and dream about brunch now :smile: @bleujai same Christopher Aguilar @chrisaguilar May 21 2016 05:23 @buckshot307 Here's my Simon project; I commented the heck out of the code when I made it (which I wish I had done with the rest of my projects), so if you get stuck you can go through it and maybe get some ideas. Good luck with finishing it, though, it really is a hard project! http://codepen.io/chrisaguilar/full/ZWVzMo/ buckshot307 @buckshot307 May 21 2016 05:25 @chrisaguilar Alright man thanks a ton! CamperBot @camperbot May 21 2016 05:25 buckshot307 sends brownie points to @chrisaguilar :sparkles: :thumbsup: :sparkles: :warning: buckshot307 already gave chrisaguilar points Christopher Aguilar @chrisaguilar May 21 2016 05:25 OH NO I DELETED THE COMMENTS :( :( :( Well, still, if you get stuck, you could try to decrypt my code :/ But you're very welcome! Happy coding! :) Manasmko @Manasmko May 21 2016 05:38 how do i multiply the numbers of variable? for eg: I want to multiply the three numbers in the var r = [2, 6, 7]; how do i go about it? jgoldverg @jgoldverg May 21 2016 05:39 you can declare three seperate var containing each then you do something like abc= d a b c = d JohnQQ @JohnQQ May 21 2016 05:39 @Manasmko you can use the basic for loop that iterates over array values , e.g array[i] * someNumber Manasmko @Manasmko May 21 2016 05:41 thanks @JohnQQ and @jgoldverg , will try to do so CamperBot @camperbot May 21 2016 05:41 manasmko sends brownie points to @johnqq and @jgoldverg :sparkles: :thumbsup: :sparkles: :cookie: 132 | @jgoldverg |http://www.freecodecamp.com/jgoldverg :cookie: 376 | @johnqq |http://www.freecodecamp.com/johnqq jgoldverg @jgoldverg May 21 2016 05:41 thx for the bp Jordan Shackelford @JordanShackelford May 21 2016 05:43 How can I add currency values without getting a bunch of extra digits? I have a function that is supposed to return 335.41 but it returns 335.409999999 bleujai @bleujai May 21 2016 05:44 hey @JordanShackelford, I had the same trouble. Look up the toFixed() option. I think it might help. .toFixed() JohnQQ @JohnQQ May 21 2016 05:45 @JordanShackelford as @bleujai said, you can use Number.toFixed(number of decimal places you want) Jordan Shackelford @JordanShackelford May 21 2016 05:47 @bleujai @JohnQQ Okay thanks CamperBot @camperbot May 21 2016 05:47 jordanshackelford sends brownie points to @bleujai and @johnqq :sparkles: :thumbsup: :sparkles: :cookie: 341 | @bleujai |http://www.freecodecamp.com/bleujai :cookie: 377 | @johnqq |http://www.freecodecamp.com/johnqq Markus Kiili @Masd925 May 21 2016 05:48 @JordanShackelford If you wan't to round to a number (toFixed returns a string), you can use +num.toFixed(digits) iigmir @iigmir May 21 2016 05:50 Hello, have a question. I have a object like this:var foo = { "bar":15,"rab":30,"fo br":45, }. I found that I cannot select fo br in object foo: If I type foo.fo br, unsurprise fail. However, I cannot also use foo."fo br". How can I select fo br in object foo? Markus Kiili @Masd925 May 21 2016 05:51 @iigmir The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3. So use bracket notation. iigmir @iigmir May 21 2016 05:54 @Masd925 You mean foo["fo br"] right? It works, thank you. CamperBot @camperbot May 21 2016 05:54 iigmir sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 1565 | @masd925 |http://www.freecodecamp.com/masd925 Islam Ibakaev @dagman May 21 2016 05:56 Manasmko @Manasmko May 21 2016 06:22 can anyone tell me what is wrong with my code? I have written it for factorialize a number. The only problem is that factorial 0 does not return 1 function factorialize(num) { var r = []; for ( var i = 1; i <= num ; i++){ r.push(i); } var n = r.reduce(function (previousVal, currentVal){ if(num === 0){ return 1; }else{ return previousVal*currentVal;} }); return n; } factorialize(5); Thompson Ike @hubhubace May 21 2016 06:25 i still have problem here function orderMyLogic(val) { if (val < 8) { return "Less than 10"; } else if (val < 5) { return "Less than 5"; } else { return "Greater than or equal to 10"; } } // Change this value to test orderMyLogic(4); Amande @wormwoods May 21 2016 06:33 This message was deleted Mariya @mariyadiminsky May 21 2016 06:36 nikban @nikban May 21 2016 06:37 how items can be added at the back of the queue Chris Cullen @123xylem May 21 2016 06:37 @hubhubace probably something to do with it being <8 AND <5 not else Can you help why this link doesnt work even with target=blank? $(output).append(
"<li>" +  data[1][0] + ": " + data[2][0] + "<br>" + "<a  href=''target='_blank'>" +data[3][0] + "</a>"  + "</li>"
Alexander Køpke
@alexanderkopke
May 21 2016 06:39
@123xylem what do you mean it doesn't work? it opens up a new page
Chris Cullen
@123xylem
May 21 2016 06:39
The link doesnt direct you to the url
it goes back to codepen/boomerang
Alexander Køpke
@alexanderkopke
May 21 2016 06:40
yes you set href=''
Chris Cullen
@123xylem
May 21 2016 06:40
O...
oops
href is the url bit
Thompson Ike
@hubhubace
May 21 2016 06:41
@123xylem what you think i do?
i need to change the order
Chris Cullen
@123xylem
May 21 2016 06:41
@hubhubace use && or someething
it shouldnt be too hard but im not very experienced
yea or the order starting with <5
Thompson Ike
@hubhubace
May 21 2016 06:42
&& puts them in single line
Chris Cullen
@123xylem
May 21 2016 06:43
Sometimes it just needs the energy to change it up :)
if its less than 8 and 5 say less than 5 else less than 8 else more than 10
@alexanderkopke Hmm thanks
CamperBot
@camperbot
May 21 2016 06:43
123xylem sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
Alexander Køpke
@alexanderkopke
May 21 2016 06:44
@123xylem so you can use a variable I think you already have it as url href='"+url+"'
Chris Cullen
@123xylem
May 21 2016 06:44
@alexanderkopke but that url is for the whole json not the specific part of the data
Alexander Køpke
@alexanderkopke
May 21 2016 06:44
ah ok
Chris Cullen
@123xylem
May 21 2016 06:44
trying to think of the fastest easiest way of doing this
is there a data[3]0 function I can use
Or do i have to manually declare all data[3] as a var that equal their url
Alexander Køpke
@alexanderkopke
May 21 2016 06:46
ah so you want each entry to be a link you can click and a new tab opens with that content
makes sense
Chris Cullen
@123xylem
May 21 2016 06:46
YEa just the last data part as the last data part is the url of the prev 2
I DID IT
href="+ data[3][0]+ "target='_blank'>"
im a genius
Alexander Køpke
@alexanderkopke
May 21 2016 06:51
:) :+1:
ikkeikke
@ikkeikke
May 21 2016 06:56
Hai. Anyone could help... I'm doing these basic algorithms, and the output, by unidentifiable reason, is a red dot, no mad js scolding me for errors, just a red dot, what did I break? :D
JohnQQ
@JohnQQ
May 21 2016 06:57
@ikkeikke give us a link :)
ikkeikke
@ikkeikke
May 21 2016 07:03
@JohnQQ well found, fyi wild red dots appear if you feed String.fromCharCode() with arguments that ain't exactly numbers it expect to be fed, gotta find appropriate diet :grin:
Amande
@wormwoods
May 21 2016 07:03
This message was deleted
Jordan Shackelford
@JordanShackelford
May 21 2016 07:10

I have an object and an array with common names.

var values = {
"PENNY":0.01,
"NICKEL":0.05,
"DIME":0.10,
"QUARTER":0.25,
"ONE":1.00,
"FIVE":5.00,
"TEN":10.00,
"TWENTY":20.00,
"ONE HUNDRED":100.00
};

var cid = [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]];

How would I check the values of each coin in cid? values.cid[i][0] doesn't work

JohnQQ
@JohnQQ
May 21 2016 07:13
@JordanShackelford what is - i - in values.cid? you only have subarrays in cid array, with no objects, therefore 1.01 is not value of "PENNY" , but you can access it like this : cid[0][1] --> 1.01
Jordan Shackelford
@JordanShackelford
May 21 2016 07:14
@johnQQ I'm iterating over it with a for loop. The i is just the array index
I need to check what the value of each of them is and do something based on that. So how do I check the values variable for cid[0][0]?
JohnQQ
@JohnQQ
May 21 2016 07:16
@JordanShackelford I forgot to mention but you cant chain array to an object (unless one contains another) , so you can't really use values.cid
TanYiXun
@TanYiXun
May 21 2016 07:16

Can someone help me with codewars kata?

function XO(str) {
//code here
var arr=[];
var arrX=[];
var arrO=[];
var arrOthers; // not necessary

arr.push(str.toLowerCase().split(""));
for( var i=0; i <arr.length; i++){

if(arr[i]=='x'){
arrX=arrX.push('x');
}

else if(arr[i]=='o'){
arrO=arrO.push('o');
}
else {
arrOthers=arr[i].pop();
}
}
var arrXJoined=arrX.join('');
var arrOJoined=arrO.join('');
if(arrXJoined.length===arrOJoined.length){
return true;
}
else{return false;}
}

Test cases

Test.assertEquals(XO('xo'),true);
Test.assertEquals(XO("xxOo"),true);
Test.assertEquals(XO("xxxm"),false);
Test.assertEquals(XO("Oo"),false);
Test.assertEquals(XO("ooom"),false);

I only managed to pass two tests , not sure why the third resulted in true insteas of false.

Jordan Shackelford
@JordanShackelford
May 21 2016 07:17
cid[0][0] should return "PENNY" right? So I need to take that string and check the values object to get the value of a penny
Thompson Ike
@hubhubace
May 21 2016 07:19

function orderMyLogic(val) {
if (val < 10) {
return "Less than 10";
} else if (val < 5) {
return "Less than 5";
} else {
return "Greater than or equal to 10";
}
}

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

JohnQQ
@JohnQQ
May 21 2016 07:19
@JordanShackelford hmmm you could do something like values[cid[0][0]] to get the "PENNY" prop name in values
TanYiXun
@TanYiXun
May 21 2016 07:20
@hubhubace how can i help?
Thompson Ike
@hubhubace
May 21 2016 07:20

@TanYiXun
function orderMyLogic(val) {
if (val < 10) {
return "Less than 10";
} else if (val < 5) {
return "Less than 5";
} else {
return "Greater than or equal to 10";
}
}

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

TanYiXun
@TanYiXun
May 21 2016 07:20
@hubhubace what do they want?
Thompson Ike
@hubhubace
May 21 2016 07:20
one statement is not true
error orderMyLogic(4) should return "Less than 5"
TanYiXun
@TanYiXun
May 21 2016 07:21
@hubhubace you need to change the order in which they execute you see
Thompson Ike
@hubhubace
May 21 2016 07:21
ok
JohnQQ
@JohnQQ
May 21 2016 07:21
@hubhubace you should first check if val < 5, then val < 10 , then else
Thompson Ike
@hubhubace
May 21 2016 07:21
that checked
TanYiXun
@TanYiXun
May 21 2016 07:21
@hubhubace since the first if() shows less than than 10, if i use 3 , it would already have returned without moving on to the second if()
Thompson Ike
@hubhubace
May 21 2016 07:22
yes
but also have to return on 6 and 11
TanYiXun
@TanYiXun
May 21 2016 07:22
@hubhubace so if its < start with smaller values , this way would be correct and way more accurate
Chris Cullen
@123xylem
May 21 2016 07:22
http://codepen.io/123xylem/pen/aNxREJ?editors=1000 Any Idea why my random buttonb only works if I say openin new tab? on right click
Thompson Ike
@hubhubace
May 21 2016 07:23
@TanYiXun orderMyLogic(6) should return "Less than 10"
orderMyLogic(11) should return "Greater than or equal to 10"
Jordan Shackelford
@JordanShackelford
May 21 2016 07:23
@johnQQ thanks it seems to be working
CamperBot
@camperbot
May 21 2016 07:23
jordanshackelford sends brownie points to @johnqq :sparkles: :thumbsup: :sparkles:
Thompson Ike
@hubhubace
May 21 2016 07:23
these last two passed
TanYiXun
@TanYiXun
May 21 2016 07:24
isit beacuse of your format? try spacing out your ifs and elses @hubhubace
Thompson Ike
@hubhubace
May 21 2016 07:25
ok will do
TanYiXun
@TanYiXun
May 21 2016 07:26
@hubhubace should be probably because of your sequence it executes as the computer executes top to down, so when using the test from smaller number to bigger numbers to see which range your test values are, you should start with a smaller range , i.e. <5 , then work your way to <10 , then else >10.
Thompson Ike
@hubhubace
May 21 2016 07:27
ok
lets try
TanYiXun
@TanYiXun
May 21 2016 07:29
@hubhubace help format
@hubhubace once you done just post your code here
wiki format
CamperBot
@camperbot
May 21 2016 07:29

# Multi line Code

js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

 ⇦ Type 3 backticks, then press [enter ⏎]

# Single line Code

This an inline <paste code here> code formatting with a single backtick() at _start_ and _end_ around thecode.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

Thompson Ike
@hubhubace
May 21 2016 07:29
ok

@TanYiXun
function orderMyLogic(val) {
if (val < 5) {
return "Less than 5";

} else if (val < 10) {
return "less than 10";
} else {
return "Greater than or equal to 10";
}
}

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

Jordan Shackelford
@JordanShackelford
May 21 2016 07:30
var cid = [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]];

// greatest to least
for(var i = cid.length - 1; i > 0; i--){
var remainingCoinTotal = cid[i][1];
if(values[cid[i][0]] < changeRemaining){
}
}
My cid array has a length of 9. I started my for loop counter at cid.length - 1, so it should be 8. But for some reason, my for loop keeps starting at 3.
Thompson Ike
@hubhubace
May 21 2016 07:31
now does not pass statement for val 6
lol
TanYiXun
@TanYiXun
May 21 2016 07:31
@hubhubace how?
@hubhubace do you mind sending me the link?
Thompson Ike
@hubhubace
May 21 2016 07:32
i get error on val 6
TanYiXun
@TanYiXun
May 21 2016 07:33
@hubhubace I KNOW!
kirbyedy
@kirbyedy
May 21 2016 07:33
@hubhubace Less not less
mind the capital letter L
TanYiXun
@TanYiXun
May 21 2016 07:33
@hubhubace IM sorry i failed to see it before... your LETTER l in less than has to be uppercaps
@kirbyedy @hubhubace yeap he's correct
Thompson Ike
@hubhubace
May 21 2016 07:38
ok
i see
so if change that ok
Thompson Ike
@hubhubace
May 21 2016 07:45
@TanYiXun you there?
TanYiXun
@TanYiXun
May 21 2016 07:45
Yeah?
Yupppp
Henrique Salguero
@kikosalguero
May 21 2016 07:46

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

case 2:
answer = count + 1 + " Bet";
break;
case 3:
answer = count + 1 + " Bet";
break;
case 4:
answer = count + 1 + " Bet";
break;
case 5:
answer = count + 1 + " Bet";
break;
case 6:
answer = count + 1 + " Bet";
break;
case 7:
answer = count + " Hold";
break;
case 8:
answer = count + " Hold";
break;
case 9:
answer = count + " Hold";
break;
case 10:
answer = count - 1 + " Hold";
break;
case "A":
answer = count - 1 + " Hold";
break;
case "J":
answer = count - 1 + " Hold";
break;
case "Q":
answer = count - 1 + " Hold";
break;
case "K":
answer = count - 1 + " Hold";
break;

}

What i am missing here?
TanYiXun
@TanYiXun
May 21 2016 07:46
Change less than to Less than
Wish Henrique why so many cases?
Woah *
Henrique Salguero
@kikosalguero
May 21 2016 07:47
And it didnt work! LOL
TanYiXun
@TanYiXun
May 21 2016 07:48
Lmao
Henrique Salguero
@kikosalguero
May 21 2016 07:48
i can use case 2 || 3 || 4 || 5 || 6: ?
Kasra Khosravi
@kasrakhosravi
May 21 2016 07:49
TanYiXun
@TanYiXun
May 21 2016 07:50
Henrique what do you mean?
Thompson did it work?
Henrique Salguero
@kikosalguero
May 21 2016 07:57
i cant have the results of Counting Cards excercise
Thompson Ike
@hubhubace
May 21 2016 07:58
still battling
omgeez
Thompson Ike
@hubhubace
May 21 2016 08:04
@TanYiXun still there?
TanYiXun
@TanYiXun
May 21 2016 08:05
Yeapp
What's happening? @hubhubace I tried changing and it worked!
Thompson Ike
@hubhubace
May 21 2016 08:06
oh
so what did you change?
TanYiXun
@TanYiXun
May 21 2016 08:06
Check previous messgaes
Thompson Ike
@hubhubace
May 21 2016 08:06
the statement or value?
TanYiXun
@TanYiXun
May 21 2016 08:06
I told you
The letter
Thompson Ike
@hubhubace
May 21 2016 08:06
the capital?
TanYiXun
@TanYiXun
May 21 2016 08:07
Since you've already changed the sequence the only part you're wrong is that
Yeah
:)
Thompson Ike
@hubhubace
May 21 2016 08:07
i changed but failed 2 statements
lol
TanYiXun
@TanYiXun
May 21 2016 08:07
??
Thompson Ike
@hubhubace
May 21 2016 08:07
passsed one
TanYiXun
@TanYiXun
May 21 2016 08:07
Change from
Thompson Ike
@hubhubace
May 21 2016 08:07
let me try again
TanYiXun
@TanYiXun
May 21 2016 08:08
Change from small caps l in less, to L in Less
Thompson Ike
@hubhubace
May 21 2016 08:08
ok
TanYiXun
@TanYiXun
May 21 2016 08:08
As they would require to return.
Thompson Ike
@hubhubace
May 21 2016 08:10
yipeee
loic
@TanYiXun thanks
CamperBot
@camperbot
May 21 2016 08:11
hubhubace sends brownie points to @tanyixun :sparkles: :thumbsup: :sparkles:
TanYiXun
@TanYiXun
May 21 2016 08:11
@hubhubace I'm glad you passed :)
Thompson Ike
@hubhubace
May 21 2016 08:12
and got to understand more
TanYiXun
@TanYiXun
May 21 2016 08:13
@hubhubace No problem... Anymore questions feel free to ask
Henrique Salguero
@kikosalguero
May 21 2016 08:16

var count = 0;

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

case 2 || 3 || 4 || 5 || 6:
answer = count + 1 + " Bet";
break;
case 7 || 8 || 9:
answer = count + " Hold";
break;
case 10 || "J" || "Q" || "K" || "A":
answer = count - 1 + " Hold";
break;

}
// Only change code above this line
}

// Note: Only the last will display
cc(2); cc("J"); cc(9); cc(2); cc(7);

What is wrong with that function?
The result isnt "1 Bet"....
buckshot307
@buckshot307
May 21 2016 08:19
So I'm working on the pomodoro clock, and I've got function to count down when the timer is started. How do I make it stop? lol.
var timeVar, seconds = 60;

function myFunction() {
timeVar = setInterval(timer, 1000);
}

function timer() {
if (seconds > 0) {
seconds -= 1;
} else {
seconds = 60;
time -= 1;
}
element4.innerHTML = time + ":" + seconds;
}

document.getElementById("timer").addEventListener("click", myFunction);
buckshot307
@buckshot307
May 21 2016 08:24
Never mind, got it!
darrenbachan
@darrenbachan
May 21 2016 08:29
I am stumped

// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me

I changed H to J and nothing

ikkeikke
@ikkeikke
May 21 2016 08:32
@darrenbachan You can't do it like that, read explanations carefully (and the error log); strings are immutable, you have to change whole string like myStr = "Hello World" :)
darrenbachan
@darrenbachan
May 21 2016 08:36
im not getting an error log
i tried changing jello to hello and still
cannot assign read only property 0 of string
this lesson is busted...
Sanne
@sannek
May 21 2016 08:42
@darrenbachan The lesson isn't busted, it's meant to teach you that you can't change parts of strings, only the whole one. Like @ikkeikke said, you need to change the whole text of the string, not just word or one letter
Siddarth Narayanan
@siddarthnarayanan94
May 21 2016 08:43
hey guys , in the profile lookup challenge, I tried this code and I find errors :
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0;i<4;i++ )
{
if(firstName ==contacts[i].firstName)
{
switch(prop)
{
case contacts[i].lastName : return contacts[i].lastName;
break;
case contacts[i].number : return contacts[i].number;
break;
case contacts[i].likes : return contacts[i].likes;
break;
default: return "No such property";
break;
      }
}
else
{
return "No such contact";
}
Krishna
@krisskb
May 21 2016 08:44
Hello ALl,
Fred
@Fred-Saru
May 21 2016 08:44
function addTogether(passed) {

if (arguments.length === 2)
return arguments[0] + arguments[1];

return passed + inner;
};

}

addTogether("http://bit.ly/IqT6zt");
The last use case breaks, so should I return; if the typeof passed and inner isn't "number" ?
Krishna
@krisskb
May 21 2016 08:47
Hello All, I have following code about getting latitude and longitude details of current location. Here I am always getting lati variable value as zero even though its getting filled in getCurrentPosition function. Could someone help me what is wrong in this code. Thanks in advance.
var lon=0;
var lati=0;
navigator.geolocation.getCurrentPosition(function(position){
lon=position.coords.longitude;
lati=position.coords.latitude;
});
var ctemp = 0;
var url = "http://api.openweathermap.org/data/2.5/weather?lat="+lati ;
Krzysztof Borowy
@Krizzu
May 21 2016 08:48
@Fred-Saru Hey Mate! What's the problem with it?
darrenbachan
@darrenbachan
May 21 2016 08:50
@sannek I can't get this, I'm retyping the whole thing. I get that it's trying to get the first letter of Hello World but retyping the entire variable does nothing for me
Krzysztof Borowy
@Krizzu
May 21 2016 08:50
@krisskb Hey mate! Looks like you have a problem with the url!
@krisskb try
var url = "http://api.openweathermap.org/data/2.5/weather?lat="+lati +"&lon="+lon;
Siddarth Narayanan
@siddarthnarayanan94
May 21 2016 08:51

function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0;i<4;i++ )
{
if(firstName ==contacts[i].firstName)
{
switch(prop)
{
case contacts[i].lastName : return contacts[i].lastName;
break;
case contacts[i].number : return contacts[i].number;
break;
case contacts[i].likes : return contacts[i].likes;
break;
default: return "No such property";
break;

      }
}
else
{
return "No such contact";
}
Ajith
@ajithvallabai
May 21 2016 08:52
is any one doing algorithm :HTML entities?
Krzysztof Borowy
@Krizzu
May 21 2016 08:52
@ajithvallabai is it intermediate?
Ajith
@ajithvallabai
May 21 2016 08:53
ya @Krizzu
Krzysztof Borowy
@Krizzu
May 21 2016 08:53
@ajithvallabai Ah, didn't get there yet
:/
darrenbachan
@darrenbachan
May 21 2016 08:53
Understand String Immutability can someone help me with this please
Ajith
@ajithvallabai
May 21 2016 08:53
soon you would be @Krizzu
Krzysztof Borowy
@Krizzu
May 21 2016 08:54
@ajithvallabai But maybe I could help :D
hit me
Ajith
@ajithvallabai
May 21 2016 08:55
i want to store all the places of regex in n
function convertHTML(str) {
// &colon;&rpar;
var n=[];
n.push(str.search(/[<&>"']/g));
var thn= str[n];
return n;
}

convertHTML("Hamburgers < Pizza < Tacos");
@Krizzu
Krishna
@krisskb
May 21 2016 08:56
Hello @Krizzu , Now I tried this full URL inside the function and passing it to getJSON. Now url variable is not recognized. How to make url variables global.
var lon=0;
var lati=0;
var url = "";
navigator.geolocation.getCurrentPosition(function(position) {
lon=position.coords.longitude;
lati=position.coords.latitude;
url = "http://api.openweathermap.org/data/2.5/weather?lat="+lati+"&lon="+lon+"&units=metric&APPID=11caf58603d30b0b28a893215a73249f" ;
});
$.getJSON(url, function(json) { Krzysztof Borowy @Krizzu May 21 2016 08:57 @ajithvallabai did you try to print 'n' into console, to see what is it holding? Ajith @ajithvallabai May 21 2016 08:59 i used return it shows me only the expression detected in first search darrenbachan @darrenbachan May 21 2016 09:00 Understand String Immutability can someone help me on this Krzysztof Borowy @Krizzu May 21 2016 09:01 @krisskb If they are not decalred in any block, they are global @krisskb try to get declaration on top of everyting else @darrenbachan hit me Ajith @ajithvallabai May 21 2016 09:01 @darrenbachan show u r code darrenbachan @darrenbachan May 21 2016 09:02 // Setup var myStr = "Hello World"; // Only change code below this line myStr[0] = "H"; // Fix Me Martialis39 @Martialis39 May 21 2016 09:02 hey, is this the right place for CSS HTML questions as well? I want make an animation that triggers either when an element is clicked or when the page is loaded, can I do that with CSS or do I have to use Javascript? this is what I have so far, with hover: darrenbachan @darrenbachan May 21 2016 09:03 @Krizzu what does "hit me" mean, is there a way to pm you? Ajith @ajithvallabai May 21 2016 09:03 @darrenbachan i think you have chaged the setup Krzysztof Borowy @Krizzu May 21 2016 09:03 @darrenbachan string are immutable, which means you cannot change them So str[0] = 'a' won't work You have to change whole string str = 'H'; @darrenbachan I meant to post it here :D darrenbachan @darrenbachan May 21 2016 09:04 chanhe the whole string to what Krzysztof Borowy @Krizzu May 21 2016 09:04 @Martialis39 They is a way to do it in css, but it's waaaaaaaaay more easier to do in js darrenbachan @darrenbachan May 21 2016 09:04 these lessons arent clear to me or im a complete dumbass one or the two Ajith @ajithvallabai May 21 2016 09:05 @darrenbachan reset it first it is Jello World Martialis39 @Martialis39 May 21 2016 09:05 @Krizzu Ok, so id do something like$jquery something ready
append style
bla bla bla
?
Great pseudo code, I know :D
darrenbachan
@darrenbachan
May 21 2016 09:05
Okay, it's reset
Krzysztof Borowy
@Krizzu
May 21 2016 09:06
$(document).ready(function(){}); Is waiting for the DOM to load @Martialis39 and yeah, that's what you should do :D Ajith @ajithvallabai May 21 2016 09:06 @darrenbachan after reseting asign Hello World to the mystr darrenbachan @darrenbachan May 21 2016 09:06 but i did that before and nothing Ajith @ajithvallabai May 21 2016 09:07 var myStr = "Bob"; myStr = "Job"; Krzysztof Borowy @Krizzu May 21 2016 09:07 @darrenbachan Yeah, string are not changable, which means you cannot change it like an array myStr[2] = 'H'; // <- this won't work if you want to change them, use myStr = 'H'; @Martialis39 Yeah, so let's say, you have and element that you want to animate, with id #myItem Use jQuery to add click event to that item Dan Couper @DanCouper May 21 2016 09:08 @ajithvallabai you need to loop through the string character by character, str search isn’t really what you want. This is what is currently happening: > convertHTML('Hamburgers < Pizza < Tacos’) // so n = [] // then n.push(11) // n is now [11] // then this, which doesn’t work: thn = "Hamburgers < Pizza < Tacos”[[11]] // can’t use array access bracket notation on a str. // Can’t use an array to find position (an array is not a number) // makes no difference, because you return n anyway return [11] Krzysztof Borowy @Krizzu May 21 2016 09:08 @Martialis39 in JS $("#myItem").click(function(){
});
darrenbachan
@darrenbachan
May 21 2016 09:09

// Setup
var myStr = "Jello World";

// Only change code below this line
str = "Hello World";
myStr[0] = "H"; // Fix Me

i dont know what im doign
Ajith
@ajithvallabai
May 21 2016 09:09
remove myStr[0] = "H"; // Fix Me
@darrenbachan
thanks @DanCouper i will try
CamperBot
@camperbot
May 21 2016 09:09
ajithvallabai sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
Martialis39
@Martialis39
May 21 2016 09:10
@Krizzu nice, thanks man :)
CamperBot
@camperbot
May 21 2016 09:10
martialis39 sends brownie points to @krizzu :sparkles: :thumbsup: :sparkles:
Krzysztof Borowy
@Krizzu
May 21 2016 09:10
@Martialis39 anytime mate
darrenbachan
@darrenbachan
May 21 2016 09:10
this lesson is dumb as hell
Ajith
@ajithvallabai
May 21 2016 09:10
@darrenbachan have u got?
u were near
Krzysztof Borowy
@Krizzu
May 21 2016 09:11
@darrenbachan It is not. It is showing you that you cannot use indexing on strings
and to change string, use its name
Ajith
@ajithvallabai
May 21 2016 09:12
@darrenbachan

mystr="Hello World"
@DanCouper which function is better
for Html entities
Martialis39
@Martialis39
May 21 2016 09:15
@Krizzu again, ty very much, just got it working (y)
CamperBot
@camperbot
May 21 2016 09:15
martialis39 sends brownie points to @krizzu :sparkles: :thumbsup: :sparkles:
:warning: martialis39 already gave krizzu points
Krzysztof Borowy
@Krizzu
May 21 2016 09:15
@Martialis39 Nice one!
Keep on hacking!
Krishna
@krisskb
May 21 2016 09:19
Still I could not use lon and lati variables after declaring on top. alert gives lat as 0
var lon=0;
var lat=0;
var wurl = "";
$(document).ready(function() { var ctemp = 0; navigator.geolocation.getCurrentPosition(foundLocation, noLocation); function foundLocation(position) { lat = position.coords.latitude; lon = position.coords.longitude; // alert("LAT : "+lat +", LONG : "+lon); } function noLocation() { alert('Could not find location'); } var openwturl="http://api.openweathermap.org/data/2.5/weather?lat=17.3858&lon=78.4807&units=metric&APPID=11caf58603d30b0b28a893215a73249f"; wurl = "http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon+"&units=metric&APPID=11caf58603d30b0b28a893215a73249f" ; alert(lat); Dan Couper @DanCouper May 21 2016 09:19 @ajithvallabai ok, you need to loop through the string, so I would split()it into an array of individual characters first. You are then checking if you need to replace each character in turn, so it’s not str.search() you want it’s str.????()... Ajith @ajithvallabai May 21 2016 09:24 i will it @DanCouper thanks man CamperBot @camperbot May 21 2016 09:24 ajithvallabai sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles: :warning: ajithvallabai already gave dancouper points Amande @wormwoods May 21 2016 09:27 This message was deleted This message was deleted This message was deleted This message was deleted This message was deleted Dan Couper @DanCouper May 21 2016 09:29 @ajithvallabai :+1: just remember, for each character, you’re asking: is this one of the entities? if so, replace and put back; if not, dont do anything, just leave it there. You can then join the characters back together once you’re done looking through them Krishna @krisskb May 21 2016 09:30 @Krizzu Still I could not use lon and lati variables after declaring on top. alert gives lat as 0. Appreciate ur help.. var lon=0; var lat=0; var wurl = "";$(document).ready(function() {
var ctemp = 0;
navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
function foundLocation(position) {
lat = position.coords.latitude;
lon = position.coords.longitude;
// alert("LAT : "+lat +", LONG : "+lon);
}
function noLocation() {
}
var openwturl="http://api.openweathermap.org/data/2.5/weather?lat=17.3858&lon=78.4807&units=metric&APPID=11caf58603d30b0b28a893215a73249f";
wurl = "http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon+"&units=metric&APPID=11caf58603d30b0b28a893215a73249f" ;
alert(lat);
Amande
@wormwoods
May 21 2016 09:31
This message was deleted
Dan Couper
@DanCouper
May 21 2016 09:32
@waasiwaasi it’s just  if you were having issues, not  js
Krzysztof Borowy
@Krizzu
May 21 2016 09:33
    if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function(pos){ //on success on getting gelocator to work
lat = pos.coords.latitude;
lng = pos.coords.longitude;
})};
@krisskb try this way
Krishna
@krisskb
May 21 2016 09:34
Krzysztof Borowy
@Krizzu
May 21 2016 09:34
@krisskb I put a annonymous function as argument for navigator.geolocation.getCurrentPosition
Amande
@wormwoods
May 21 2016 09:34
This message was deleted
This message was deleted
This message was deleted
Ghost
@ghost~56a552d0e610378809be0124
May 21 2016 09:37
help reduce
CamperBot
@camperbot
May 21 2016 09:37

# Challenge Condense Arrays with Reduce

Reduce can be useful for condensing an array of numbers into one value.

var array = [4,5,6,7,8];
var singleVal = 0;
// Only change code below this line.

var singleVal = array.reduce(function(previousVal, currentVal){

return previousVal+currentVal;

});
Amande
@wormwoods
May 21 2016 09:39
function lookUpProfile(firstName, prop){
// Only change code below this line
var result;
contacts.forEach (function(e) {
if (e.firstName === firstName) {
result = e[prop] || "No such property";
}
});

return result || "No such contact";

// Only change code above this line
}
@siddarthnarayanan94 Try this :smile:
Krishna
@krisskb
May 21 2016 09:40
@Krizzu yes that is how I tried first with anonymous function. I am fighting with this issue from last night :-(
Krzysztof Borowy
@Krizzu
May 21 2016 09:40
@krisskb Don't give up, skeleton!
After you create your url, print it into console, copy it and paste in into your browser
check if it's working
Alessandro Santandrea
@santa83
May 21 2016 10:02
Hi, anyone can help me?
Raj Thakur
@rajkthakur
May 21 2016 10:03
@santa83 yeah!!
Alessandro Santandrea
@santa83
May 21 2016 10:03
thanks a lot! It's stupid question
Mike Ekkel
@Murkrage
May 21 2016 10:04
Validating US phone numbers is tougher than I expected it to be haha
I love regexp, but dang it this is hard
Alessandro Santandrea
@santa83
May 21 2016 10:05

@rajkthakur I'm working on Caesars Cipher:

function rot13(str) { // LBH QVQ VG!

for(i=0; i<str.length; i++) {
var newWord = str.charCodeAt(i)-13;
}
}

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

Arsalan Sabir
@aayanqazi
May 21 2016 10:05
help me in collection record
CamperBot
@camperbot
May 21 2016 10:05
no wiki entry for: me in collection record
Arsalan Sabir
@aayanqazi
May 21 2016 10:05

function updateRecords(id, prop, value) {
if(value !== "" && prop !== "tracks")
{
collection[id][prop]=value;
}
if(value!==""&& prop=="tracks")
{
collection[id][prop].push(value);
}
if(value ==="")
{
collection[id].prop
}

return collection;
}

HOw to delete prop ??
If value is blank
Alessandro Santandrea
@santa83
May 21 2016 10:07
@rajkthakur I don't understand how I should go on
Raj Thakur
@rajkthakur
May 21 2016 10:07
@santa83 first try to split each word
@santa83 and check if you can go along or after that ping me I will help
luckycharm-boy
@luckycharm-boy
May 21 2016 10:10
function caseInSwitch(val) {
// Only change code below this line
switch (val) {
case 1:
console.log("alpha");
break;
case 2:
console.log("beta");
break;
case 3:
console.log("gamma");
break;
case 4:
console.log("delta");
break;
}

// Only change code above this line
}

// Change this value to test
caseInSwitch(1);
Arsalan Sabir
@aayanqazi
May 21 2016 10:11
use default
Raj Thakur
@rajkthakur
May 21 2016 10:11
@luckycharm-boy can you detail your problem a bit more
Arsalan Sabir
@aayanqazi
May 21 2016 10:11
assign string in each case to answer
Raj Thakur
@rajkthakur
May 21 2016 10:12
I think in place of console you should set the value for answer variable @luckycharm-boy
Arsalan Sabir
@aayanqazi
May 21 2016 10:12
How to delete prop in json object ?
luckycharm-boy
@luckycharm-boy
May 21 2016 10:13
@rajkthakur I'm supposed to write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"
Ivan Saveliev
@ivansvlv
May 21 2016 10:14
@luckycharm-boy switch should have a default value, in case your input is not one of the cases that you've described. after case 4 add - default: console.log("oops"); break;
something like that
oh no
hehe
Raj Thakur
@rajkthakur
May 21 2016 10:15
case 1:
Ivan Saveliev
@ivansvlv
May 21 2016 10:15
yes, you should assign something to answer
because right now you return an empty string
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
luckycharm-boy
@luckycharm-boy
May 21 2016 10:17
@rajkthakur @isavelyev thanks, sorted :)
CamperBot
@camperbot
May 21 2016 10:17
luckycharm-boy sends brownie points to @rajkthakur and @isavelyev :sparkles: :thumbsup: :sparkles:
Ivan Saveliev
@ivansvlv
May 21 2016 10:17
yw
Raj Thakur
@rajkthakur
May 21 2016 10:17
@luckycharm-boy welcome
Arsalan Sabir
@aayanqazi
May 21 2016 10:24
Ivan Saveliev
@ivansvlv
May 21 2016 10:26
Henrique Salguero
@kikosalguero
May 21 2016 10:29
Hello guys! Can anybody help me about what im doing wrong in this couting card exercises ?

var count = 0;

function cc(card) {
// Only change code below this line
if (card == 2 || 3 || 4 || 5 || 6) {
count = count + 1;
answer = count + " Bet";
}

else if (card == 7 || 8 || 9) {
answer = count + " Hold";
}

else if (card == 10 || "J" || "Q" || "K" || "A") {
count = count - 1;
}

// Only change code above this line
}