5th
Aug 2017
aRtoo
@artoodeeto
Aug 05 2017 00:05
  var I = 1;
var V = 5;
var X = 10;
var L = 50;
var C = 100;
var D = 500;
var M = 1000;
@sjames1958gm i know i can check the place value of the num then multiply it according to place value
Stephen James
@sjames1958gm
Aug 05 2017 00:11
@artoodeeto I used compare and subtract method
while (num > 0)
if greater than 1000 add M to output and subtract 1000 from num
else if greater 990 add CM to output and subtract 990 from num
else if ...
@artoodeeto I have seen 2D arrays one for each 10s place
aRtoo
@artoodeeto
Aug 05 2017 00:13
@sjames1958gm didnt really understand sir but thanks. as long as i dont have to convert the num to string.
CamperBot
@camperbot
Aug 05 2017 00:13
artoodeeto sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8246 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 05 2017 00:14
@artoodeeto Take a piece of paper and a number and convert it to roman numerals, and think about how you would do it (no code)
then translate the algorithm to code
aRtoo
@artoodeeto
Aug 05 2017 00:14
@sjames1958gm hahaha. if only you can see my paper beside me.
@sjames1958gm from for loop to switch statement. haha
Kaeleb Rocha
@Kralleb
Aug 05 2017 00:16
@artoodeeto i would put all that into an array for sure
Stephen James
@sjames1958gm
Aug 05 2017 00:17
@artoodeeto Don't think about code. Just write down, say 768 and convert it to roman.
aRtoo
@artoodeeto
Aug 05 2017 00:22
@Kralleb put this in the array? var I = 1; var V = 5; var X = 10; var L = 50; var C = 100; var D = 500; var M = 1000;
@sjames1958gm yea. i know how to convert it. i have some algo in my head now. say if theres a 768 so theres a hundreds place value. im goinig to subtract 100 from there until i make another place avlue
@sjames1958gm something like that.
CallMeOrange
@EgnaroDev
Aug 05 2017 00:24
Too many variables, you just need two arrays of the numbers and roman numbers
or one array if you can
You might know this but I want to say it, if you have 768, subtract 100 add "C" then 668 - 100 add "C" so on..
31 = 31 - 10 = 21 - 10 = 11 - 10 = 1 - 1 = 0
10 = "X" and there is 3 of them, XXX and 1 only one of them, I therefore "XXXI"
CallMeOrange
@EgnaroDev
Aug 05 2017 00:31
Aug 05 2017 00:36
guys is there a good tutorial how to wrap up code into a embeddable widget?
kumquatfelafel
@kumquatfelafel
Aug 05 2017 00:38
@EgnaroDev how that challenge coming, by the way?
CallMeOrange
@EgnaroDev
Aug 05 2017 00:39
@kumquatfelafel Well I skipped it to work on HTML Entities Converter completed it and right now working on Spinal Tap Case
kumquatfelafel
@kumquatfelafel
Aug 05 2017 00:39
gotcha
CallMeOrange
@EgnaroDev
Aug 05 2017 00:43
@kumquatfelafel can you take a look?
function spinalCase(str) {
var array = str.match(/[A-Z]/g);
var test = "";
for (var i = 0; i < array.length; i++){
str = str.replace(/[^a-z]/gi, '');
console.log(str.replace(array[i], "-"+array[i]));
}
return test;
}
spinalCase("TheAndyGriffithSho w");
-TheAndyGriffithShow The-AndyGriffithShow TheAndy-GriffithShow TheAndyGriffith-Show
Thats what I get when I log it, so I might need to split it somehow..
even if I join it back together, it will be the same
replace and lowercase might be enough but I want to do this hard way
Any suggestions?
kumquatfelafel
@kumquatfelafel
Aug 05 2017 00:48
sec
@EgnaroDev is - part of [^a-z]?
CallMeOrange
@EgnaroDev
Aug 05 2017 00:51
no, just a to z
I don't know what you mean but just a to z
kumquatfelafel
@kumquatfelafel
Aug 05 2017 00:52
The-AndyGriffithShow So we have this string. And in our replace function, what we're basically saying is "get rid of all characters that aren't a-z or A-Z".
CallMeOrange
@EgnaroDev
Aug 05 2017 00:52
Yea
kumquatfelafel
@kumquatfelafel
Aug 05 2017 00:53
(also, str.replace(array[i], "-"+array[i]) this isn't being stored anywhere at moment)
CallMeOrange
@EgnaroDev
Aug 05 2017 00:53
just console.logging it as a test
kumquatfelafel
@kumquatfelafel
Aug 05 2017 00:53
@EgnaroDev so in the replace function, will that get rid of the -?
CallMeOrange
@EgnaroDev
Aug 05 2017 00:54
str = str.replace(/[^a-z]/gi, ''); I replace everything that aren't a-z or A-Z to empty spaces so I would have all string as ThisIsAString then use console.log(str.replace(array[i], "-"+array[i]));
if it works as I expected, I would do test += str.replace(array[i], "-"+array[i]) then return it
but the problem is str repeating...
kumquatfelafel
@kumquatfelafel
Aug 05 2017 00:56
CallMeOrange
@EgnaroDev
Aug 05 2017 00:56
4 times because of array's length in a loop so I don't know what to do
yeah I only get one - like that but its different if I do test +=
this is old code
function spinalCase(str) {
var array = str.match(/[A-Z]/g);
var test;
for (var i = 0; i < array.length; i++){
test += str.split(' ')[i].replace(array[i], "-".concat(array[i]));
}
return test;
}
spinalCase("This Is Spinal Tap");
But this won't work with a case with no spaces
try to log test with that code
oh I get it, because I split it I only get This, Is from different repeating str
They are not from the same string
Well thats why it work like that way
CallMeOrange
@EgnaroDev
Aug 05 2017 01:03
I guess I'll have to learn more regex instead of trying to create a loop like that
Joseph
@revisualize
Aug 05 2017 01:05
@EgnaroDev do var test = "";
CallMeOrange
@EgnaroDev
Aug 05 2017 01:05
@revisualize Yeah I would get 'undefinedstring' when I do var test;
I already did that :/, that was old code anyway
kumquatfelafel
@kumquatfelafel
Aug 05 2017 01:13
@EgnaroDev with your new code, all your - are being overwritten since str = str.replace(/[^a-z]/gi, ''); is inside for loop. Or rather, they would be, if you stored result in str.
there are other potential issues, but have to go for now
CallMeOrange
@EgnaroDev
Aug 05 2017 01:15
Okay
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:18
HALP!
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
if ('bastian'.substr(-1) === 'n') {
return true;
}
else {
return false;
}
}

confirmEnding("Bastian", "n");
Abhishek Tiwari
@fillopfy
Aug 05 2017 01:18
@EgnaroDev first check for spaces and underscores, reomove them and then check for small-big letter combination
CallMeOrange
@EgnaroDev
Aug 05 2017 01:19
What's underscores?
kumquatfelafel
@kumquatfelafel
Aug 05 2017 01:19
_
CallMeOrange
@EgnaroDev
Aug 05 2017 01:19
oh
@ma5one1 test it by comparing str and target... not custom string and 'n'
kumquatfelafel
@kumquatfelafel
Aug 05 2017 01:20
@ma5one1 you're trying to hardcode here. Don't. Use the parameters you've been given
CallMeOrange
@EgnaroDev
Aug 05 2017 01:20
^
kumquatfelafel
@kumquatfelafel
Aug 05 2017 01:21
confirmEnding("Bastian", "n");// this passes "Bastian" into str, and "n" into target.
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:21
thats what hardcode is..
CallMeOrange
@EgnaroDev
Aug 05 2017 01:21
What happen if you do this?
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
if ('bastian'.substr(-1) === 'n') {
return true;
}
else {
return false;
}
}

confirmEnding("Blahblahblah", "h");
Nothing to do with str ("Blahblahblah") and target ("h")
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:24
@EgnaroDev Results to true. But wont pass.
CallMeOrange
@EgnaroDev
Aug 05 2017 01:24
Yes because you are comparing bastian and 'n' instead of parameters
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:24
@kumquatfelafel ill reset and try this.
CallMeOrange
@EgnaroDev
Aug 05 2017 01:25
@ma5one1 The problem is you are comparing strings you created instead of parameters
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:26
@kumquatfelafel
CallMeOrange
@EgnaroDev
Aug 05 2017 01:26
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
if ('bastian'.substr(-1) === 'n') {
return true;
}
else {
return false;
}
}

confirmEnding("test", "h");
confirmEnding("test", "h"); should return false but instead it return true
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:26
returns false but wont pass.
CallMeOrange
@EgnaroDev
Aug 05 2017 01:27
@ma5one1 Your code works fine but you are supposed to use parameters instead of these strings
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:27
Okay guys i tried all possible paths.
kumquatfelafel
@kumquatfelafel
Aug 05 2017 01:27

@ma5one1 Yeah, because what you're doing is wrong. :p

it's a little confusing to grasp in the context of functions at first, so let's just pretend we're working with some regular lines of code first, then relate it to the concept of function.

Give me sec to write example.
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:28
@EgnaroDev yea oddly it still doesn't pass.
CallMeOrange
@EgnaroDev
Aug 05 2017 01:28
@ma5one1 Show your code again, make sure to use parameters (str, target)
Your code all it does is to compare 'bastian' and 'n' not str and target, your code has nothing to do with str and target
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:30
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
if (str.substr(-target) === 'target')
{
return true;
}
else {
return false;
}
}

confirmEnding("Bastian", "n");
CallMeOrange
@EgnaroDev
Aug 05 2017 01:30
Yes good, but parameter are not supposed to be in string
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:31
Good GAWD
CallMeOrange
@EgnaroDev
Aug 05 2017 01:31
:clap:
@ma5one1 I don't think -target in .substr() would work
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:32
@EgnaroDev thank you
CamperBot
@camperbot
Aug 05 2017 01:32
ma5one1 sends brownie points to @egnarodev :sparkles: :thumbsup: :sparkles:
CallMeOrange
@EgnaroDev
Aug 05 2017 01:32
Did it pass for you?
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:33
give me a moment..
@kumquatfelafel thank you
CamperBot
@camperbot
Aug 05 2017 01:33
ma5one1 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:40
I was missing.
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
if (str.substr(-target.length) === target)
{
return true;
}
else {
return false;
}
}

confirmEnding('bastian', 'n');
Is length a numerical count of indexes in this case??
Moisés Man
@moigithub
Aug 05 2017 01:43
repl.it/languages/javascript
and write "hello".length
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:45
@moigithub i get that, but in this particular case. It has a reverse count and applied to the substr???
Moisés Man
@moigithub
Aug 05 2017 01:48
go back to that page and write
"hello".substr(-1)
"hello".substr(-2)
"hello".substr(-3)
one by one.. play with the number
John
@AnonymousLords
Aug 05 2017 01:49
Guys whats the point of the Confirm the Ending challange? If their is already a keyword to do it, then why do it without it?
kumquatfelafel
@kumquatfelafel
Aug 05 2017 01:49
var hello = "Hello " + "World"; //here, we are basically just deciding, "This will be Hello World"... which in some cases is okay. But what if we wanted it to be something else? One option...
var a = "Hello ";
var b = "World";
var c = a + b; //here we use variables that hold the strings "Hello " and "World"... if we wanted to change c, we could simply change value of a or b.

Moving on to functions, it's basically the same idea.

function greeting(greet, name) {
console.log(greet + name + '!');
}
//         vv       vv these values, called arguments, passed in to function
greeting("Howdy ", "neighbor"); //outputs "Howdy neighbor!" in console
greeting("Good day, ", "sir"); //outputs "Good day, sir!" in console

Note that in function, we are not overly reliant on literal values (e.g. 1, "hello", etc.)

One of the goals when writing a function is to write a piece of code that performs a certain task and is reusable, given a number of different potential values. If the task in question is, say, five lines of code... by calling a function instead, we can save a significant amount of time coding (and also, makes our code easier to read and maintain).

and so on and so forth.

John
@AnonymousLords
Aug 05 2017 01:50
x :point_up: August 4, 2017 9:49 PM @kumquatfelafel
ok
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:52
Salamat pare's.
@moigithub thank you
CamperBot
@camperbot
Aug 05 2017 01:52
ma5one1 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3556 | @moigithub |http://www.freecodecamp.com/moigithub
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:52
@AnonymousLords thank you
CamperBot
@camperbot
Aug 05 2017 01:52
ma5one1 sends brownie points to @anonymouslords :sparkles: :thumbsup: :sparkles:
John
@AnonymousLords
Aug 05 2017 01:52
@ma5one1 what?
Maximino V. Jardin III
@ma5one1
Aug 05 2017 01:53
@AnonymousLords its thanks guys in tagalog
CamperBot
@camperbot
Aug 05 2017 01:53
ma5one1 sends brownie points to @anonymouslords :sparkles: :thumbsup: :sparkles:
:warning: ma5one1 already gave anonymouslords points
John
@AnonymousLords
Aug 05 2017 01:53
This message was deleted
John
@AnonymousLords
Aug 05 2017 01:59
@kumquatfelafel :point_up: August 4, 2017 9:49 PM
kumquatfelafel
@kumquatfelafel
Aug 05 2017 02:01

@AnonymousLords There is probably already code/functions out there that does almost everything you want to do most of the time. That being said, you may not be able to find that code... or you might want to do something slightly different, or ....

So at some point, you're presumably going to have to write your own functions. :p

It's good to be able to practice with writing functions that have an existing counterpart, so there's plenty of documentation, and you have a pretty easy way of checking if your algorithm is behaving as you would expect.

Things you attempt later on may rely on poorly documented libraries, and may not be things others before you have attempted, and you'll have to rely far more on your own wits to survive. ;)

Basically, better to get used to writing algorithms that are relatively straightforward, such that they probably are methods for some object, or can be found in some library of basic functions.... then to rely on said functions as a crutch until one day you suddenly realize "Hey, I can't use this for everything!"

John
@AnonymousLords
Aug 05 2017 02:03
Okay
kumquatfelafel
@kumquatfelafel
Aug 05 2017 02:03
There's pretty much no way for you to know "all the functions" and know what all of them do and where they can be found. So being able to write your own functions and read/understand documentation is an important part of coding
John
@AnonymousLords
Aug 05 2017 02:03
Okay]
But it can also make code less complciated
kumquatfelafel
@kumquatfelafel
Aug 05 2017 02:06
I think a good rule of thumb, at least when starting out is to say "Could I code this function myself?" and "How would I go about doing that?". A large part of understanding is doing, and you should probably have a pretty good understanding of what a function actually does before you throw it into your code all willy nilly. :p
John
@AnonymousLords
Aug 05 2017 02:06
Okay
How do they make games like Forza or Battle feild
kumquatfelafel
@kumquatfelafel
Aug 05 2017 02:07
At first, you don't have to really worry about your code being the ultimate in elegance and conciseness. You're just acquiring skills that can help you later, and familiarizing yourself with the language... with for loops, etc.
John
@AnonymousLords
Aug 05 2017 02:07
Okay
Do they code it from the start, or make make programs that code
kumquatfelafel
@kumquatfelafel
Aug 05 2017 02:11

I couldn't say how a specific game is coded.

Have to go for now.

John
@AnonymousLords
Aug 05 2017 02:12
Okay
Wait does subtring work on arrays
Kelechi Chinaka
@ke1echi
Aug 05 2017 02:15
no..strings
John
@AnonymousLords
Aug 05 2017 02:15
Oh
How to get teh last ietm in a array
i forgot >.<
;-;
Kelechi Chinaka
@ke1echi
Aug 05 2017 02:16
array[array.length - 1]
Moisés Man
@moigithub
Aug 05 2017 02:16
array.pop()
John
@AnonymousLords
Aug 05 2017 02:17
Slice also worked
thanks @moigithub @kelechy Its the one thing i alays forget lol
CamperBot
@camperbot
Aug 05 2017 02:17
anonymouslords sends brownie points to @moigithub and @kelechy :sparkles: :thumbsup: :sparkles:
:star2: 3557 | @moigithub |http://www.freecodecamp.com/moigithub
Jefferson
@jeffersonnnn
Aug 05 2017 02:50
hi guys, thanks for being amazing to us newbs.
Jefferson
@jeffersonnnn
Aug 05 2017 02:56
I have a question from the Truncate the String challenge.
Here is my code for the challenge.


function truncateString(str, num) {
var newStr = 0;
if (str > num) {
newStr = str.length.slice.length(num) + "...";
} else if (num <= 3) {
return str;
}
newStr = str;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
I can imagine that i am quite wrong, bit i can't make out where my error is coming from exactly. Help, please?
Coy Sanders
@coymeetsworld
Aug 05 2017 03:36
one glaring issue is you're only returning a string if the number is less than 3 @jeffersonnnn
also you don't compare str to num
you want to compare the length
Jefferson
@jeffersonnnn
Aug 05 2017 03:50
thanks for the insights, kind internet stranger @coymeetsworld
CamperBot
@camperbot
Aug 05 2017 03:50
jeffersonnnn sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2986 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Aug 05 2017 03:52
np
Anand Kumar Parhi
@binarylogician
Aug 05 2017 06:42
In a CRM project I'm storing leads(there are 1000+ leads, I'm getting 10 at a time for pagination) that I get from an api in localStorage. On second load I want to use the local storage to show stored data immediately and update the store with new leads if any new leads are available in the api. To me this seems like he best UX, but I'm unsure about how to go about this.
Also whenever I get new data I don't want to re render the whole page, just render in the new leads.
How do I achieve this?
TL DR: How n when to update localStorage data(which came from an api) that I have persisted with redux persist efficiently with new items that might be available in the api?
KinderPreet Singh
@kindercappy
Aug 05 2017 06:53
Please check out my Simon game.
Please do report the bugs you find. Thanks :grinning:
https://codepen.io/kindercappy/full/rzWgvm/
alpox
@alpox
Aug 05 2017 08:04
@state0fmind every time you get new data, you directly store it in the localStorage and redux. On applicationstart you set the initialValue of your leads array to what you get from the localStorage. For only rerendering the leads instead of everything, there is react
heroiczero
@heroiczero
Aug 05 2017 09:34
@kindercappy nice job :+1: it works as intended from what i could tell
Abhinav Mishra
@abhinav-m
Aug 05 2017 10:27
can people guide me how to make this responsive
im using flex
what should i read up / learn to make it responsive without using bootstrap etc
(no framework)
just know the basics of flex for now
heroiczero
@heroiczero
Aug 05 2017 10:30
@abhinav-thinktank you can try @media https://developer.mozilla.org/en-US/docs/Web/CSS/@media
Abhinav Mishra
@abhinav-m
Aug 05 2017 10:30
@heroiczero :+1: ty
CamperBot
@camperbot
Aug 05 2017 10:30
abhinav-thinktank sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1574 | @heroiczero |http://www.freecodecamp.com/heroiczero
Jefferson
@jeffersonnnn
Aug 05 2017 10:53
Hey guys, i am stuck on the Truncate a String challenge. Here is my code

function truncateString(str, num) {

if (str > num.length) {
str = str.slice(num.length + 3) + "...";
} else if (num.length <= 3) {
str = num.slice.length + 3 + "...";
} else {
return str;
}

}
truncateString("A-tisket a-tasket A green and yellow basket", 11);
Joseph Henshaw
@Big-jo
Aug 05 2017 11:06
@Anthony-Armfield yh i just saw the mistake this morning and i changed it but i don't think the file is still linked
heroiczero
@heroiczero
Aug 05 2017 11:07
@jeffersonnnn i think you want str.length. num is already a number, so i dont know what you are doing with num.length
Joseph Henshaw
@Big-jo
Aug 05 2017 11:07
  <script scr ="jsfile.js"></script>
@Anthony-Armfield okay i just found the silly mistake scr instead of src
mustimuu
@mustimuu
Aug 05 2017 11:12
hello guys
i am working with a wordpress template. i want to link to an extern stylesheet, my own. i dont want to work in theirs
what can i do? all the files is on cyberduck
heroiczero
@heroiczero
Aug 05 2017 11:16
@jeffersonnnn
function truncateString(str, num) {

if (str.length > num) { // use str.length, not num.length because num is already a number.
return str.slice(0,num - 3) + "..."; // need to return to output a string and need an initial value for slice
} else if (num <= 3) {
return str.slice(0,num) + "..."; // need a return to output the string and slice is incorrectly used
} else {
return str;
}

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Jefferson
@jeffersonnnn
Aug 05 2017 11:17
@heroiczero alright, i see what you are talking about. Any other insights?
just saw this, thanks. @heroiczero
CamperBot
@camperbot
Aug 05 2017 11:17
jeffersonnnn sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1575 | @heroiczero |http://www.freecodecamp.com/heroiczero
mustimuu
@mustimuu
Aug 05 2017 11:18
guys. i am working on a wordpress template. and i want to link to an extern stylesheet. I dont want to work in their 60000 code css file. How can i do so
heroiczero
@heroiczero
Aug 05 2017 11:20
@jeffersonnnn it still does not pass the test but I will let you figure that out. Hint: It has to do with the order of the if statements.
Joseph Henshaw
@Big-jo
Aug 05 2017 11:39
var FirstName = document.getElementById('firstName').value;
var Destination = document.getElementById('destination').value;

function StoreObj() {
console.log(FirstName);
}
i have this code and the StoreObj function is linked with an Onclick event handler , and it keeps giving me cannot read property 'value' of null. any ideas?
Stephen James
@sjames1958gm
Aug 05 2017 11:46
@Big-jo Probably the elements are not loaded when this runs
Joseph Henshaw
@Big-jo
Aug 05 2017 11:49
the elements are all loaded because i have to click the button first which means it's all loaded
but lemme use a document ready method
Stephen James
@sjames1958gm
Aug 05 2017 11:51
@Big-jo Move your script to the end of the <body>
@Big-jo document.getElementById('firstName').value; when this code runs in the head, the elements are not loaded yet, which is why you get the error
Joseph Henshaw
@Big-jo
Aug 05 2017 11:54
oh @sjames1958gm can't i use document.ready() method
cykins4good
@cykins4good
Aug 05 2017 11:54
Stephen James
@sjames1958gm
Aug 05 2017 11:54
@Big-jo You can, but it is also recommended to load scripts at the end of the body
Joseph Henshaw
@Big-jo
Aug 05 2017 11:55
okay thanks @sjames1958gm
CamperBot
@camperbot
Aug 05 2017 11:55
big-jo sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8247 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 05 2017 11:55
@cykins4good You have to create a second object,
cykins4good
@cykins4good
Aug 05 2017 11:55
Hi to you all.i find it difficult to solve this.I as asked to add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings.
Stephen James
@sjames1958gm
Aug 05 2017 11:56
@cykins4good Which means, don't repeat var myMusic = add the album object inside the existing array
cykins4good
@cykins4good
Aug 05 2017 11:56
@sjames1958gm ok, i will try that
Joseph Henshaw
@Big-jo
Aug 05 2017 11:59
@sjames1958gm hmmm you were right it worked, no more errors
cykins4good
@cykins4good
Aug 05 2017 12:01
@sjames1958gm i came up with this,but still not passing me
Joseph Henshaw
@Big-jo
Aug 05 2017 12:02
@sjames1958gm when i click the submit button, it doesnt print the first name to console as it should
Stephen James
@sjames1958gm
Aug 05 2017 12:02
@cykins4good Closer, but your added lines are not inside of an object, recall objects are inside {}
Joseph Henshaw
@Big-jo
Aug 05 2017 12:02
it just comes up empty
Stephen James
@sjames1958gm
Aug 05 2017 12:04
@Big-jo You are getting the value into FirstName when it is empty not when the button is pressed.
var FirstNameElem = document.getElementById('firstName');

function StoreObj() {
console.log(FirstNameElem.value);
}
@Big-jo Save the element reference then read the value on click
moamenfnanan
@moamenfnanan
Aug 05 2017 12:05
Joseph Henshaw
@Big-jo
Aug 05 2017 12:06
@sjames1958gm how?
moamenfnanan
@moamenfnanan
Aug 05 2017 12:06
whats wrong
Stephen James
@sjames1958gm
Aug 05 2017 12:06
@Big-jo Look up a little I showed you
@moamenfnanan '10' is a string not a number
Joseph Henshaw
@Big-jo
Aug 05 2017 12:08
@sjames1958gm oh thanks
CamperBot
@camperbot
Aug 05 2017 12:08
big-jo sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: big-jo already gave sjames1958gm points
Stephen James
@sjames1958gm
Aug 05 2017 12:08
@Big-jo :+1:
Abhinav Mishra
@abhinav-m
Aug 05 2017 12:10
@sjames1958gm i have yet to make the final ui changes
but here is the (near) finished version
is my application structure better this time around
mustimuu
@mustimuu
Aug 05 2017 12:17
@mustimuu
hello
can someone help me with wordpress??
I want to link to an external stylesheet
I do not want to use their css file
Joseph Henshaw
@Big-jo
Aug 05 2017 12:18
var UsrObjects {
Name : FirstName.value,
destination : Destination.value
};
is this correct if i want to put the variables in an object? @sjames1958gm
Stephen James
@sjames1958gm
Aug 05 2017 12:18
@abhinav-thinktank Much better. I would consider making the edit/add recipe another component, but it is not required
Abhinav Mishra
@abhinav-m
Aug 05 2017 12:19
@sjames1958gm ok , yes that added alot of headache to my functions
thank you!
working on making it responsive now
@sjames1958gm ty
CamperBot
@camperbot
Aug 05 2017 12:19
abhinav-thinktank sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8248 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 05 2017 12:19
@Big-jo That looks fine.
@abhinav-thinktank :+1:
cykins4good
@cykins4good
Aug 05 2017 13:05
@sjames1958gm i am still stuck in the challenge.
Darth Skywalker
Aug 05 2017 13:14
@cykins4good you're missing , (comma) on line 12
after }
also change line 20 from ], ro ]}
cykins4good
@cykins4good
Aug 05 2017 13:30
@AdiSkywalker i have effected the changes.But its not passing me
Darth Skywalker
Aug 05 2017 13:32
@cykins4good line 19 : missing "
cykins4good
@cykins4good
Aug 05 2017 13:40
CamperBot
@camperbot
Aug 05 2017 13:40
cykins4good sends brownie points to @adiskywalker :sparkles: :thumbsup: :sparkles:
cykins4good
@cykins4good
Aug 05 2017 13:41
thanks a lot @sjames1958gm
CamperBot
@camperbot
Aug 05 2017 13:41
cykins4good sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8249 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Maluchukwu
@Maluchukwu
Aug 05 2017 14:00
Hello coders, please can anyone assist me with the minimax algorithm for the tic tac toe project? I'm currently building the tic tac toe project and I've struggled to implement the minimax algorithm for days now. I've understood how it works but still haven't been able to implement it. I've read blogs and even watched youtube videos but those werent helpful. Please someone should help me. Please share a link to your project of you've done it. I'd appreciate😢😢
@cmccormack ???
Also, i dont know react or angular. Just jquery😢
Hemakshi Sachdev
@hemakshis
Aug 05 2017 14:02
Hey, Can please someone review my JavaScript Calculator and tell if they could find any bug. Would Really appreciate it :)
https://codepen.io/hemakshis/pen/oeBNdK?editors=1100

@magiclalala
Aug 05 2017 14:05

//Basic JavaScript--Word Blanks
var result = "";

return result;
}

wordBlanks("dog ", "big ", "ran ", "quickly");
//why can't i pass this?somewhere goes whong?

cykins4good
@cykins4good
Aug 05 2017 14:05
Please i need help to pass this challenge.
Aug 05 2017 14:10
@hemakshis - just a couple quick tests - entering a number (or string of text) like 88.33.22 is accepted by the calculator. Entering 2.2 + 6 = give the answer 8.2, but then adding additional number clicks appends them to the display instead of (what a typical calculator does) clearing the display and starting a new entry. Entering 2.2 + 6 = gives the answer 8.2. Continuing as above, without clearing, entering 5 + 6= gives the result 73.2 which the display shows is the calculation 2.2 + 65 + 6. Basically - chaining operations (or completing one and starting another without clearing) doesn't seem to be handled as a typical calculator seems to do. Just a couple comments for you...
@cykins4good - what kind of error do you see when you hover over that red :x: ?
Maluchukwu
@Maluchukwu
Aug 05 2017 14:12

Hello coders, please can anyone assist me with the minimax algorithm for the tic tac toe project? I'm currently building the tic tac toe project and I've struggled to implement the minimax algorithm for days now. I've understood how it works but still haven't been able to implement it. I've read blogs and even watched youtube videos but those werent helpful. Please someone should help me. Please share a link to your project of you've done it. I'd appreciate😢😢
@cmccormack ???

Hemakshi Sachdev
@hemakshis
Aug 05 2017 14:17
@khaduch Thanks a lot.. I will definitely try to correct them..
CamperBot
@camperbot
Aug 05 2017 14:17
hemakshis sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Aug 05 2017 14:23
@Maluchukwu - I haven't done this one yet - found a link to this article - have you seen that one? I'm sure that someone else can come along who has completed this project...
cykins4good
@cykins4good
Aug 05 2017 14:23
@khaduch it said expected to see a function or assignment, but instead saw an error
Aug 05 2017 14:26
@cykins4good - okay - so it means that that line of code is not correct... It looks like you are on the right track, though, insofar as you should be referencing myStorage - but you have to assign the results of what you are getting from myStorage to the gloveBoxContents variable - so remove that string "maps" after the equal sign, and move the myStorage. up there. Then you have to add the appropriate property references to "dig down" into the object, as they did in the example.

@magiclalala
Aug 05 2017 14:38

var result = "";

return result;
}

wordBlanks("dog ", "big ", "ran ", "quickly");

i can't pass the challenge.
Joel Y.
@zapcannon99
Aug 05 2017 14:40
@magiclalala you are missing some spaces
I think
Aug 05 2017 14:40
@magiclalala - you have to insert spaces between each word (between each of the function argument variables that you use) in your composition of result. So any place you put one of the variable, make sure to surround it with " " - like " " + myVerb + " " as needed - you only need one space between each word in the final result.
Joel Y.
@zapcannon99
Aug 05 2017 14:40
for example, before brown
Guderian Raborg
@hypercuber
Aug 05 2017 14:42
Hey yall, I am starting to learn canvas but I am not sure how to do something when let say a rectangle is click.
Maybe add to one of my pens https://codepen.io/hypercuber/#
Hills
@Hillsie
Aug 05 2017 14:43
Evening (where I am :smile: ), I’ve added my palindrome solution for comment. I am interested in knowing what the JS way is? Ta
https://gist.github.com/anonymous/48fa4cb9d1aea5cd71fb6437c6ab7f76

@magiclalala
Aug 05 2017 14:46
Aug 05 2017 14:52

@Hillsie - you can do it with these two lines of code in the function body:

  var lcString = str.toLowerCase().replace(/[\W_]/g, ''); // strip out underscores, and non-word characters;
// split the string, reverse it and join, compare to the original
return lcString === lcString.split('').reverse().join('');

And I'm not sure that there isn't a more concise way to write that, but that works...

Maluchukwu
@Maluchukwu
Aug 05 2017 14:53
@khaduch thanks. I've seen that before too. It was helpful in understanding how the algorithm works but not in implementation
CamperBot
@camperbot
Aug 05 2017 14:53
maluchukwu sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Hills
@Hillsie
Aug 05 2017 14:53
@khaduch :smile: JS is always shorter. Thanks.
CamperBot
@camperbot
Aug 05 2017 14:53
hillsie sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:

@magiclalala
Aug 05 2017 14:54
@khaduch thanks a lot :D @zapcannon99 the same to you
CamperBot
@camperbot
Aug 05 2017 14:54
magiclalala sends brownie points to @khaduch and @zapcannon99 :sparkles: :thumbsup: :sparkles:
Aug 05 2017 14:54
@magiclalala - you're welcome
@Hillsie - you're welcome
@Maluchukwu - you're welcome - I hope you find some help. I have to try this tic-tac-toe exercise sometime soon!
cykins4good
@cykins4good
Aug 05 2017 14:57
@khaduch i came up with this, still not working
Aug 05 2017 14:59
@cykins4good - please remove the string after the var gloveBoxContents = and move the myStorage.car...... line up after the equal sign. Then you're pretty close - the one thing that you're missing is that the "glove box" is inside the car. so - myStorage.car.inside and then the {"glove box"]. "maps" should not be at the end of that line, that is the value that will be in that property.
Aug 05 2017 15:06
@cykins4good - one shortcoming in that example is that they are not showing the assignment of the object references to a variable - that is potentially throwing you off a little. But just build the chain of property references to get down to the item that you want - there is probably enough information in my previous comment to have what you need. It's an important concept to understand for the many challenges and exercises ahead!
John
@nekfhpm
Aug 05 2017 15:08
test
Hemakshi Sachdev
@hemakshis
Aug 05 2017 15:10
@khaduch I've corrected everything that you said.. but now I have a new problem.. :sweat_smile:
Whenever I subtract a float with an int or vice-versa or both floats I get ans as .999998
for example: for 2.3 - 0.3 I get ans as 1.99999999998
CallMeOrange
@EgnaroDev
Aug 05 2017 15:13
Can you use .toFixed(2)?
Never mind you are trying to round it
Hemakshi Sachdev
@hemakshis
Aug 05 2017 15:16
@EgnaroDev But if I applied this to my final ans it would round-off even those numbers whose ans I should get in a float
CallMeOrange
@EgnaroDev
Aug 05 2017 15:18
@hemakshis Sorry, I'm not ready for calculator yet but if you do 2.3 - 0.3 on normal calculator, you get 2, you should be able to round 1.99...
Hemakshi Sachdev
@hemakshis
Aug 05 2017 15:19
@EgnaroDev No Problem :) Anyways Thanks :)
CallMeOrange
@EgnaroDev
Aug 05 2017 15:19
You are welcome
Austin Wiggins
@austinwiggins
Aug 05 2017 15:19
I'm trying to look at wikipedia viewers to get an idea of how to create one. In this pen that I looked at, https://codepen.io/denislav99/pen/JKPbyg, what does result.query.pages mean?
and do?
Kim Ford
@kimfucious
Aug 05 2017 15:20

Hi, all… looking for a bit of help to wrap my mind around closure. While it my be beyond the call of the [Show the Local Weather challenge] (https://www.freecodecamp.org/challenges/show-the-local-weather), I’m trying to do things “right”, and when I say right, I mean not exposing variables from outside the socpe of my functions just to make the thing work.

I’ve got a Codepen up here.

You’ll notice on line 22 of my JS that I do not use Var/Let, thus exposing the return of the ajax call globally.

What I’d rather understand how to do, is to call the swapTemp function in such a way that it knows the values of tempC and tempF from the getWeather function, but I’m a bit mind boggled in trying to do so.

Got milk?

CallMeOrange
@EgnaroDev
Aug 05 2017 15:21
@austinwiggins I think result is a data like json and I'm sure query.pages is accessing objects from result
Austin Wiggins
@austinwiggins
Aug 05 2017 15:22
Thanks @EgnaroDev :)
CamperBot
@camperbot
Aug 05 2017 15:22
austinwiggins sends brownie points to @egnarodev :sparkles: :thumbsup: :sparkles:
Hills
@Hillsie
Aug 05 2017 15:38
Is there a better way of finding the longest word in JS. My example solution below
function findLongestWord(str) {
/*  Input: sentence to find the longest word
return: size of the longest word
*/
strArray = str.split(' ');
var longest ="";
for ( var i = 0; i < strArray.length; i++){
if (strArray[i].length > longest.length){
longest = strArray[i];
}
}
return longest.length;
}

console.log(findLongestWord("The quick brown fox jumped over the lazy dog"));
Aug 05 2017 15:41
@kimfucious - I'm thinking that it would be as simple as moving your assignment of the .click for the switch into the callback for the success property of your getWeather function? Have I tried it - no... but you could then enclose your tempC and tempF values within the function. At least I think that would work because now you have a global for currentWeather.
Kim Ford
@kimfucious
Aug 05 2017 15:43
@khaduch Hi Ken, thanks. Yes, the code works as it stands now, because I’ve exposed the currentWeather object. What I’d like to do is remove currentWeather from the global scope and then figure out how to make it still work…
CamperBot
@camperbot
Aug 05 2017 15:43
kimfucious sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
CallMeOrange
@EgnaroDev
Aug 05 2017 15:44
@Hillsie
this is my solution
function findLongestWord(str) {
str = str.split(" ");
var array = [];
for (var i = 0; i < str.length; i++) {
var lengthn = str[i].length;
array.push(lengthn);
}
array.sort(function(a, b){
return a - b;
});
return array.pop();

}

findLongestWord("The quick brown fox jumped over the lazy dog");
Really old, I can change it if I want to
Hills
@Hillsie
Aug 05 2017 15:48
thanks for sharing @EgnaroDev
CamperBot
@camperbot
Aug 05 2017 15:48
hillsie sends brownie points to @egnarodev :sparkles: :thumbsup: :sparkles:
cykins4good
@cykins4good
Aug 05 2017 15:48
@khaduch i have finally solved the challenge.Thanks a lot.This is my solution
CamperBot
@camperbot
Aug 05 2017 15:48
cykins4good sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Hills
@Hillsie
Aug 05 2017 15:50
:+1: @cykins4good
CallMeOrange
@EgnaroDev
Aug 05 2017 15:50
function findLongestWord(str) {
var array = [];
for (var i = 0; i < str.split(" ").length; i++) {
array.push(str.split(" ")[i].length);
}
return array.sort(function(a, b) {
return a - b;
})[array.length - 1];
}
findLongestWord("The quick brown fox jumped over the lazy dog");
I changed it
Aug 05 2017 15:52

@Hillsie - mu "Find Longest Word" looks like this:

function findLongestWord(str) {
var words = str.split(' '),
longest = 0,
i;
for (i = 0; i < words.length; i++) {
var l = words[i].length;
if (l > longest) longest = l;
}
return longest;
}

But I'll bet there would be a way to use .reduce() and do a really short version?

Kim Ford
@kimfucious
Aug 05 2017 15:53
@khaduch Oddly, I was able to do this on the first try with getWeather inside of getCoords, but I just can’t seem to wrap my mind around how to do this with swapTemp.
CallMeOrange
@EgnaroDev
Aug 05 2017 15:53
Hm.. I never seen something like this
 var words = str.split(' '),
longest = 0,
i;
Aug 05 2017 15:53
@cykins4good - you're welcome! good luck as you continue.
Hills
@Hillsie
Aug 05 2017 15:53
CamperBot
@camperbot
Aug 05 2017 15:53
hillsie sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Aug 05 2017 15:53
@EgnaroDev - it's a value way to declare a number of variables...
CallMeOrange
@EgnaroDev
Aug 05 2017 15:53
Yeah
Nice
Hills
@Hillsie
Aug 05 2017 15:55
@khaduch You’re i is global variable without the var
stet that
you’re using comma's
CallMeOrange
@EgnaroDev
Aug 05 2017 15:55
@Hillsie i is already a variable
var words = str.split(' '),
longest = 0,
i;
looks like this
var words = str.split(' ');
var longest = 0;
var i;
Kim Ford
@kimfucious
Aug 05 2017 15:57
@EgnaroDev consider using the sort method on your array after the split…
function findLongestWord(str) {

var arr = str.split(" ");

arr.sort(function(a,b) {
return b.length - a.length;
});
return arr[0].length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Hills
@Hillsie
Aug 05 2017 15:57
Yip, recognised my crossed eyes
Aug 05 2017 15:58
@Hillsie @EgnaroDev - here's the .reduce() version I just came up with:
function findLongestWord(str){
return str.split(' ').reduce( (length, word) => {return word.length > length ? word.length : length }, 0);
}
Hills
@Hillsie
Aug 05 2017 15:58
@khaduch Like this short cuts if (l > longest) longest = l;
Stephen James
@sjames1958gm
Aug 05 2017 15:59
@khaduch Since you are only returning you can remove the {} and the return
return str.split(' ').reduce( (length, word) => word.length > length ? word.length : length , 0);
Aug 05 2017 16:01
@sjames1958gm - I was thinking that I could, I was just :chicken:
Hills
@Hillsie
Aug 05 2017 16:01
I better get to grips with that arrow function if I wanna play golf :) . Night night.
khaduch @khaduch - I have some other things that I should be doing right now... have a great day everyone!
CallMeOrange
@EgnaroDev
Aug 05 2017 16:02
@kimfucious Your solution looks good, this is a bit cleaner
function findLongestWord(str) {
return str.split(" ").sort(function(a,b) {
return b.length - a.length;
})[0].length;
}
b - a is annoying so I came up with this
function findLongestWord(str) {
return str.split(" ").sort(function(b, a) {
return a.length - b.length;
})[0].length;
}
Michael Norris
@Norrismi
Aug 05 2017 16:07
Hello, I have stumbled my way through the JS Basic Algorithm scripting in FCC. I would like to review these skills before moving on. Should I just run through these exercises once again?
CallMeOrange
@EgnaroDev
Aug 05 2017 16:07
@Norrismi you should, try to improve all of your code if you can
Its good to create another solution
if you don't want to do same algorithms again, do new one here http://www.codewars.com/dashboard
Michael Norris
@Norrismi
Aug 05 2017 16:09
@EgnaroDev Thanks! Do you know of any alternative sites that offer equal difficulty of challenges?
CamperBot
@camperbot
Aug 05 2017 16:09
norrismi sends brownie points to @egnarodev :sparkles: :thumbsup: :sparkles:
Aug 05 2017 16:09
@Hillsie @EgnaroDev - after @sjames1958gm made his comment:
function findLongestWord(str){
return str.split(' ').reduce( (length, word) => word.length > length ? word.length : length, 0);
}
thanks @sjames1958gm
CamperBot
@camperbot
Aug 05 2017 16:09
khaduch sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8250 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
CallMeOrange
@EgnaroDev
Aug 05 2017 16:10
@Norrismi well I think codewars is good one
There is also codefight
Michael Norris
@Norrismi
Aug 05 2017 16:10
@EgnaroDev awesome thanks!
CamperBot
@camperbot
Aug 05 2017 16:10
:warning: norrismi already gave egnarodev points
norrismi sends brownie points to @egnarodev :sparkles: :thumbsup: :sparkles:
CallMeOrange
@EgnaroDev
Aug 05 2017 16:10
You are welcome
Kim Ford
@kimfucious
Aug 05 2017 16:13
@EgnaroDev This might be a wrong thig to say, so I invite others to discuss, but when dealing with strings: unless you have a quick solution, move(split) to an array. After than you have a wealth of methods that you can use to transform, filter, and reduce with…
Panagiotis Tsimpoukellis
@PanChee00
Aug 05 2017 16:18
hey guys. i have a question
Write a function countBs that takes a string as it's only argument and returns a number that indicates how many uppercase "B" characters are in the string . I found this in a book of JS I couldn't solve it
Var countBs = function(string, n){
for (n=0 ;n<string.length; n+=1)
{
number = string.charAt(n);
if(number === 'B')
{
Console.log();
}
}
what's my fault?
Manish Giri
@Manish-Giri
Aug 05 2017 16:19
@PanChee00 a couple of things
most important being, if letter is B
Panagiotis Tsimpoukellis
@PanChee00
Aug 05 2017 16:20
@Manish-Giri could you help me please
Kim Ford
@kimfucious
Aug 05 2017 16:20
@EgnaroDev Thanks for the input. I don’t mind b-a, as it implies a reverse sort order which is what I believe we were aiming for. Regardless, there are many ways to skin a cat, no? Often I am less concise in the code examples I share for illustrative purposes, as I think that’s more helpful than trying to be clever. For me at least, when trying to learn something, it’s best to have it all spelled out.
CamperBot
@camperbot
Aug 05 2017 16:20
kimfucious sends brownie points to @egnarodev :sparkles: :thumbsup: :sparkles:
Manish Giri
@Manish-Giri
Aug 05 2017 16:20
you're not doing anything
CamperBot
@camperbot
Aug 05 2017 16:20
Manish Giri
@Manish-Giri
Aug 05 2017 16:20
@PanChee00 this here
if(number === 'B')
{
Console.log();
}
ideally you should increment a variable here, that will keep track of the count
Panagiotis Tsimpoukellis
@PanChee00
Aug 05 2017 16:21
ook\
Joseph
@revisualize
Aug 05 2017 17:30
cbot
CamperBot
@camperbot
Aug 05 2017 17:30
you called?
Luis Felipe López G.
@luishendrix92
Aug 05 2017 18:05
a functional way would to to .filter 'B' and .length the result
Luis Felipe López G.
@luishendrix92
Aug 05 2017 18:11
or with ramdaJS :trolleybus: :trollface:
import { compose, filter, equals, length } from 'ramda'

const countBs = compose(length, filter(equals('B')))
kappa
lerebourx
@lerebourx
Aug 05 2017 18:14
Hello, I'm startin in the world of Javascript programming. What are your advice?
Kelechi Chinaka
@ke1echi
Aug 05 2017 18:24
@luishendrix92 can i hit you with a quick one?
Luis Felipe López G.
@luishendrix92
Aug 05 2017 18:26
a quick what
Kelechi Chinaka
@ke1echi
Aug 05 2017 18:26
question
Luis Felipe López G.
@luishendrix92
Aug 05 2017 18:26
sure
Kelechi Chinaka
@ke1echi
Aug 05 2017 18:30
Luis Felipe López G.
@luishendrix92
Aug 05 2017 18:30
in what particular language?
oh sorry
JS ok
lol
Kelechi Chinaka
@ke1echi
Aug 05 2017 18:31
function myParseInt(str) {
return (str.includes('.'))? NaN : parseInt(str);
}
fails a test
Luis Felipe López G.
@luishendrix92
Aug 05 2017 18:31
the rules are clearly listed
It should make the conversion if the given string only contains a single integer value (and eventually spaces - including tabs, line feeds... - at both ends)
For all other strings (including the ones representing float values), it should return NaN
It should assume that all numbers are not signed and written in base 10
says "including", not only restricted to
so you're only taking in consideration the floating point .
"10 kittens"
or "10__"
Regexp would be the easiest way to solve it
it prevents a lot of headaches and loops
Kelechi Chinaka
@ke1echi
Aug 05 2017 18:34
am not good with regex
how do i check for those conditions with regex
Luis Felipe López G.
@luishendrix92
Aug 05 2017 18:36
I'm trying t osolve it first
Stephen James
@sjames1958gm
Aug 05 2017 18:36
@kelechy if the string isn't spacesdigitsspaces then NaN
Luis Felipe López G.
@luishendrix92
Aug 05 2017 18:36
it's tricky
Stephen James
@sjames1958gm
Aug 05 2017 18:36
function myParseInt(str) {
if (!str.match(/^\s*\d+\s*$/)) return NaN return +str; } Luis Felipe López G. @luishendrix92 Aug 05 2017 18:36 because for example there are intermediate spaces that break the parsing, so they must be removed beforehand Kelechi Chinaka @ke1echi Aug 05 2017 18:38 what does match do at that code @sjames1958gm Luis Felipe López G. @luishendrix92 Aug 05 2017 18:38 nvm the inbetween spaces should not be allowed Stephen James @sjames1958gm Aug 05 2017 18:38 @kelechy return/true/false if the regex matches or not Kelechi Chinaka @ke1echi Aug 05 2017 18:38 so all spaces should be removed @luishendrix92 Luis Felipe López G. @luishendrix92 Aug 05 2017 18:39 ok so my first solution tht passed all the hidden tests is function myParseInt(str) { return /[^\s\d]/.test(str) || /\d\s+\d/.test(str) ? NaN : parseInt(str, 10) } and the best solution is function myParseInt(str) { return /^\s*\d+\s*$/.test(str) ? +str : NaN;
}
Kelechi Chinaka
@ke1echi
Aug 05 2017 18:40
ok.. my regex not good @sjames1958gm
Luis Felipe López G.
@luishendrix92
Aug 05 2017 18:40
since all numbers are guaranteed base 10
+str type coercion is safe
or you could make use of the new .trim() method
and just do /^\d+$/ Kelechi Chinaka @ke1echi Aug 05 2017 18:42 ok thanks guys Luis Felipe López G. @luishendrix92 Aug 05 2017 18:42 which means "matches the start of the string, 1 or more digits and the end of the string" Kelechi Chinaka @ke1echi Aug 05 2017 18:42 thanks @luishendrix92 @sjames1958gm CamperBot @camperbot Aug 05 2017 18:42 kelechy sends brownie points to @luishendrix92 and @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 1759 | @luishendrix92 |http://www.freecodecamp.com/luishendrix92 :star2: 8251 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm CallMeOrange @EgnaroDev Aug 05 2017 18:42 There should be "regexwars" Kelechi Chinaka @ke1echi Aug 05 2017 18:42 u guys inspire me to learn more trim() removes spaces at the edges @luishendrix92 Maluchukwu @Maluchukwu Aug 05 2017 18:43 Hello coders, please can anyone assist me with the minimax algorithm for the tic tac toe project? I'm currently building the tic tac toe project and I've struggled to implement the minimax algorithm for days now. I've understood how it works but still haven't been able to implement it. I've read blogs and even watched youtube videos but those werent helpful. Please someone should help me. Please share a link to your project of you've done it. I'd appreciate😢😢 @cmccormack @QuincyLarson @Rafase282 @anyone??? Luis Felipe López G. @luishendrix92 Aug 05 2017 18:43 well that's why I said you should use it not only spaces LF,CR,Space,Tab once you remove them you're left with two situations: 1) either the number is consisted of only sequential digits 2) it's not, and it won't parse safely or would parse a float (tho parseInt gets rid of the decimals) CallMeOrange @EgnaroDev Aug 05 2017 18:45 Luis Felipe López G. @luishendrix92 Aug 05 2017 18:45 and with ^ and$ you're making sure there are no other characters on both ends
^ means start of the string
$means the end of it Stephen James @sjames1958gm Aug 05 2017 18:46 Another way to trim and match at the same time: function myParseInt(str) { var m = str.match(/^\s*(\d+)\s*$/)
return m ? +m[1] : NaN
}
Joseph Henshaw
@Big-jo
Aug 05 2017 18:47
is there any api that gives you the logitude and latidude of aplace
Luis Felipe López G.
@luishendrix92
Aug 05 2017 18:47
match is sometimes just innecessary
.test is more than ok for this one
spongebob time!
CallMeOrange
@EgnaroDev
Aug 05 2017 18:47
@Big-jo Try apixu, they should have everything you need
or use https://ipinfo.io/json for city and country
Joseph Henshaw
@Big-jo
Aug 05 2017 18:48
@EgnaroDev thanks
CamperBot
@camperbot
Aug 05 2017 18:48
big-jo sends brownie points to @egnarodev :sparkles: :thumbsup: :sparkles:
Luis Felipe López G.
@luishendrix92
Aug 05 2017 18:50
const spongebob = (s) => [...s].map((c, i) => i % 2 ? c.toLowerCase() : c.toUpperCase()).join
CallMeOrange
@EgnaroDev
Aug 05 2017 18:50
wow
Luis Felipe López G.
@luishendrix92
Aug 05 2017 18:51
you can make it one line if your parameters have shorter names
CallMeOrange
@EgnaroDev
Aug 05 2017 18:51
I see
Luis Felipe López G.
@luishendrix92
Aug 05 2017 18:52
I think .replace would also work
CallMeOrange
@EgnaroDev
Aug 05 2017 18:52
Yeah
I failed
Cody Seibert
@codyseibert
Aug 05 2017 18:53
@Maluchukwu here is another video on mini-max if you are interested
https://www.youtube.com/watch?v=x_Je9i3aKNk&lc=z120xfcpaouphhi1v23bf5pajmjrw1god04.1501947988962561
CallMeOrange
@EgnaroDev
Aug 05 2017 18:54
Joseph Henshaw
@Big-jo
Aug 05 2017 18:57
Please where can i get a drop down menu with Country and state
Calvin
@oakypokey
Aug 05 2017 19:00
Hey, does anyone know what I am doing wrong? I’m getting the error TypeError: addTogether(…) is not a function when I execute this:

var x = arguments[0];
var y = arguments[1];

function isNumber(x) {
return typeof x === "number";
}

return a + b;
}

if(!isNumber(x) || !isNumber(y)){
return undefined;
}

if(arguments.length == 2){
return x + y;
}

if(typeof a === "number"){
return a + arguments[0];
} else {
return undefined;
}
};

if(arguments.length > 1){
}

}

addTogether(2)(3);
Stephen James
@sjames1958gm
Aug 05 2017 19:01
@oakypokey You are not checking if arguments[1] exists or not
@oakypokey Also, you cannot reference arguments[0] inside of addAgain
Cody Seibert
@codyseibert
Aug 05 2017 19:03
@oakypokey what is this code trying to do? return a curry function for adding numbers?
Calvin
@oakypokey
Aug 05 2017 19:04
The challenge is to create a function that when given two numbers adds them together and when given one number returns a function that adds that one number to another number
so addTogether(2,3) would return 5 and addTogether(2) would return function(a){return 2 + a}
Luis Felipe López G.
@luishendrix92
Aug 05 2017 19:05
sounds like an FCC challenge I know
the faster way would be to check for the length of the arguments object-like array
if arguments.length < 2, then return a new function that accepts a b and returns arguments[0] + b
else, return arguments[0] + arguments[1]
or you can give names to the parameters in the outer function and check if b is undefined (it's what happens when the argument is ommited)
this way you don't have to do deal with arguments[]
Stephen James
@sjames1958gm
Aug 05 2017 19:08
@oakypokey (!isNumber(x) || (arguments.length > 1 && !isNumber(y)) This check will probably work
Calvin
@oakypokey
Aug 05 2017 19:10
Yeah that check worked! Thanks @sjames1958gm!
CamperBot
@camperbot
Aug 05 2017 19:10
oakypokey sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8252 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Calvin
@oakypokey
Aug 05 2017 19:11
and thanks @luishendrix92 and @codyseibert
Nick Forlivio
@whackdev
Aug 05 2017 19:12
has anyone had success running the clementinejs on their local machine? I've developed all the projects locally because I don't always have internet but I can't get this running
Cody Seibert
@codyseibert
Aug 05 2017 19:12
@oakypokey now that you seemed to have solved it, check this out:
function add(a, b = null) {
return b ? a + b : (c) => a + c;
}

console.log(add(2, 3));
Calvin
@oakypokey
Aug 05 2017 19:13
Ah, I’ve seen something simlar with linked lists in C++
Am I right in saying that b gets overwritten if specified in the call of the function?
Jim Tryon
@jimtryon
Aug 05 2017 19:14
That seems like an overkill to add two numbers
Cody Seibert
@codyseibert
Aug 05 2017 19:15
yeah, b will be overwritten
Calvin
@oakypokey
Aug 05 2017 19:16
Yeah I’m a little verbose 😅
Jim Tryon
@jimtryon
Aug 05 2017 19:16
Do you need to initialize b to null?
I think it’d be safer to initialize it to 0 (of the mindset to always avoid null)
Cody Seibert
@codyseibert
Aug 05 2017 19:17
nope, but it helps someone understand that b isn't really "required"
Jim Tryon
@jimtryon
Aug 05 2017 19:17
null doesn’t play nicely with a lot of code from what I’ve seen
Cody Seibert
@codyseibert
Aug 05 2017 19:17
what mindset is to avoid null?
Jim Tryon
@jimtryon
Aug 05 2017 19:18
null can lead to unpredictable results
Cody Seibert
@codyseibert
Aug 05 2017 19:18
I mean technically I probably should have just put b = undefined and not null
Stephen James
@sjames1958gm
Aug 05 2017 19:18
@codyseibert if b is zero that code will not work as it will return a function not a sum
Cody Seibert
@codyseibert
Aug 05 2017 19:18
good point
Jim Tryon
@jimtryon
Aug 05 2017 19:19
that is interesting, didn’t notice that
Cody Seibert
@codyseibert
Aug 05 2017 19:19
@sjames1958gm so something like this would be better right?
function add(a, b = undefined) {
return b !== undefined ? a + b : (c) => a + c;
}
Stephen James
@sjames1958gm
Aug 05 2017 19:20
@codyseibert Yes, makes it longer :( but more correcter :)
Jim Tryon
@jimtryon
Aug 05 2017 19:20
Isn’t undefined the same as null?
Stephen James
@sjames1958gm
Aug 05 2017 19:20
@jimtryon No,.
Cody Seibert
@codyseibert
Aug 05 2017 19:20
undefined is the default value of variables you declare without setting a value into them
null has to be manually set by the coder
Jim Tryon
@jimtryon
Aug 05 2017 19:21
Oh ok, that makes sense
Calvin
@oakypokey
Aug 05 2017 19:21
@codyseibert quick question: what would happen if I entered add(a, “asdkf”). Would it break it?
Cody Seibert
@codyseibert
Aug 05 2017 19:21
so,
let i;
i === undefined // true
Stephen James
@sjames1958gm
Aug 05 2017 19:21
@codyseibert If default is undefined, then no default values is needed?
Cody Seibert
@codyseibert
Aug 05 2017 19:22
@oakypokey the code would try to add a numeric to a string, so yeah it wouldn't function correctly
@sjames1958gm correct, setting b = undefined isn't needed, but if you imagine someone else coming by and reading your code, having that in the function signature makes it clearly visible that b isn't necessary for the function to work
function add(a, b = undefined) {

when I read this, I know I don't need to pass in b, but when I read this:

function add(a, b) {

I'd assume b is required for this add function to work

of course you'd have docs / comments explaining that
but that's just my personal preference
DistinctWolf
@DistinctWolf
Aug 05 2017 19:24
I have a module required in the main file, but why do I have to require it in other files in nodejs
Jim Tryon
@jimtryon
Aug 05 2017 19:24
does Javascript support optional parameters?
Cody Seibert
@codyseibert
Aug 05 2017 19:25
@jimtryon can you give an example of what you mean?
Jim Tryon
@jimtryon
Aug 05 2017 19:25
Hmm, so in Java, you can put a parameter and give it a default but it’s optional in the function
Cody Seibert
@codyseibert
Aug 05 2017 19:26
oh
nope you cant overload in javascript
Jim Tryon
@jimtryon
Aug 05 2017 19:26
Damn, that was a useful feature
Cody Seibert
@codyseibert
Aug 05 2017 19:26
but you can make your function do different stuff depending on what you pass in right?
Calvin
@oakypokey
Aug 05 2017 19:27
Yeah I guess with typeof
In C++ at least, the function was defined by not only the name but the cast of the params as well
Jim Tryon
@jimtryon
Aug 05 2017 19:27
@codyseibert What do you mean do different stuff, like type conversion?
Aug 05 2017 19:27
you can pass an object of your arguments to a function, or use the arguments object (Google it) for a single function with optional parameters
Calvin
@oakypokey
Aug 05 2017 19:27
Jim Tryon
@jimtryon
Aug 05 2017 19:28
That is because they have a different signature
DistinctWolf
@DistinctWolf
Aug 05 2017 19:28
@jimtryon you can have a function parameter equal to the value passed in or zero if you're working with numbers
Jim Tryon
@jimtryon
Aug 05 2017 19:29
so if I pass in a parameter as 0, that means it’s optional to the function?
JS knows that is what I want?
DistinctWolf
@DistinctWolf
Aug 05 2017 19:29
@jimtryon if parameter value exists then use it or if it doesn't then set it to zero
Cody Seibert
@codyseibert
Aug 05 2017 19:29
@jimtryon for example, let's say I make a function call concat. I can have it do array concat, or string concat depending on the types of the inputs
function concat(a, b) {
if (Array.isArray(a) && Array.isArray(b)) return a.concat(b);
else if (typeof a === 'string' && typeof b === 'string') return a + b;
else throw new Error('invalid parameter types')
}
Jim Tryon
@jimtryon
Aug 05 2017 19:30
is that the same thing as optional parameters or is just that two different return types?
Cody Seibert
@codyseibert
Aug 05 2017 19:30
but there is no way to do
function concat(String a, String b)

function concat(Array a, Array b)
Jim Tryon
@jimtryon
Aug 05 2017 19:31
private boolean defaultOptionalFlagValue = true;

public void doSomething(boolean optionalFlag) {
...
}

public void doSomething() {
doSomething(defaultOptionalFlagValue);
}
That would be an optional parameter in the method
Cody Seibert
@codyseibert
Aug 05 2017 19:31
but I see what you mean by "optional"
no, so in Javascript you can only define a method once
WAINGOR
@WAINGOR
Aug 05 2017 19:32
Hi all, are there any people in here that know Node JS ?
:)
Jim Tryon
@jimtryon
Aug 05 2017 19:32
@WAINGOR I can safely say that you can just post the question and someone will help :)
Cody Seibert
@codyseibert
Aug 05 2017 19:33
so in that example, you'd have to do
function doSomething(optionalFlag) {
if (optionalFlag !== undefined) {
} else {
}
}
Jim Tryon
@jimtryon
Aug 05 2017 19:33
I’m surprised why that feature didn’t make it in the language
WAINGOR
@WAINGOR
Aug 05 2017 19:33
Hi all I have an issue (I am using Node JS) :smile: :
Hi all, I am writing my first app in Node which will crawl a website and respond to found information by sending e-mails, if that information meets specific requirements.
Now the thing is:

I want it to send 1 e-mail for each identical post that meets the requirements mentioned above. My programme succesfully stores data that it scans into arrays that are assigned to variables. I want it to store which posts it has already scanned so it wont notify me a second time with the same information (it crawls one and the same page every 2 minutes) . Obviously if I store this into an array that works fine. But I also want to turn the programme off every now and then and review the information stored. How do I do this?
I want to save the state of vars/arrays into another (.js) file preferably.

Now the only way to solve this issue that comes to my mind is:
log my vars/arrays to a .txt file using

node index.js >myfile.txt
and then using fs.readFileSync to read that file and checking for the presence of certain values. But this feels like a very bad solution.

Can anybody point me into the right direction for this issue?

Greets
Jim Tryon
@jimtryon
Aug 05 2017 19:33
In some ways not all, JS and Java are similar
WAINGOR
@WAINGOR
Aug 05 2017 19:33

Hi all, I am writing my first app in Node which will crawl a website and respond to found information by sending e-mails, if that information meets specific requirements.
Now the thing is:

I want it to send 1 e-mail for each identical post that meets the requirements mentioned above. My programme succesfully stores data that it scans into arrays that are assigned to variables. I want it to store which posts it has already scanned so it wont notify me a second time with the same information (it crawls one and the same page every 2 minutes) . Obviously if I store this into an array that works fine. But I also want to turn the programme off every now and then and review the information stored. How do I do this?
I want to save the state of vars/arrays into another (.js) file preferably.

Now the only way to solve this issue that comes to my mind is:
log my vars/arrays to a .txt file using

node index.js >myfile.txt
and then using fs.readFileSync to read that file and checking for the presence of certain values. But this feels like a very bad solution.

Can anybody point me into the right direction for this issue?

Greets

Jim Tryon
@jimtryon
Aug 05 2017 19:33
wall of text...
WAINGOR
@WAINGOR
Aug 05 2017 19:33
lol I accidentally backticked it :D
Cody Seibert
@codyseibert
Aug 05 2017 19:35
just write to a file
using
fs.writeFileSync('data.json', 'utf-8', JSON.stringify(data, null, 2))
then load it back in when the script starts
DistinctWolf
@DistinctWolf
Aug 05 2017 19:37

@jimtryon is this what you were looking for

function myFunc(a, b = 0) {
return a + b;
}
myFunc(1,1);

so if you pass a value it will take it or default will be zero

Guderian Raborg
@hypercuber
Aug 05 2017 19:37

Is there another way to change color of rectangle when you click on it that does not involve making an if statement to check if event.x is click inside an area?

  if (sq.x < event.x && event.x < sq.x + sq.length &&
sq.y < event.y && event.y < sq.y + sq.length) sq.update();

https://codepen.io/hypercuber/pen/rzjaWg?editors=0010

Cody Seibert
@codyseibert
Aug 05 2017 19:38
not if you're using canvas that i know of
Guderian Raborg
@hypercuber
Aug 05 2017 19:38
@codyseibert Okay, thanks. What about in 3d? Would not want to do a if statement for 3 dimensions
CamperBot
@camperbot
Aug 05 2017 19:38
hypercuber sends brownie points to @codyseibert :sparkles: :thumbsup: :sparkles:
Cody Seibert
@codyseibert
Aug 05 2017 19:40
@hypercuber I mean, I'd use a 2d or 3d library... they'd typically have a way to check if a rectangle or object was clicked; but yes, I think you'd need to figure out the math for click detection otherwise
Guderian Raborg
@hypercuber
Aug 05 2017 19:47
@codyseibert Okay, thanks alot.
CamperBot
@camperbot
Aug 05 2017 19:47
hypercuber sends brownie points to @codyseibert :sparkles: :thumbsup: :sparkles:
:warning: hypercuber already gave codyseibert points
Maluchukwu
@Maluchukwu
Aug 05 2017 19:53
@codyseibert wow, funny enough i was just watching your video on youtube. You did a great job in explaining. I just couldn't see the codes you were typing. It could be because of my device though.
Cody Seibert
@codyseibert
Aug 05 2017 19:57
do you have it full screened + 1080p?
in the comments someone pasted his code doc
@Maluchukwu ^
Viperish
@Viperish
Aug 05 2017 20:02
I'm stuck on Random Quote Generator because I don't understand jquery. What should I do?
Like I get the basic idea behind it but I don't know how to use it in practice.
Maluchukwu
@Maluchukwu
Aug 05 2017 20:03
@codyseibert yes. Full screen
Joseph Henshaw
@Big-jo
Aug 05 2017 20:03
please does anyone know how to get the drop down list with countries and another drop down list with the state of the countries selected
Maluchukwu
@Maluchukwu
Aug 05 2017 20:04
@codyseibert oh. Let me check that out
Thayyeb salim
@Thayyebsalim
Aug 05 2017 20:05
Just try things, Thinking about it will only make things seem complex. @Viperish
if you have any specific doubts, I might be able to help out a bit @Viperish
Cody Seibert
@codyseibert
Aug 05 2017 20:09
@Viperish what don't you understand about jQuery?
Viperish
@Viperish
Aug 05 2017 20:10
How to use it
Cody Seibert
@codyseibert
Aug 05 2017 20:12
do you understand dom manipulation + event listeners using js?
Viperish
@Viperish
Aug 05 2017 20:12
I feel like I got thrown into the deep end without actually telling me what to do
So right now I'm looking up how to do stuff and it's sort of confusing.
Thayyeb salim
@Thayyebsalim
Aug 05 2017 20:13
Yeah its a bit confusing when you start the projects
what I did was, saw some vids on youtube then re did the fcc challenges
Cody Seibert
@codyseibert
Aug 05 2017 20:15
@Viperish why do you think you need jquery for this?
Thayyeb salim
@Thayyebsalim
Aug 05 2017 20:15
If you still think youre missing something I'd recommend codecademy too
Cody Seibert
@codyseibert
Aug 05 2017 20:19
@Viperish i'd recommend doing all the sections leading up to that project
like basic javascript, jquery, etc
Guderian Raborg
@hypercuber
Aug 05 2017 20:25
@Viperish I think there should be a section for DOM
Viperish
@Viperish
Aug 05 2017 20:29
Ok thanks :)
aRtoo
@artoodeeto
Aug 05 2017 21:15
aight. im giving up. i need help. convert numbers to roman numerals.
i have this.
function convertToRoman(num) {
/*
var I = 1;
var V = 5;
var X = 10;
var L = 50;
var C = 100;
var D = 500;
var M = 1000;
*/

var result ="";

while(num !== 0){

if(num>=1 && num<=4){
result += 'I';
num -=1;
console.log(num + 'uno');

}else if(num>=5 && num<=9){
result = 'V';
num -= 5;
console.log(num  + 'dos');

}else if(num>=10 && num<=49){
result += 'X';
num -= 10;
console.log(num  + 'tres');

}else if(num>=50 && num<=99){
result += 'L';
num -= 50;
console.log(num  + 'kwartro');

}else if(num>=100 && num<=499){
result += 'C';
num -= 100;
console.log(num  + 'singko');

}else if(num>=500 && num<=999){
result += 'D';
num -= 500;
console.log(num + 'sais');

}else if(num>=1000){
result += 'M';
num -= 1000;
console.log(num + 'syete');
}

}

return result;
}

convertToRoman(78);
Stephen James
@sjames1958gm
Aug 05 2017 21:16
@artoodeeto Start from the largest number first
aRtoo
@artoodeeto
Aug 05 2017 21:16
@sjames1958gm yea. i almost deleted it. loool
@sjames1958gm haha.
Stephen James
@sjames1958gm
Aug 05 2017 21:17
@artoodeeto close
aRtoo
@artoodeeto
Aug 05 2017 21:17
@sjames1958gm but i know this shit will still be wrong
Stephen James
@sjames1958gm
Aug 05 2017 21:18
@artoodeeto If you start with the larger number then you don't need the range checks
But you need to split out 4, 9, 40, 49, 99, etc
@artoodeeto Like CM, CD, XC, etc
aRtoo
@artoodeeto
Aug 05 2017 21:19
@sjames1958gm ha? why? confused here sir
Stephen James
@sjames1958gm
Aug 05 2017 21:20
@artoodeeto 900 is CM not DCCCC
aRtoo
@artoodeeto
Aug 05 2017 21:21
@sjames1958gm ohhhhh. okok sir thanks
CamperBot
@camperbot
Aug 05 2017 21:21
artoodeeto sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8253 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Junicus
@Junicus
Aug 05 2017 21:21
for that one the lookup table is a much simpler algorithm
Joseph
@revisualize
Aug 05 2017 21:56
Hello.
Kiwalabye Richard
@xdon55
Aug 05 2017 22:03
hey guys,,, someone plz tell me whats wrong with this code.
function largestOfFour(arr) {
// You can do this!
for(var i=0;i<arr.length;i++){
for(var j=0;j<arr[i].length;j++){
var largest = 0;

largest = Math.max.apply(null, arr[i][j]);

var newArr = [];
return newArr.push(largest);
}
}

}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Stephen James
@sjames1958gm
Aug 05 2017 22:07
@xdon55 What happens when the code hits the return statement?
@xdon55 If you are going to use Math.max.apply - you don't need two loops
kumquatfelafel
@kumquatfelafel
Aug 05 2017 23:08
Also, it's being applied to wrong thing
(arr[i][j] is single value)
Guderian Raborg
@hypercuber
Aug 05 2017 23:47
@xdon55 maybe using Math.max(...arr) would help when arr is an array

window.addEventListener('click', function(event) {
});