These are chat archives for FreeCodeCamp/HelpJavaScript

15th
Mar 2017
Jason Luboff
@JLuboff
Mar 15 2017 00:00
Adios all
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 00:00
@JLuboff cya
john94
@lpy1994
Mar 15 2017 00:01
@wonskytuner np, you would know what I mean along the way, happy coding!
will*
Chris Cullen
@123xylem
Mar 15 2017 00:01

Hello guys!
QUick QUESTION:
Why are my ids showing as Null when I call them in mongo.

They do have an id when i see them in the data base but when i call them through the app they show as null.

console response:

Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
{ _id: 58c76e48f339ce0d322f59a5,
  name: 'bob',
  email: 'bob@bob.com',
  __v: 3,
  posts: [ null, null, null ] }

My code:

  post.create({                                          //create a post with following data
      title:"working code",
    content:"Ive cracked this part"
},function(post)    {                                     //give that post a callback function
    mongoose.model("user").findOne({name:"bob"},function(err,foundUser){  //that finds one user model with name bob

        if(err){console.log(err)}

        else{                                                  //if found push in the post that was created
            foundUser.posts.push(post);
            foundUser.save(function(err,saved){               //and save bobs new details
            if(err)
            {console.log(err)}
            else
            {console.log(saved)}

        }) 
  }
  })
  })

mongoose.model("user").findOne({name:"bob"}).populate("posts").exec(function(err,user){
    if(err){console.log(err)}
else{console.log(user, user.posts.id)}});

-----------I attach a post to a user once i find a user with name bob..
Here is bobs user schema

var userSchema= new mongoose.Schema({
    name:String,
    email:String,
    posts:[{
        type:mongoose.Schema.Types.ObjectId,    //posts attribute looks for an id in a mongoose schema 
        ref:"post"                               // THe schema reference is post
            }]
});

THE IDS of these things DO EXIST.. but when I call them in the app they show as null..
WHY!!!???

wonskytuner
@wonskytuner
Mar 15 2017 00:02
@lpy1994 did u try codewars.com??
Rachel Wilson
@razzlepdx
Mar 15 2017 00:02
hi everyone - I'm working on Return Largest Numbers in Arrays algorithm. Looking for a hint on how to proceed :) Would it be better for me to reduce my sub-array down to one number, and then push it onto a new largestNumber array, or should I use another for loop to concat the sub arrays once they have all been reduced?
Kwadwo Opoku-Debrah
@kojodoesdesign
Mar 15 2017 00:02
whats mongoose?
john94
@lpy1994
Mar 15 2017 00:03
@wonskytuner just learned that from you !
JenimDacket
@JenimDacket
Mar 15 2017 00:03

function findLongestWord(str) {
  var splits = str.split(" ");
  var result = 0;  

  for (i=0; i<splits.length; i++){
    if(splits[i].length>result){
      result = splits[i].length;
    }


  return result;}
}

findLongestWord("The quick brown fox jumped over the lazy dog");
guys, my code is not iterating
It is stopping after the first instance and returning that. Why is this happening
I don't want a solution to the problem, just help identifying the problem
*solution to the challenge
Mychal Simka
@msimka
Mar 15 2017 00:05
Anyone else get hung up on #192? I checked a validator and it says the syntax is correct
john94
@lpy1994
Mar 15 2017 00:05
@wonskytuner the website looks awesome, thx for that !
CamperBot
@camperbot
Mar 15 2017 00:05
lpy1994 sends brownie points to @wonskytuner :sparkles: :thumbsup: :sparkles:
:cookie: 244 | @wonskytuner |http://www.freecodecamp.com/wonskytuner
John Mica
@JohnMica
Mar 15 2017 00:05
@JenimDacket your alg just returns 6 :P
JenimDacket
@JenimDacket
Mar 15 2017 00:06
the hell?
got it
thanks
John Mica
@JohnMica
Mar 15 2017 00:06
np
JenimDacket
@JenimDacket
Mar 15 2017 00:07
wait, just kidding
hahahah
John Nunns
@johnnunns
Mar 15 2017 00:07
cool @JLuboff def wouldn't have know parseInt could do that, thanks!
CamperBot
@camperbot
Mar 15 2017 00:07
johnnunns sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1151 | @jluboff |http://www.freecodecamp.com/jluboff
John Mica
@JohnMica
Mar 15 2017 00:07
what does it need to return ? @JenimDacket
JenimDacket
@JenimDacket
Mar 15 2017 00:08
the challenge asks that you return the integer of the largest word in the sentence (after .split, the largest string in the array)
rather, the length of the largest word
John Mica
@JohnMica
Mar 15 2017 00:08
so far your function is finding these numbers : 3 5 5 5 6 6 6 6 undefinded
JenimDacket
@JenimDacket
Mar 15 2017 00:09
How did you find that out...............
What would help me a lot
John Mica
@JohnMica
Mar 15 2017 00:09
codepen - just enter the JS and instead of return result - console.log(result)
in the console enter the “test phrase| which is findLongestWord("The quick brown fox jumped over the lazy dog");
and you get the result
JenimDacket
@JenimDacket
Mar 15 2017 00:10
Also, why is it finding that? the code should cause it to break up each word in the sentence into a string within an array, and then compare the value of each of those individually, assigning the largest to "result" and ultimately returning result, i.e. the largest word in the array
John Mica
@JohnMica
Mar 15 2017 00:10
3 5 5 5 6 6 6
JenimDacket
@JenimDacket
Mar 15 2017 00:10
That doesn't make any sense
John Mica
@JohnMica
Mar 15 2017 00:10
where did you create the array ?
JenimDacket
@JenimDacket
Mar 15 2017 00:11
.split
John Mica
@JohnMica
Mar 15 2017 00:11
var splits is just something but not an array :)
JenimDacket
@JenimDacket
Mar 15 2017 00:11
string.split(" ")
Bassem Elsarty
@Elsarty
Mar 15 2017 00:11
Can you guys rate this? Tell me if there's anything I should do or work on please. http://codepen.io/Elsarty/full/JWyBLR/
ebony821
@ebony821
Mar 15 2017 00:12
How to manipulate arrays with unshift
JenimDacket
@JenimDacket
Mar 15 2017 00:12
it should split every word into its own string within the array, dividing based on the white space @JohnMica
John Mica
@JohnMica
Mar 15 2017 00:12
trying to find the var splits in the console leats to - cannot find variable - probably scoped and thus not accesable
ebony821
@ebony821
Mar 15 2017 00:12

// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.shift(); // ourArray now equals ["J", "cat"]
ourArray.unshift("Happy");
// ourArray now equals ["Happy", "J", "cat"]

// Setup
var myArray = [["John", 23], ["dog", 3]];
myArray.shift();

// Only change code below this line.
myArray.shift (["John, 23 y is now ["dog", 3
myArrat.unshift9(["Paul",35]) //myArray is now []

JenimDacket
@JenimDacket
Mar 15 2017 00:13
@JohnMica why? The varible is explicitly stated
John Mica
@JohnMica
Mar 15 2017 00:14
yep but accesable only inside the function findLongestWord
outside this function it doesnt exist
John Deegan
@JohnDeegs
Mar 15 2017 00:14
@JenimDacket I see your issue now, you've misplaced a bracket
@JohnMica Your return result is inside your for loop
JenimDacket
@JenimDacket
Mar 15 2017 00:14
are you freaking kidding me................
='',,,,'',,'(
John Mica
@JohnMica
Mar 15 2017 00:14
hehe
i’m just trying to helpo him figure it out
on his own :P
JenimDacket
@JenimDacket
Mar 15 2017 00:15
@JohnMica Not really man hahaha
Bassem Elsarty
@Elsarty
Mar 15 2017 00:15
John Deegan
@JohnDeegs
Mar 15 2017 00:15
@JohnMica Misplaced brackets are sometimes needles in a haystack
JenimDacket
@JenimDacket
Mar 15 2017 00:16
@JohnDeegs
Thank you man. I was going to lose my mind. I spent like 3 hours on that, and I had FINALLY figured out the logic, so that was discouraging to say the least. haha
CamperBot
@camperbot
Mar 15 2017 00:16
jenimdacket sends brownie points to @johndeegs :sparkles: :thumbsup: :sparkles:
:cookie: 327 | @johndeegs |http://www.freecodecamp.com/johndeegs
John Mica
@JohnMica
Mar 15 2017 00:17
you created a var splits that creates an array
JenimDacket
@JenimDacket
Mar 15 2017 00:17
which isn't a problem
@JohnMica that is a completely acceptable way of completing the challenge. Cleaner imho
John Deegan
@JohnDeegs
Mar 15 2017 00:17
@JenimDacket Don't worry, it annoyed me so much why your code wasn't working that I pasted it into my current project just to examine it further, then it took another 10 minutes to finally see the bracket :D
JenimDacket
@JenimDacket
Mar 15 2017 00:18
@JohnDeegs Hahahaha That makes me feel WAY better man!! Thank you again!
CamperBot
@camperbot
Mar 15 2017 00:18
jenimdacket sends brownie points to @johndeegs :sparkles: :thumbsup: :sparkles:
:warning: jenimdacket already gave johndeegs points
John Mica
@JohnMica
Mar 15 2017 00:18
@JenimDacket JS has this thing - same result accomplished in many differnt ways
Hernan Mendez
@hernanmendez
Mar 15 2017 00:18
hey i'm on the Check for Palindromes, and i have no idea what's wrong

function palindrome(str) {
var arr=[];
var nstr="";
arr=str.split("");
arr.reverse();
nstr=arr.join();
arr.reverse();
var n2str =arr.join();
nstr.replace(/\W+/g,"");
n2str.replace(/\W+/g,"");
if((nstr.toLowerCase())==(n2str.toLowerCase())){
return true;
}

return false;
}

palindrome("not a palindrome");

JenimDacket
@JenimDacket
Mar 15 2017 00:19
@JohnDeegs I'll try to do a better job of checking all my closing statements next time!
Hernan Mendez
@hernanmendez
Mar 15 2017 00:19
i have some unnecessary lines of code that i can clean. but that's not it as far as i know
John Deegan
@JohnDeegs
Mar 15 2017 00:20
@JenimDacket Get used to things like this happening, it's the bread and butter of programming! No matter how long you do this stuff it'll catch you out :p
JenimDacket
@JenimDacket
Mar 15 2017 00:20
@JohnDeegs definitely!! haha
John Mica
@JohnMica
Mar 15 2017 00:20
yep - im lost with commas missing all the time
Hernan Mendez
@hernanmendez
Mar 15 2017 00:21
wait
i think i got it
JenimDacket
@JenimDacket
Mar 15 2017 00:21
When I first started a couple weeks ago I would get SOOO mad about this kind of stuff. It's getting easier to accept that this is just kind of how it goes. haha
Hernan Mendez
@hernanmendez
Mar 15 2017 00:23
nop
something is left
John Deegan
@JohnDeegs
Mar 15 2017 00:24
@JenimDacket If something's annoying you in code, take 5 minutes, go for a little walk and coffee. You'll be surprised how much you notice when you come back with a clearer mind.
John Mica
@JohnMica
Mar 15 2017 00:24
@JohnDeegs true story
JenimDacket
@JenimDacket
Mar 15 2017 00:24
@JohnDeegs
Words to live by man.. haha I will make it part of my routine.
How long have you guys been doing this?
Herman Fassett
@HermanFassett
Mar 15 2017 00:24
I also recommend Rubber Duck Debugging
John Mica
@JohnMica
Mar 15 2017 00:25
a few years with breaks in between
JS - only about 3-4 months
John Deegan
@JohnDeegs
Mar 15 2017 00:26
@JenimDacket I started FCC around this time last year, completed the front end cert in September-ish time. I've learnt back-end stuff and implementing it in my current projects, so hopefully will start the back end cert when I have more time :)
John Mica
@JohnMica
Mar 15 2017 00:27
@JohnDeegs node for backend or php / ruby … ?
JenimDacket
@JenimDacket
Mar 15 2017 00:27
Nice.
Do you guys do this for work or is it more of a hobby kind of thing?
John Deegan
@JohnDeegs
Mar 15 2017 00:28
@JohnMica Ruby for a college project, NodeJS for a personal project. Probably shouldn't use the two at once but I can't help myself :D
John Mica
@JohnMica
Mar 15 2017 00:28
@JenimDacket so far both kind of :P
JenimDacket
@JenimDacket
Mar 15 2017 00:28
@JohnMica tell more man!
Herman Fassett
@HermanFassett
Mar 15 2017 00:28
I did a lot of React stuff in an internship I had
JenimDacket
@JenimDacket
Mar 15 2017 00:28
React?
John Mica
@JohnMica
Mar 15 2017 00:28
@JohnDeegs nice = i’m leaving the Node stuff for next year
nope - plain JS
libraries and frameworks will have to wait until I really need them
John Deegan
@JohnDeegs
Mar 15 2017 00:29
@JenimDacket I'm in the final year of a CS degree, but I love JS the most out of all the languages I use so I only really program for a hobby with JS. I use Java/Ruby and a bit of C# in college.
John Mica
@JohnMica
Mar 15 2017 00:29
i like the vanilla better
Herman Fassett
@HermanFassett
Mar 15 2017 00:29
I used to love JavaScript but I think C++ is a new love
John Mica
@JohnMica
Mar 15 2017 00:30
nice @JohnDeegs - still youg and hungry to learn
young *
Herman Fassett
@HermanFassett
Mar 15 2017 00:30
@JohnDeegs cool, I'm also in final year of a CS degree.
Hernan Mendez
@hernanmendez
Mar 15 2017 00:30
@HermanFassett I love c++ too
John Deegan
@JohnDeegs
Mar 15 2017 00:30
@JenimDacket How did you discover FreeCodeCamp? :)
Herman Fassett
@HermanFassett
Mar 15 2017 00:30
:heart:
John Mica
@JohnMica
Mar 15 2017 00:31
got to go now guys
have fun
John Deegan
@JohnDeegs
Mar 15 2017 00:31
@JohnMica Cya!
Hernan Mendez
@hernanmendez
Mar 15 2017 00:31
@HermanFassett it's actually the first programming language i learned, it is LONG but not LOOOOONG
John Deegan
@JohnDeegs
Mar 15 2017 00:31
@HermanFassett What languages do you use?
Herman Fassett
@HermanFassett
Mar 15 2017 00:32
@JohnDeegs certainly depends on what I'm doing. Currently I've been using primarily C/C++, but I've also used JavaScript, C#, Java and Python extensively with small bits of others.
My Summer internship was completely JavaScript, while in college I've been using C/C++
JenimDacket
@JenimDacket
Mar 15 2017 00:33
@JohnMica See you man!
Hernan Mendez
@hernanmendez
Mar 15 2017 00:34
sooo can someone explain me why this doesn't work please?

function palindrome(str) {
var arr=[];
var nstr="";
str=str.replace(/\W+/g,nstr);
arr=str.split("");
nstr=arr.join();
arr.reverse();
var n2str ="";
n2str=arr.join();
n2str=n2str.toLowerCase(); nstr=nstr.toLowerCase();
if(nstr==n2str){
return true;
}

return false;
}

palindrome("_eye");

JenimDacket
@JenimDacket
Mar 15 2017 00:34
@JohnDeegs Basically, I discovered coding as a means of kissing my old boss's ass.. haha
he had asked me to build a website b/c I was the only guy who had ever gone to college in our company.
Herman Fassett
@HermanFassett
Mar 15 2017 00:35
@hernanmendez I think you need to account for _ too
JenimDacket
@JenimDacket
Mar 15 2017 00:35
I said sure and figured I'd just figure it out.
@hernanmendez Like @HermanFassett said! Figure out that underscore and you are golden!
@JohnDeegs After a week of learning html and css through khan academy, I fell in love. Since then (~2-3 weeks ago) I quit my job and decided to start doing this full time. Right now it's just learning to do all of this, but this work has the perfect balance of constant challenge and learning curve, mixed with the pseudo immediate gratification.
Robert Arifin
@renkachan
Mar 15 2017 00:38
guys
i wan to ask

var currentLatitude;
var currentLongitude;
$(document).ready(function(){
getLocation();
window.setTimeout(temperatureMeasurement,100);
});
/
setInterval(function() {
//call $.ajax here
}, 5000);
/

function getLocation() {
if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition);
} else {
console.log("Geolocation is not supported by this browser.");
}
}
function showPosition(position) {
currentLatitude=position.coords.latitude;
currentLongitude=position.coords.longitude;
console.log(currentLatitude);
console.log(currentLongitude);
}
function temperatureMeasurement()
{
$.ajax(
{
url:"https://cors-anywhere.herokuapp.com/api.openweathermap.org/data/2.5/weather?lat="+currentLatitude +"&lon="+currentLongitude+"&appid=af735e08f456a4362ca60a95532fadd9",
type: 'GET',
dataType: 'json',
success: function(data){
console.log(data);
},
error: function(err) {
console.log("error");
},
})};

JenimDacket
@JenimDacket
Mar 15 2017 00:39
@JohnDeegs Ideally, I will finish up the full stack by May and then I can start investing my time into learning more specialization and maybe getting a job/internship somewhere
ebony821
@ebony821
Mar 15 2017 00:39
// Only change code below this line.
myArray.unshift("John", 23);
Robert Arifin
@renkachan
Mar 15 2017 00:39
why if i write as temperatureMeasurement(). it will throw error
John Deegan
@JohnDeegs
Mar 15 2017 00:39
@hernanmendez Check and see the characters you're replacing, then check what the challenge requires.
Robert Arifin
@renkachan
Mar 15 2017 00:39
i need to write it with settimeout
Hernan Mendez
@hernanmendez
Mar 15 2017 00:39
@HermanFassett is not, i specifically choosed _ on another line of code but still
John Deegan
@JohnDeegs
Mar 15 2017 00:39
@hernanmendez You're definitely on the right track, you've only made a small mistake.
ebony821
@ebony821
Mar 15 2017 00:39
// Only change code below this line.
myArray.unshift("John", 23); How do I fix this
Herman Fassett
@HermanFassett
Mar 15 2017 00:40
@hernanmendez all you need to do is change the regex a bit
John Deegan
@JohnDeegs
Mar 15 2017 00:47
@JenimDacket Wow, that's pretty ballsy! I wish I could dedicate to this full time, but I have to constantly switch between languages in my head for college. May is definitely attainable doing this full time! Don't lose heart though if it does take longer, I think the weather project almost broke me and took me like a week to do but it's those struggles that eventually make you better at this :)
John Deegan
@JohnDeegs
Mar 15 2017 00:52
@JenimDacket https://www.udemy.com/understand-javascript/ usually goes on sale for 9.99 but it's value for understanding JS really helped me, there's a free preview on youtube as well, in case you were looking for extra material.
Hernan Mendez
@hernanmendez
Mar 15 2017 00:53
... I have no idea why the _ is still there
This link saved me from losing my mind when I was working on that one. =)
@JohnDeegs Thanks for the support man! It has been a hell of a ride!
is Udemy pretty good? They have a python class that I was looking at taking..
CamperBot
@camperbot
Mar 15 2017 00:56
jenimdacket sends brownie points to @johndeegs :sparkles: :thumbsup: :sparkles:
:warning: jenimdacket already gave johndeegs points
JenimDacket
@JenimDacket
Mar 15 2017 00:57
@hernanmendez Give that a solid read through. And like actually read it. hahaha It will help =)
John Deegan
@JohnDeegs
Mar 15 2017 00:59
@JenimDacket Depends on the course, make sure it's been updated recently and has good reviews! Courses that give a free preview are usually worth your time.
JenimDacket
@JenimDacket
Mar 15 2017 01:00
Good to know man
Michael Grienauer
@mgrienauer
Mar 15 2017 01:02
function sumFibs(num) {
  var i = 1;
  var current = 1;
  var fibarr = [];

  while (i < num){
    fibarr.push(i);
    i += 1;
  }
  return fibarr;
}

sumFibs(4);
why is this crashing my browser
should it just push 1,2,3,4 to fibarr?
Hernan Mendez
@hernanmendez
Mar 15 2017 01:02
@JenimDacket yes the thing is that when i selected individually [], yes i know is part of \w, i made /[]/ instead of /[]/ , i finished replacing \W+ with [^a-zA-Z0-9]+
@JenimDacket thanks
CamperBot
@camperbot
Mar 15 2017 01:02
hernanmendez sends brownie points to @jenimdacket :sparkles: :thumbsup: :sparkles:
:cookie: 246 | @jenimdacket |http://www.freecodecamp.com/jenimdacket
Herman Fassett
@HermanFassett
Mar 15 2017 01:03
@mike93og93 it should just push [1,2,3]... Don't know why it would crash your browser
JenimDacket
@JenimDacket
Mar 15 2017 01:03
@hernanmendez Sorry, I couldn't read all of that. Did you end up being able to figure it out?
Michael Grienauer
@mgrienauer
Mar 15 2017 01:04
@HermanFassett idk when i try to run tests it doesnt return anything and i have to reload my tab
Ali Ahmad
@aliahmad-code
Mar 15 2017 01:05

var code = "var myGlobal = 10;
// Declare your variable here

function fun1() {
oppsGlobal = 5;// Assign 5 to oopsGlobal Here

}

// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}"

Herman Fassett
@HermanFassett
Mar 15 2017 01:05
Well, there's no way that code crashes your browser
Ali Ahmad
@aliahmad-code
Mar 15 2017 01:05
whoops, sorry about that
I'm stuck on assigning a value of 5 to oppsGlobal, how exactly am I supposed to assign a value?
Deusmar Júnior
@deusmar
Mar 15 2017 01:08
@kebien6020 @forkerino @HermanFassett @JenimDacket
function factorialize(num) {
  var i = 1;
  var f = 1;
  while(i <= num) {
    f = f * i;
    i++;
  }
  return f;
}

factorialize(5);
JenimDacket
@JenimDacket
Mar 15 2017 01:09
Oh yes... my first friend of the day...
Herman Fassett
@HermanFassett
Mar 15 2017 01:09
:wink:
JenimDacket
@JenimDacket
Mar 15 2017 01:10
The best advice I can give you is to look up recursion and put all of your heart and soul into understanding it.
Hernan Mendez
@hernanmendez
Mar 15 2017 01:10
@JenimDacket yes
Herman Fassett
@HermanFassett
Mar 15 2017 01:10
Iteration can do anything recursion can
dahn88
@dahn88
Mar 15 2017 01:10

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

var splitString = str.split(" ");
var arrayOfCharCodes = [];

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

for (var j = 0; j < splitString[i].length; j++) {

  arrayOfCharCodes.push(splitString[i].charCodeAt(j)); 
}

}

var stringOfCharCodes = arrayOfCharCodes.toString();

return String.fromCharCode(stringOfCharCodes);

}

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

CamperBot
@camperbot
Mar 15 2017 01:10
:bulb: to format code use backticks! ``` more info
JenimDacket
@JenimDacket
Mar 15 2017 01:10
That link will make it much easier to comprehend
dahn88
@dahn88
Mar 15 2017 01:10
whoops
JenimDacket
@JenimDacket
Mar 15 2017 01:11
@deusmar
Deusmar Júnior
@deusmar
Mar 15 2017 01:11
I know sounds amateur but it's ok, taking one thing at a time... Thank you all for the help.
dahn88
@dahn88
Mar 15 2017 01:12
function rot13(str) { // LBH QVQ VG!

  var splitString = str.split(" ");
  var arrayOfCharCodes = [];

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

    for (var j = 0; j < splitString[i].length; j++) {

      arrayOfCharCodes.push(splitString[i].charCodeAt(j)); 
    }

  }

  var stringOfCharCodes = arrayOfCharCodes.toString();

  return String.fromCharCode(stringOfCharCodes);


}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
im having trouble with the caesar cipher challenge
Deusmar Júnior
@deusmar
Mar 15 2017 01:12
Watching now @JenimDacket 👍🏼
dahn88
@dahn88
Mar 15 2017 01:13
String.fromCharCode(stringOfCharCodes); --> returns a red dot
not sure what im doing wrong
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:14
@dahn88 why are you using to string
and then string from char code
dahn88
@dahn88
Mar 15 2017 01:15
because im turning the array into a string
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:15
why?
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:16
its the to string thats the problem
Michael Grienauer
@mgrienauer
Mar 15 2017 01:16
function sumFibs(num) {
  var i = 1;
  var current = 1;
  var fibarr = [1];
  var summer = 0;

  while (current < num){
    fibarr.push(current);
    current = current + fibarr[i-1];
    i += 1; 
  }

  for (var k = 0; k<fibarr.length;k++){
    if (fibarr[k] % 2 == 1){
      summer += fibarr[k];
    }
  }
  return summer;
}

sumFibs(75025);
dahn88
@dahn88
Mar 15 2017 01:16
hm ok
Michael Grienauer
@mgrienauer
Mar 15 2017 01:16
only failing the last test of summ all in fibonacci
any ideas?
dahn88
@dahn88
Mar 15 2017 01:16
@HeebieGeeBee thanks ill look into it
CamperBot
@camperbot
Mar 15 2017 01:16
dahn88 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1037 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Jacoby Clarke
@Jacobycodes18
Mar 15 2017 01:17

var oldArray = [1,2,3,4,5];

// Only change code below this line.
var newArray = oldArray;
newArray.map(function(val){
return val * 3;
});
Is something wrong with this?

dahn88
@dahn88
Mar 15 2017 01:18
well the thing is @HeebieGeeBee if i do this return String.fromCharCode(arrayOfCharCodes);
return String.fromCharCode(arrayOfCharCodes);
it has the same outcome
unless youre completely talking about something else
JenimDacket
@JenimDacket
Mar 15 2017 01:18
@deusmar Sounds good man. Let me know if you need anything else
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:20
@dahn88 what outcome?
dahn88
@dahn88
Mar 15 2017 01:20
@HeebieGeeBee same outcome
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:21
@dahn88 well you dont want to give it an array either
dahn88
@dahn88
Mar 15 2017 01:21
same outcome as String.fromCharCode(arrayOfCharCodes.toString());
oh ok
@HeebieGeeBee thank you
CamperBot
@camperbot
Mar 15 2017 01:21
dahn88 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: dahn88 already gave heebiegeebee points
dahn88
@dahn88
Mar 15 2017 01:24
@HeebieGeeBee LOL im so dumb why the hell would i turn it into a string. good question
haha
ha
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:24
@dahn88 yeah seemed questionable
dahn88
@dahn88
Mar 15 2017 01:25
i was literally going over it and saying to myself. "i swear this seems so right" haha
Alexander Køpke
@alexanderkopke
Mar 15 2017 01:25
welcome to the club :)
the hardest thing is to have come up with something and then having to let it go 8/
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:26
scrapping code completely can be annoying yeah
Alexander Køpke
@alexanderkopke
Mar 15 2017 01:26
Prometheus 2.0
G-4-R-Y
@G-4-R-Y
Mar 15 2017 01:27

hey there guys, just a question: why doesn't this work?
function reverseString(str) {
str.split("");
str.reverse();
str.join("");

return str;
}

reverseString("hello");

HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:27
@alexanderkopke weird im watching a youtube video about prometheus
Alexander Køpke
@alexanderkopke
Mar 15 2017 01:27
yeah I know ;)
jk
G-4-R-Y
@G-4-R-Y
Mar 15 2017 01:28
this one worked tho:
return str.split("").reverse().join("");
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:28
wouldnt surprise me if someone was
@G-4-R-Y strings dont get mutated
Alexander Køpke
@alexanderkopke
Mar 15 2017 01:29
@G-4-R-Y because some methods don't change but only returns the object they are used on
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:30
if you did str = str.split('') ... every line it would work
Alexander Køpke
@alexanderkopke
Mar 15 2017 01:32
@G-4-R-Y from mdn it says about split's return value: An array of strings split at each point where the separator occurs in the given string.
ShadowKnight
@ShadowKnight00
Mar 15 2017 01:32
Yep, with function chaining you can pass the return value along. Without it, you must make sure you capture the return value if the function doesn't directly alter the variable.
Richard Walker
@RichWalker3
Mar 15 2017 01:33
@lpy1994 thanks
CamperBot
@camperbot
Mar 15 2017 01:33
darthy0da sends brownie points to @lpy1994 :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @lpy1994 |http://www.freecodecamp.com/lpy1994
Hernan Mendez
@hernanmendez
Mar 15 2017 01:33
so i'm doing some crazy stuff here on Title Case a Sentence but when i try to run it it tell me "TypeError: Cannot read property 'o' of undefined " but as long as i can tell i have no undefined's

function titleCase(str) {
str=str.toLowerCase();
var arr=str.split(" ");
var narr=arr.length;
for (var y=0;y<arr.length;y++ ){
for (var u=0;u<arr[y].length;u++){
if (u=="0"){
narr[y][0]=arr[y][u].toUpperCase();
}
narr[y].push(arr[y][u]);
}
}
return 1;
}

titleCase("I'm a little tea pot");
(it's not ready yet)

Moisés Man
@moigithub
Mar 15 2017 01:35
cuz methods/functions
pick something(input) --> process it ---> produce an output
soo split takes an str --> returns an array -->
this array is used as input to --> reverse --> which also returns an array ->
which is used as input for join() --> which finally ouput an string
knowing what the methods takes as input.. and ouput..
u can use method chain @G-4-R-Y
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:35
well for starts should be u === 0
@hernanmendez
ShadowKnight
@ShadowKnight00
Mar 15 2017 01:35
You declare var u = 0, but then you if (u=="0") compare u to the letter 0?
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:35
@hernanmendez but you may wnat to re think how youre doing your code anyways
@hernanmendez theres lots of weird things in you code which i dont think you want
Hernan Mendez
@hernanmendez
Mar 15 2017 01:37
@ShadowKnight00 i'm using == not === so there should be no problem
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:37
you have narr=arr.length meaning narr is a number, then in the loop youre trying to find some type index of narr
then even later trying to push something into narr
Hernan Mendez
@hernanmendez
Mar 15 2017 01:38

function titleCase(str) {
str=str.toLowerCase();
var arr=str.split(" ");
var narr=arr.length;
for (var y=0;y<arr.length;y++ ){
for (var u=0;u<arr[y].length;u++){
if (u=="0"){
narr[y][0]=arr[y][u].toUpperCase();
}
narr[y].push(arr[y][u]);
}
}
return 1;
}

titleCase("I'm a little tea pot");

ok ok
ShadowKnight
@ShadowKnight00
Mar 15 2017 01:39
I know it doesn't mean much with tiny programs, but this is where descriptive variable names really help out later on, so you know what you actually meant to use the variable for.
Alexander Køpke
@alexanderkopke
Mar 15 2017 01:40
hmm I think the u=="0" part should work fine, but the narr = arr.length should cause some problems
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:40
@hernanmendez you can do this with only one loop
Hernan Mendez
@hernanmendez
Mar 15 2017 01:42
var narr=arr.length;
it doesnt show the []
but it's narr=x
wait
this chat
Alexander Køpke
@alexanderkopke
Mar 15 2017 01:43
is awesome?
Hernan Mendez
@hernanmendez
Mar 15 2017 01:43
var narr=[][]
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:43
@hernanmendez well learn how to put code in back ticks
Hernan Mendez
@hernanmendez
Mar 15 2017 01:43
in the first bracket is arr.length
in the second one is a 1
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:44
narr = [arr.length][1]?
Hernan Mendez
@hernanmendez
Mar 15 2017 01:46
i made it
Alexander Køpke
@alexanderkopke
Mar 15 2017 01:47
oO
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:47
you passed that challenge? @hernanmendez
Hernan Mendez
@hernanmendez
Mar 15 2017 01:47
Done but it took me 2 loop plus a loop inside a loop haha
loops everywhere
Alexander Køpke
@alexanderkopke
Mar 15 2017 01:48
wow. Great job!
Hernan Mendez
@hernanmendez
Mar 15 2017 01:52
c++ programmers... doing everything always more complicated
actually 3 not 2 loops lol, do you want to see it?
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 01:53

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

fahrenheit /= 1.8;
fahrenheit += 32;

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

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

So i'm trying to get it to return my fahrenheit into celsius
but i'm clearly missing something but i'm awwful at this and have no idea what i'm missing.
JenimDacket
@JenimDacket
Mar 15 2017 01:54

Hey fam, I just have a little question?


function titleCase(str) {
  var abs = str.split(" ");
  var result = " ";
  function slice(val){
    var beg = val[0].toUpperCase();
    var end = val.slice(1).toLowerCase();
    var full = beg + end;
    return full;}

  for(i=0; i<abs.length; i++){
   result += " " + slice(abs[i]);
  }
  return result;

}

titleCase("jOHn MayOR is mY Guy");

WHAT THE F*?

Hernan Mendez
@hernanmendez
Mar 15 2017 01:54
@Tiff32 farenheit is undefined
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 01:55
So fahrenheit = something.
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:55
function titleCase(str) {
return str.split(" ").map(i=> i = i[0].toUpperCase() + i.slice(1).toLowerCase()).join(" ");
}
@hernanmendez
dont need to use any loops
Hernan Mendez
@hernanmendez
Mar 15 2017 01:56
@HeebieGeeBee oohh .map... didn't remenber that, i had a headache when i was doing that
@Tiff32 farenheit = celsius converted
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:57
@JenimDacket what areyou doing there?
JenimDacket
@JenimDacket
Mar 15 2017 01:57
Title case homie
@HeebieGeeBee
Only those first letters doe
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:57
@JenimDacket yeah i got that i mean with all that code
JenimDacket
@JenimDacket
Mar 15 2017 01:57
Hey buddy, take it easy. It works. =P
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:58
@JenimDacket it works?
JenimDacket
@JenimDacket
Mar 15 2017 01:59
Yeah man.
Runs like a champ
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:59
its passed the challenge?
JenimDacket
@JenimDacket
Mar 15 2017 01:59
but no
Idk why doe
just kidding. Just figured it out.
Run it for yourself though. Runs like a charm
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 01:59
even with the spaces at the start of the sentence?
JenimDacket
@JenimDacket
Mar 15 2017 01:59
Yup, THAT was the problem. lmao
Hernan Mendez
@hernanmendez
Mar 15 2017 02:00
@JenimDacket hey compare my code to @HeebieGeeBee ' s i think his is the messiest one LoL
JenimDacket
@JenimDacket
Mar 15 2017 02:00
Lol
headakemuzik
@headakemuzik
Mar 15 2017 02:01
hey i need help with this challenge Selecting from many options with Switch Statements

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (answer) {
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
return answer;
}

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

JenimDacket
@JenimDacket
Mar 15 2017 02:01
So, heebs, riddle me this: how do I fix it w/out tossing my function nesting love
Rodrigo Marques Brandao
@brandaorm
Mar 15 2017 02:01
hello guys, i need help
JenimDacket
@JenimDacket
Mar 15 2017 02:02

@headakemuzik

hey man, when you post stuff, place your code between "```”

Rodrigo Marques Brandao
@brandaorm
Mar 15 2017 02:02
what's wrong with my var? var myStr = FirstLine\n\SecondLine\rThirdLine;
JenimDacket
@JenimDacket
Mar 15 2017 02:02
so for instance, " (enter) 'hey guys help me out?'"
headakemuzik
@headakemuzik
Mar 15 2017 02:02
@JenimDacket im not sure what u mean
JenimDacket
@JenimDacket
Mar 15 2017 02:03
if you hit the ~ key without pressing shift three times, it will produce an `
if you do that three times, i.e. ``` and then press enter, it will produce a space that you can write in
and it makes your code look like this: ```
like this.  much cleaner and easier for everyone
@headakemuzik
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:04
  for(i=0; i<abs.length; i++){
    if(i === abs.length -1) {
result += slice(abs[i]);
} else {
result += slice(abs[i]) + " ";
}
@JenimDacket
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:05

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

fahrenheit /= 1.8;
fahrenheit += 32;

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

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

JenimDacket
@JenimDacket
Mar 15 2017 02:05
@Tiff32 please read like 5 lines up hahaha
Rodrigo Marques Brandao
@brandaorm
Mar 15 2017 02:05
hey guys, help me out please :)?
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:05
I am so bad at all of this. How did i just mess it up? I put the parenthesees
headakemuzik
@headakemuzik
Mar 15 2017 02:05

function case

InSwitch(val) {
var answer = "";
// Only change code below this line
switch (answer) {
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
return answer;
}

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

nvm
JenimDacket
@JenimDacket
Mar 15 2017 02:05
hahaha
w0lfgang m0zart
@w0lfgangm0zart
Mar 15 2017 02:06
i must not be understanding what this exercise wants
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:06

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

fahrenheit /= 1.8;
fahrenheit += 32;

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

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

JenimDacket
@JenimDacket
Mar 15 2017 02:06
```
then press enter
then ```
w0lfgang m0zart
@w0lfgangm0zart
Mar 15 2017 02:06

function nextInLine(arr, item) {
var x = arr[item];
return x; // 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));

Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:06
'''
CamperBot
@camperbot
Mar 15 2017 02:06
:bulb: to format code use backticks! ``` more info
w0lfgang m0zart
@w0lfgangm0zart
Mar 15 2017 02:06

```
function nextInLine(arr, item) {
var x = arr[item];
return x; // 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));

JenimDacket
@JenimDacket
Mar 15 2017 02:06
EVERYONE PRESS MORE INFO!!!
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:07
@headakemuzik val needs to be the argument for the switch statement, and then in each case you want to be assigning a value to the answer variable not console logging
JenimDacket
@JenimDacket
Mar 15 2017 02:07
listen to camper bot! PLZZZZZZ
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:07
Im just gonna punch a hole into my computer. Was niceseeing ya;ll.
w0lfgang m0zart
@w0lfgangm0zart
Mar 15 2017 02:08

function nextInLine(arr, item) {
   var  x = arr[item];
  return x;  // 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));
JenimDacket
@JenimDacket
Mar 15 2017 02:08
@HeebieGeeBee I see what ya did there
@w0lfgangm0zart Yeah! there you go!
@w0lfgangm0zart so which problem is this?
Moisés Man
@moigithub
Mar 15 2017 02:08
review array methods few exercises back @w0lfgangm0zart
JenimDacket
@JenimDacket
Mar 15 2017 02:08
@Tiff32 NOOOOO!!
w0lfgang m0zart
@w0lfgangm0zart
Mar 15 2017 02:08
stand in line
JenimDacket
@JenimDacket
Mar 15 2017 02:09
@Tiff32 Defs take a break and then come back =)
w0lfgang m0zart
@w0lfgangm0zart
Mar 15 2017 02:09
i dont understand what this is actually asking for
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:09
@JenimDacket im trash at everything I do, just depressing ya know.
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:09
@w0lfgangm0zart you need to use push to put the item in the array and your return should be your shift from the array
w0lfgang m0zart
@w0lfgangm0zart
Mar 15 2017 02:09
i dont believe that push has been covered yet
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:09
@w0lfgangm0zart read the documentation for .push() and .shift() methods
headakemuzik
@headakemuzik
Mar 15 2017 02:09
@HeebieGeeBee thank you very much!!!
CamperBot
@camperbot
Mar 15 2017 02:09
headakemuzik sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1038 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
w0lfgang m0zart
@w0lfgangm0zart
Mar 15 2017 02:10
has push been covered before this lesson?
JenimDacket
@JenimDacket
Mar 15 2017 02:10
Hey man, I used to feel the exact same way. And then a very wise, very experienced guy on here told me that this is part of coding. No one, not even the pros go through this w/out frustration and wtf moments. Just gotta keep it up, take a break to walk around or drink some water or have a piss, and then come back to it man. @Tiff32
w0lfgang m0zart
@w0lfgangm0zart
Mar 15 2017 02:10
i know it from codecademy
Stephen James
@sjames1958gm
Mar 15 2017 02:11
@w0lfgangm0zart There were four challenges on push, shift, unshift and pop
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:11
@w0lfgangm0zart cant remember but probably
JenimDacket
@JenimDacket
Mar 15 2017 02:11
@Tiff32 Which problem are you on?
w0lfgang m0zart
@w0lfgangm0zart
Mar 15 2017 02:11
i just did all of those except push
oh i see
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:12
@JenimDacket appreciate the kind words man.
w0lfgang m0zart
@w0lfgangm0zart
Mar 15 2017 02:12
i somehow skipped it
thanks
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:12
@JenimDacket just says "convert celsius to fahrenheit" under javascript
JenimDacket
@JenimDacket
Mar 15 2017 02:12
@Tiff32 Yeah man. Don't let it get ya down. Just keep on and take a break before you break the screen ya know? hahaha
okay, give me a sec to look at it again
Yep

@Tiff32 okay, so let's see what you have so far.

Remember, first do three of "```" and hit enter. those are not to be confused with '''

CamperBot
@camperbot
Mar 15 2017 02:14
:bulb: to format code use backticks! ``` more info
JenimDacket
@JenimDacket
Mar 15 2017 02:15
your code goes after the enter key
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:15
`

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

fahrenheit /= 9/5;
fahrenheit += 32;

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

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

omfg gonna watch a youtube tutorial i am so fucking stupid i can't handle it/
JenimDacket
@JenimDacket
Mar 15 2017 02:16
hahahahahahah
sounds good.
=)
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:16
oh it's shift enter
JenimDacket
@JenimDacket
Mar 15 2017 02:16
you have to hit the three ticks then press enter before you copy and past your code @Tiff32
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:18
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line
  fahrenheit = celsius;

  fahrenheit /= 9/5;
  fahrenheit += 32;

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

// Change the inputs below to test your code
convertToF(30);
HALLELUJAH
JenimDacket
@JenimDacket
Mar 15 2017 02:18
@Tiff32 My man!
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:18
@JenimDacket SHOW ME WHAT YOU GOT
JenimDacket
@JenimDacket
Mar 15 2017 02:18
hahahaha
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:18
@Tiff32 do you see the formula in the challenge details?
JenimDacket
@JenimDacket
Mar 15 2017 02:19
So, when you are doing these, keep in mind that you can make an adjustment to the variable in the actual assignment
i.e.
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:19
The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
this?
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:19
yes
JenimDacket
@JenimDacket
Mar 15 2017 02:19
dogs = cats + more fun
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:19
holy fucking shit
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:19
how would you express that formula in a javascript syntax @Tiff32
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:19
i was doing division
JenimDacket
@JenimDacket
Mar 15 2017 02:19
yup
hahahahahaha
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:19
dear god
JenimDacket
@JenimDacket
Mar 15 2017 02:19
It's okay man!
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:20
@JenimDacket thanks!
CamperBot
@camperbot
Mar 15 2017 02:20
tiff32 sends brownie points to @jenimdacket :sparkles: :thumbsup: :sparkles:
:cookie: 247 | @jenimdacket |http://www.freecodecamp.com/jenimdacket
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:20
@HeebieGeeBee thanks!
CamperBot
@camperbot
Mar 15 2017 02:20
tiff32 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1039 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:20
been a long ass week with daylight savings time and my god I would have given up coding if not for that.
JenimDacket
@JenimDacket
Mar 15 2017 02:20
hey, go get'em heebs look at all that star power you have
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:21
not that i can do much with them
JenimDacket
@JenimDacket
Mar 15 2017 02:21
@Tiff32 If you ever feel like that, take a break man. =) I've only been doing this for a little while, but I can confirm what everyone else will tell you: This WILL be challenging. But, if you keep it up, you also WILL make progress. =)
@HeebieGeeBee RNGezus looks kindly on those with many star power
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:21
about @sjames1958gm if you wanna see boss level brownies
CamperBot
@camperbot
Mar 15 2017 02:21
:star2: 6175 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:22
@JenimDacket so true. I also do IT work at a school right now and I think I get dyslexia staring at screens all day :P
JenimDacket
@JenimDacket
Mar 15 2017 02:22
HOT DOG!
@Tiff32 Totally man! haha
Alex Harrison
@alexharrison-js
Mar 15 2017 02:26

Hi Guys I have a Javascript question if you would be so kind:

I’m trying to do one of the algorithm questions.

when given two strings (str and target) I need to return true when the str is the last letter OR last word in str.

Here’s my code now and I am getting the error that words and last are already defined, but I want them to be defined only in the case that the if statement is true Please help;

function confirmEnding(str, target) {



  if (" " in str){
 var words = str.split(' ').reverse();
 var last = words[0];
}

  else {
    var words = str.split('').reverse();
    var last = words[0];
  }



if (last == target){
    return true;
  }
  return false;

}

confirmEnding("Bastian is a big fat loser", "n");
JenimDacket
@JenimDacket
Mar 15 2017 02:28
@HeebieGeeBee
```

function titleCase(str) {
  var abs = str.split(" ");
  var result = "";
  function slice(val){
    var beg = val[0].toUpperCase();
    var end = val.slice(1).toLowerCase();
    var full = beg + end;
    return full;}

  for(i=0; i<abs.length; i++){
   if (i === 0){
     result += slice(abs[i]);
   } 
     else {
       result += " " + slice(abs[i]);
  }
  }  
  return result;

}

titleCase("jOHn MayOR is mY Guy");
Thanks for that little if/else pointer. Saved my mind & my code
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:30
@alexharrisonmusic you probably going to have to rethink your code cus i dont think that will work for the challenge, but just declare you last varable at the top of the function and then define them in your if else statement
@alexharrisonmusic but yeah even with that sorted out your code still wont pass the challenge
@JenimDacket no problem
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:33
var myStr "I am a \"double quoted\" string inside \"double quotes\"."; // Change this line
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:33
@JenimDacket you could also just use map with your function
JenimDacket
@JenimDacket
Mar 15 2017 02:33
map...
give me a sec. I've kind of forgotten that one.
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:33
Not sure why this is not reading right? the back slash should be in front of each of the quotations right
JenimDacket
@JenimDacket
Mar 15 2017 02:34
@HeebieGeeBee how would I do that?
@Tiff32 What are you supposed to be doing? making the phrase a comment?
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:35
@JenimDacket yeah i got it. the = must have got deleted
oops
JenimDacket
@JenimDacket
Mar 15 2017 02:35
it happens
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:36
return abs.map(slice(val)).join(' ');
try that
JenimDacket
@JenimDacket
Mar 15 2017 02:36
I spent like 20 minutes chasing a ghost semi-colon earlier
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:36
oh god, rip.
Alex Harrison
@alexharrison-js
Mar 15 2017 02:38
@HeebieGeeBee Thanks for the feedback. I’ll start from scratch then. Sometimes you just need someone to tell you that you’re not on the right track. Cheers!
CamperBot
@camperbot
Mar 15 2017 02:38
alexharrisonmusic sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1040 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
JenimDacket
@JenimDacket
Mar 15 2017 02:39
@HeebieGeeBee I'm not following mate
sorry, out of context my brain is just saying no
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 02:40
can someone help for counting cards challenge
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:41
function titleCase(str) {
  var abs = str.split(" ");


  return abs.map(function slice(val){
    var beg = val[0].toUpperCase();
    var end = val.slice(1).toLowerCase();
    var full = beg + end;
    return full;}).join(' ');
}
@JenimDacket
headakemuzik
@headakemuzik
Mar 15 2017 02:42

// Setup
function abTest(a, b) {
  // Only change code below this line



  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
not sure what to do
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:43
@sourabhrangdal hey, I'm not there yet, but if you post the code you're working on they'll be able to help better :)
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:43
function titleCase(str) {
  var abs = str.split(" ");
  function slice(val){
    var beg = val[0].toUpperCase();
    var end = val.slice(1).toLowerCase();
    var full = beg + end;
    return full;}

  return abs.map(slice).join(' ');
}
or if you want it a bit more readable @JenimDacket
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 02:44
@Tiff32 :thumbsup:
c0d0er
@c0d0er
Mar 15 2017 02:44
does anybody know why the mouseover and mouseout methods both dont work in my pen? http://codepen.io/c0d0er/pen/qrjwGg?editors=0010
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 02:44
can someone help for counting cards challenge, want i am doing is wrong
var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card){
    case count += 1:
      count += " Bet";
      break;  
    case count = 0:
      count = " Bet";
      break;
    case count -= 1:
      count -= " Bet";
      break;
  }

  return card;
  // Only change code above this line
}
Zaluth
@Zaluth
Mar 15 2017 02:44
i want to make a smooth scroll, so i thought of using a loop and scrollBy, but doesn't work, can anyone help?
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 02:45
@headakemuzik what is the challenge name
headakemuzik
@headakemuzik
Mar 15 2017 02:45
@sourabhrangdal Return Early Pattern for Functions
@headakemuzik you need to make an if statement that checks if a or b are less than 0
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 02:46
@Manish-Giri :thumbsup:
Manish Giri
@Manish-Giri
Mar 15 2017 02:47
and return undefined if so
@headakemuzik
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 02:47
@Manish-Giri is it correct to suggest using or || to @headakemuzik
Robert Arifin
@renkachan
Mar 15 2017 02:47
is the correct way to use callback function?
Manish Giri
@Manish-Giri
Mar 15 2017 02:47
@sourabhrangdal yeah
Robert Arifin
@renkachan
Mar 15 2017 02:47
getLocation(temperatureMeasurement);
i want temperaturemeasurement function to run
after getLocation function ended
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:48
@c0d0er @c0d0er dont chain it
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 02:49
@Manish-Giri getting confused in expression and case valueN
eswhy
@eswhy
Mar 15 2017 02:49
any suggestions on how pass the punctuation on the caesars cipher algorithm? i have a super ugly program but its returning the correct characters, I just dont know how to pass the puncuation
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 02:49
@Manish-Giri *I am getting confused by expression and case valueN
Manish Giri
@Manish-Giri
Mar 15 2017 02:50
@sourabhrangdal look at this example
```
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:50
@eswhy just make your function ignore the charcters that arent in the range of the capital alphabet
@Manish-Giri yo
Manish Giri
@Manish-Giri
Mar 15 2017 02:50
switch (expr) {
  case 'Oranges':
    console.log('Oranges are $0.59 a pound.');
    break;
  case 'Apples':
    console.log('Apples are $0.32 a pound.');
    break;
  case 'Bananas':
    console.log('Bananas are $0.48 a pound.');
    break;
  case 'Cherries':
    console.log('Cherries are $3.00 a pound.');
    break;
  case 'Mangoes':
  case 'Papayas':
    console.log('Mangoes and papayas are $2.79 a pound.');
    break;
  default:
    console.log('Sorry, we are out of ' + expr + '.');
}

console.log("Is there anything else you'd like?");
@sourabhrangdal
@HeebieGeeBee :wave: wsup
eswhy
@eswhy
Mar 15 2017 02:51
@HeebieGeeBee do i use a regex or what?
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 02:51
@Manish-Giri yes, reading the same thing, trying to figure out to counting challenge
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:51
@eswhy dont need to
wheres your code?
eswhy
@eswhy
Mar 15 2017 02:52
@HeebieGeeBee one sec

function rot13(str) { // LBH QVQ VG!
var punctuation = str.match(/\W\g/);
var ans = [];
var convert =[];
for (i = 0; i<str.length; i++){ convert.push(str.charCodeAt(i));} for (x = 0; x<convert.length; x++){ if (convert[x]>=78){ans.push(convert[x]-13);}
else if (convert[x]<78){ans.push(convert[x]+13);}
}
var ansString= ans.map(function(x){return String.fromCharCode(x);});
return ansString;
}

// Change the inputs below to test
rot13("SERR CVMMN!");

Manish Giri
@Manish-Giri
Mar 15 2017 02:52
@sourabhrangdal
function cc(card) {
  // Only change code below this line
  switch(card){
    case 1:
    case 2:
            ....
  }
here's how it goes
eswhy
@eswhy
Mar 15 2017 02:52
@HeebieGeeBee ignore that sorry
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:53
@eswhy put a limit on conditionals
eswhy
@eswhy
Mar 15 2017 02:53
@HeebieGeeBee idk what that is...
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:54
alpha bet capital is like 65 to 90
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 02:54
@Manish-Giri :thumbsup: i tried that, let me share, wait
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:54
so only apply changes to characters with in that range
eswhy
@eswhy
Mar 15 2017 02:54
@HeebieGeeBee ahhhh
@HeebieGeeBee thank you
CamperBot
@camperbot
Mar 15 2017 02:54
eswhy sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1041 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
JenimDacket
@JenimDacket
Mar 15 2017 02:55
@HeebieGeeBee oooooooh, I like that!
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:55
var myStr = 'First Line \n \\SecondLine\\ \r ThirdLine'; // Change this line
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.
It says to do with no spacing?
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:56
@Tiff32 yet you have put them in
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:56
I put the \n and \r and the backslashes. how do i escape them thought without spacing?
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 02:56
@Manish-Giri below is wrong,
var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
      count += " Bet" + " Hold";
      break;

    case 0:
      count = " Bet" + " Hold";
      break;

    case 10:
    case J:
    case Q:
    case K:
    case A:
      count -= " Bet" + " Hold";
      break;
  }

  return card;
  // Only change code above this line
}
Moisés Man
@moigithub
Mar 15 2017 02:57
yepyoushouldremoveallspacesfromyourstringNOspacesatall @Tiff32
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:57
@Tiff32 remove the spaces
Manish Giri
@Manish-Giri
Mar 15 2017 02:57
@sourabhrangdal inside the switch block, you should only increment/decrement count depending on the value of card.
Saboor Malik
@MathematicsCoding
Mar 15 2017 02:57

function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  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(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Manish Giri
@Manish-Giri
Mar 15 2017 02:57
Once outside, make an if/else statement that returns count along with the right string, depending on the value of count
@sourabhrangdal
JenimDacket
@JenimDacket
Mar 15 2017 02:58
@HeebieGeeBee So, .map is applying the slice function to every one of my arrays and then the join at the end recompresses it back into a single string. That looks WAAY cleaner
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:58
@HeebieGeeBee thanks!
CamperBot
@camperbot
Mar 15 2017 02:58
tiff32 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: tiff32 already gave heebiegeebee points
Saboor Malik
@MathematicsCoding
Mar 15 2017 02:58
In output After says 2,3,4,5,6 but how?
Rob Tieffenbacher III
@Tiff32
Mar 15 2017 02:58
@moigithub thanks bud
CamperBot
@camperbot
Mar 15 2017 02:58
tiff32 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2854 | @moigithub |http://www.freecodecamp.com/moigithub
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:58
@JenimDacket yup
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 02:58
@Manish-Giri ok, let me try :thumbsup:
eswhy
@eswhy
Mar 15 2017 02:59
@HeebieGeeBee okay so i couldnt only apply changes to characters within that range because I am using the 13th letter in the alphabet M as the point at which my function should either add or subtract 13 to decode the ROT 13 string
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 02:59
@eswhy im sure you could if you tried
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:00
@HeebieGeeBee Can you explain how my code works?
..
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:01
if (x > 64 && x < 78) @eswhy is a clue
eswhy
@eswhy
Mar 15 2017 03:02

@HeebieGeeBee
this is what i have

function rot13(str) { // LBH QVQ VG!
var ans = [];
var convert =[];
for (i = 0; i<str.length; i++){ convert.push(str.charCodeAt(i));} for (x = 0; x<convert.length; x++){ if (convert[x]>=78 && convert[x]<=90){ans.push(convert[x]-13);}
else if (convert[x]<=78 && convert[x]<=90){ans.push(convert[x]+13);}
}
var ansString= ans.map(function(x){return String.fromCharCode(x);});
return ansString.join("");
}
// Change the inputs below to test
rot13("SERR CVMMN!");

HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:02
@MathematicsCoding what do you need explaining?
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:02
This code

function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  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(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
I dont understand this output when after says [2,3,4,5,6]
But how?
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:03
@eswhy your else if conditional isnt right
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:03
Like I dont see any [2,3,4,5,6] in the code
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:04
@MathematicsCoding you're not meant to
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:04
enot?
Oh
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:04
arr.push(item); what does this do ? @MathematicsCoding
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:04
Is it because there is two [1,2,3,4,5]?
To add
Well add item in that function
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:05
@MathematicsCoding that doesnt matter, youre just writing a function
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:05
Yeah.. but I want to understand
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:06
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift();
  return item;  // Change this line
}
this is the function that has been written it does nothing until it is called
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:06
Oh nvm I got it
Because 1=2 2=3 etc.
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:06
when someone calls it they will pass two arguments into it
Ayush Bahuguna
@relentless-coder
Mar 15 2017 03:07
var x = 2;
var y = 4;
if((y > x || y++ === 4)&& ++y === 5){
   x = 1;
} else {
  x = 4;
}
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:07
for example nextInLine([1,2,3], 4) is calling the function with two arguments and array of numbers as the first argument and a single number as the second argument
Ayush Bahuguna
@relentless-coder
Mar 15 2017 03:08
so the condition inside if statement changes the values ????
eswhy
@eswhy
Mar 15 2017 03:08
@HeebieGeeBee alright i figured it out thank you for your help man
CamperBot
@camperbot
Mar 15 2017 03:08
eswhy sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: eswhy already gave heebiegeebee points
Ayush Bahuguna
@relentless-coder
Mar 15 2017 03:08
because I logged y and it says 5.. o_O
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:08
@Manish-Giri just tried, but not sure i understand the challenge
function cc(card) {
  // Only change code below this line
  switch(card) {
    case +1:
      if(count >= 2 || count <= 6){
        count += " Bet";
      }
      count += " Hold";
  } 
  break;
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:08
now the functions purpose is to take the array add the number to the end of the array , and then return a number that it has shifted from the front ofthe array @MathematicsCoding
Ayush Bahuguna
@relentless-coder
Mar 15 2017 03:09
@HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:09
@MathematicsCoding to test if your function works properly the freecodecamp testing will call the function multiple times with many different arguments and make sure they get the correct things returned
@relentless-coder yo
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:10
Strange...
That .push and .shift functions just disappeared from the code
Ayush Bahuguna
@relentless-coder
Mar 15 2017 03:11
var x = 2;
var y = 4;
if((y > x || y++ === 4)&& ++y === 5){
   x = 1;
} else {
  x = 4;
}
@HeebieGeeBee so the value of y changes too?
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:11
I even resetted the code but they doesnt come back
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:11
@relentless-coder sorry i dont know about altering the conditional with using somthing like y++ inside it
Ayush Bahuguna
@relentless-coder
Mar 15 2017 03:11
it changed. y is 5 now.
but why?
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:11
@MathematicsCoding reseting the code clear all the code you have written
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:11
Yeah
These function was right here when I started it
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:12
@relentless-coder well isnt that what y++ does?
Manish Giri
@Manish-Giri
Mar 15 2017 03:12
@sourabhrangdal it's like a poker game, your value goes down if you get a high card, and value goes up if you get a low card..
so you need to make cases for 2 through 6, where you would increment count, and for cases Q, J and the rest, you decrement count..
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:13
++y...
Ayush Bahuguna
@relentless-coder
Mar 15 2017 03:13
@HeebieGeeBee i thought it was just for the conditional purposes.
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:14
@relentless-coder i guess it alters y inside conditional or not
Ayush Bahuguna
@relentless-coder
Mar 15 2017 03:14
okay.
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:14
might need to use y + 1 == ... if you dont want it to change
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:14
@Manish-Giri
function cc(card) {
  // Only change code below this line
  switch(card) {
    case +1:
      if(count >= 2 || count <= 6){
        count += " Bet";
      }
      count += " Hold";
  } 
  break;
it is not correct, sorry i am all confused
SymoneAustin
@SymoneAustin
Mar 15 2017 03:17
Hi everyone. I am doing the Word Blanks part of the basic javascript section. Can anyone give me some idea of what I'm doing wrong?
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:18
@SymoneAustin share your code
Ayush Bahuguna
@relentless-coder
Mar 15 2017 03:18
@HeebieGeeBee got it.
SymoneAustin
@SymoneAustin
Mar 15 2017 03:20

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

result = "My " + myNoun + "is " + myAdjective + "but he " + myVerb + "very " + myAdverb + ".";
// Your code above this line
return result;
}

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

Saboor Malik
@MathematicsCoding
Mar 15 2017 03:20
Sigh I remember someone had the same problem with this challenge...
Peopledon'twritelikethis
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:22
@MathematicsCoding tag him when you help him
SymoneAustin
@SymoneAustin
Mar 15 2017 03:22
@sourabhrangdal sorry I'm not sure how to add a screenshot into the chat.
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:22
@SymoneAustin it is correct, but did you updated your wordBlanks function?
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:22
@HeebieGeeBee it's a woman...
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:22
@SymoneAustin to copy code and paste, add this ``` before and after your code
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:23
@MathematicsCoding either way tell them what they need to solve the problem
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:23
and paste here
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:23
@MathematicsCoding tag him when you help him
Who's him?
:trollface:
David Amanze
@GodKingShogun
Mar 15 2017 03:23
hello everyone
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:23
Hello God or King
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:23
@GodKingShogun yo
David Amanze
@GodKingShogun
Mar 15 2017 03:23
i want to commit suicide lol

function smallestCommons(arr) {
var remainder=0;
var counter1=2;
var counter=1;
var num1= arr[0];
var num2= arr[1];
var fnum1= arr[0];
var fnum2= arr[1];
  if (num1<num2){
  for (var i=2; counter<=fnum2; i++) {
    if (fnum1*i<fnum2) {

    } else if (fnum1*i>fnum2) {
      fnum2*=counter1;
      counter1++;
    } else if (fnum1*i===fnum2){
      for (var j=num2; j>=num1; j--) {
        if(fnum2%j===0) {

        } else{
          remainder+=1;
        }
        if (remainder===0){
          return fnum2;
        } else {
          remainder=0;
        }
      }
    }

   } 
  }

}
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:23
Dont do it!
G-4-R-Y
@G-4-R-Y
Mar 15 2017 03:23
hey guys, can you help me out here?
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:24
@GodKingShogun Oh its a joke what the issues? :p
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:24
ok then @SymoneAustin you need to add spaces
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:24
Space = " "
G-4-R-Y
@G-4-R-Y
Mar 15 2017 03:24
blob
David Amanze
@GodKingShogun
Mar 15 2017 03:25
@MathematicsCoding lol i think i have the concept down so far but i feel like there is a neater way to write this. im in the triangle of death
SymoneAustin
@SymoneAustin
Mar 15 2017 03:25

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

result = "My " + myNoun + "is " + myAdjective + "but he " + myVerb + "very " + myAdverb + ".";
// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat", "small", "bit", "slowly");
```

Matthew
@IMDBLM
Mar 15 2017 03:25
Hey y'all I'm hung up on testing objects for properties. To be honest I'm almost entirely stuck on how to start, because I undestand the example, but I'm not just testing for a particular property but the entire. So what I have checks off 2 of the 3 but not the 3rd.

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here


  return myObj[checkProp];
}

// Test your code by modifying these values
checkObj("gift");
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:26
@SymoneAustin make sure the backticks are on their own line
Joseph
@revisualize
Mar 15 2017 03:26
@IMDBLM You need an if statement in there.
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:26
@SymoneAustin yes
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:27
@revisualize hi
Joseph
@revisualize
Mar 15 2017 03:27
@SymoneAustin That code should be fine.
Matthew
@IMDBLM
Mar 15 2017 03:27
@revisualize And that's what I wondered. Because the instructions say if this otherwise this
Joseph
@revisualize
Mar 15 2017 03:27
@SymoneAustin Oh, you're missing spaces
@sourabhrangdal
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

result = "My " + myNoun +  "is " + myAdjective + "but he " + myVerb + "very " + myAdverb + ".";
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("cat", "small", "bit", "slowly");
Matthew
@IMDBLM
Mar 15 2017 03:27
@revisualize but then it seems almost like I'm not even using the .hasOwnProperty
Joseph
@revisualize
Mar 15 2017 03:28
@SymoneAustin Yeah, you're missing a bunch of spaces.
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:28
@IMDBLM what do you do if the property isnt found?
Joseph
@revisualize
Mar 15 2017 03:28
@SymoneAustin People don'twrite likethis.
SymoneAustin
@SymoneAustin
Mar 15 2017 03:28
thanks guys! I forgot to put the spaces in front of the words.
Robert Arifin
@renkachan
Mar 15 2017 03:28
anyone can help me with callback function? i was confused
Joseph
@revisualize
Mar 15 2017 03:29
@renkachan What do you have?
Robert Arifin
@renkachan
Mar 15 2017 03:29
@revisualize i have this

var currentLatitude;
var currentLongitude;
var data;
$(document).ready(function(){
getLocation(function()
{
temperatureMeasurement();
});

//window.setTimeout(temperatureMeasurement,100);
});
/
setInterval(function() {
//call $.ajax here
}, 5000);
/

function getLocation(callback) {
if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition);
} else {
console.log("Geolocation is not supported by this browser.");
}
}
function showPosition(position) {
currentLatitude=position.coords.latitude;
currentLongitude=position.coords.longitude;
console.log(currentLatitude);
console.log(currentLongitude);
callback();
}
function temperatureMeasurement()
{
$.ajax(
{
url:"https://cors-anywhere.herokuapp.com/api.openweathermap.org/data/2.5/weather?lat="+currentLatitude +"&lon="+currentLongitude+"&appid=af735e08f456a4362ca60a95532fadd9",
type: 'GET',
dataType: 'json',
success: function(data){
console.log("data");
},
error: function(err) {
console.log("error");
},
})};

Joseph
@revisualize
Mar 15 2017 03:29
@renkachan OMG!
WTF is that crap?
Matthew
@IMDBLM
Mar 15 2017 03:29
haha
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:29
hey .shift function means to remove first element right?
WTF is that crap?
G-4-R-Y
@G-4-R-Y
Mar 15 2017 03:29
I'm stuck in the "Factorialize a Number" challenge, can anyone help me?
function factorialize(num) {
  for (i = 1; i < num; i++)
    if (i >= num-1) {
      num *= i;
    }

    else {
      i *= i+1;
    }

  return num;
}

factorialize(5);
Robert Arifin
@renkachan
Mar 15 2017 03:29
LOL
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:30
LOL
Robert Arifin
@renkachan
Mar 15 2017 03:30
the temperatureMeasurement is not being called
Joseph
@revisualize
Mar 15 2017 03:30
@renkachan Do you have a codepen or a gist or something!?!?!?!
Joseph
@revisualize
Mar 15 2017 03:30
@renkachan You do realize that the room for your question is https://gitter.im/FreeCodeCamp/HelpFrontEnd
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:31
Can there be more than two function with same name?
Robert Arifin
@renkachan
Mar 15 2017 03:31
@revisualize sorry didnt know about the room , ok i will go there !
Joseph
@revisualize
Mar 15 2017 03:31
@MathematicsCoding One thing the .shift() method does is remove the first element from an array.
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:31
Yeah
This challenge: Stand in line
Can there be more than two function with same name?
Joseph
@revisualize
Mar 15 2017 03:31
@MathematicsCoding You can do method chaining. But, you have to know what the method that you're chaining returns.
@MathematicsCoding Functions? Or methods?
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:32
I dont know chaining yet
function
Joseph
@revisualize
Mar 15 2017 03:32
@MathematicsCoding I'm confused by what you mean. Two functions at the same time?
@MathematicsCoding Do you realize that .shift() is a method?
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:32
Like this
function blah()
function blah()
Joseph
@revisualize
Mar 15 2017 03:32
@MathematicsCoding You cannot have two functions with the same name.
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:33
Oh ok
Joseph
@revisualize
Mar 15 2017 03:33
The first function will be overwritten by the second.
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:33
Well I dont know how to do this then...
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2

function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  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(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Joseph
@revisualize
Mar 15 2017 03:33
@MathematicsCoding THAT"S really close.
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:33
hi all, i am stuck with Counting Cards challenge, can someone help please
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:34
Well I didnt do anything...
Joseph
@revisualize
Mar 15 2017 03:34
@sourabhrangdal Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:34
@revisualize Did you just type that?
Joseph
@revisualize
Mar 15 2017 03:34
@MathematicsCoding What does the .shift() method return?
@MathematicsCoding No. I copy and paste.
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:34
Oh
.shift() means to remove first array from an element
Joseph
@revisualize
Mar 15 2017 03:35
@MathematicsCoding That it does.
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:35
Just like .pop() but remove last
Joseph
@revisualize
Mar 15 2017 03:35
@MathematicsCoding What does the .shift() method return?
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:35
@revisualize thank you, let me try :thumbsup:
CamperBot
@camperbot
Mar 15 2017 03:35
sourabhrangdal sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3524 | @revisualize |http://www.freecodecamp.com/revisualize
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:35
return?
Im actually confused with return..
Joseph
@revisualize
Mar 15 2017 03:35
@MathematicsCoding Yes. Methods also return something.
@MathematicsCoding Okay.

@MathematicsCoding Question:

function getName() { return "Happy Feet"; }
var name = getName();
console.log(name);

What do you think is output to the console when you log the variable name?
Why do you think that is?

Saboor Malik
@MathematicsCoding
Mar 15 2017 03:36
Because of its variable?
I never understood return in first place..
Joseph
@revisualize
Mar 15 2017 03:36
@MathematicsCoding What?
@MathematicsCoding Well, that's a problem.
@MathematicsCoding Because all functions and methods (which are functions) return something.
Matthew
@IMDBLM
Mar 15 2017 03:37
@revisualize just to show i figured it out in less than 4 hours this time:

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)) {
     return myObj[checkProp];
     } else {
  return "Not Found";
     }
}

// Test your code by modifying these values
checkObj("gift");
Joseph
@revisualize
Mar 15 2017 03:37
@IMDBLM Grats?
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:37
Well what does return do in code...
Matthew
@IMDBLM
Mar 15 2017 03:37
These last two challenges have sincerel confused me
Joseph
@revisualize
Mar 15 2017 03:37
@IMDBLM Wait, it takes you 4 hours to solve challenges?
@MathematicsCoding
The return statement ends function execution and specifies a value to be returned to the function caller.
Syntax
return [[expression]];
expression
The expression to return. If omitted, undefined is returned instead.
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:38
...
Matthew
@IMDBLM
Mar 15 2017 03:38
@revisualize the testing objects one did but everything else has been a breeze (more or less)
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:38
Can you give me an easy example?
Joseph
@revisualize
Mar 15 2017 03:38
@MathematicsCoding Yes
@MathematicsCoding
function getName() { return "Happy Feet"; }
Matthew
@IMDBLM
Mar 15 2017 03:39
@revisualize I am perhaps overthinking, or am just missing key points altogether. I may pause this course and go read the 'You Don't Know JS' books or something.
Joseph
@revisualize
Mar 15 2017 03:40
@IMDBLM I wouldn't. Just keep pushing.
@IMDBLM You can read the books at the same time.
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:40
return... return... return...
Zaluth
@Zaluth
Mar 15 2017 03:40
my clearInterval isn't working, can anyone help?
var scroll = document.getElementById("scroll");
var time;

function scrollPage(){
  window.scrollBy(0, 1);
}

scroll.onclick = function(){
  time = setInterval(scrollPage, 10);  
}

if(window.pageYOffset == "10"){
  clearInterval(time);
}
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:42
I will not pass this challenge...
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:42
@revisualize
var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card) {
    case +1:
      if(card === 2 || card === 3 || card === 4 || card === 5 || card === 6) {
        count += " Bet";
      } count += " Hold";
      break;
    case 0:
      if(card === 7 || card === 8 || card === 9) {
        count = " Bet";
      } count = " Hold";
      break;
    case -1:
      if(card === 10 || card === "J" || card === "Q" || card === "K" || card === "A") {
        count -= " Bet";
      } count -= " Hold";
   break;   
  }
Joseph
@revisualize
Mar 15 2017 03:43
@sourabhrangdal You really need to learn how to work with switches
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:43
@Zaluth how do you know that window offset equals 10?
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:43
@amitkumarsarangi stuck
Matthew
@IMDBLM
Mar 15 2017 03:44
@revisualize Sometimes these things just make me feel so dumb! haha
JamesVitaly
@JamesVitaly
Mar 15 2017 03:44
just completed the return largest number in arrays challenge, but I am sure my answer is convoluted and not the best I wonder if anyone could help me improve it
function largestOfFour(arr) {
var largest = [];
for (var i = 0; i < arr.length; i++) {
if (arr[i].sort(function (a,b) {return b - a;}));} {
largest = arr[0].slice(0,1) +(',')+ arr[1].slice(0,1)+ (',') + arr[2].slice(0,1) + (',') + arr[3].slice(0,1);
var array = largest.split(',').map(Number);
return array; }
Joseph
@revisualize
Mar 15 2017 03:44
@sourabhrangdal You're not using the switch correctly.
Zaluth
@Zaluth
Mar 15 2017 03:44
@HeebieGeeBee i don't, i want to stop the function when the window has scrolled that much
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:45
@revisualize yes, i am getting confused in decrement, increment and case and the global var
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:45
@Zaluth got a codepen?
Joseph
@revisualize
Mar 15 2017 03:45
@sourabhrangdal How do you add one to a variable?
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:46
@revisualize var myVar++
Joseph
@revisualize
Mar 15 2017 03:46
@sourabhrangdal How do you subtract 1 from a variable?
@sourabhrangdal What if that variable was count?
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:47
@revisualize var myVar-- (or var myVar = myVar - 1)
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:47
@Zaluth well dont use a string
10 not "10"
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:47
Sigh
Goddamn it
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:48
@revisualize var count++ (or var count = count + 1) / (var count = count - 1)
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:48
@Zaluth but i dont know how you can tell anything else isnt working when theres nthing in the site
Joseph
@revisualize
Mar 15 2017 03:48
@sourabhrangdal you now know how to increment and decrement the global count variable.
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:48
@revisualize yes, to arrange or create increment and decrement in swtich, is a big deal for me now
Zaluth
@Zaluth
Mar 15 2017 03:49
@HeebieGeeBee hmm but still doesn't work
what i want to do is a smooth scroll, so scrollBy won't do
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:49
can there be more than two return?
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:49
@Zaluth i dont see anythig on the site to scroll with
Joseph
@revisualize
Mar 15 2017 03:49
@MathematicsCoding There can. But, when the first one is hit the function STOPS
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:49
@revisualize kind apologies, that i am taking your time, but could you spare a little time for this challenge, trying it from yesterdeay
Zaluth
@Zaluth
Mar 15 2017 03:50
@HeebieGeeBee if you click the button, the page should scroll
Joseph
@revisualize
Mar 15 2017 03:50
@sourabhrangdal Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
I got to watch a tutorial
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:51
@Zaluth nope
Zaluth
@Zaluth
Mar 15 2017 03:51
@HeebieGeeBee http://codepen.io/Zaluth/pen/bqrOGJ
maybe now?
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:52
nope where is it going to scroll to exactly?
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:53
I...
Zaluth
@Zaluth
Mar 15 2017 03:53
it should scroll by a set amount of px, in this case, 10. it shuld stop scrolling after that, but it doesn't
Joel
@MMK123
Mar 15 2017 03:54
hello
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 03:54
@revisualize trying :thumbsup:
Joel
@MMK123
Mar 15 2017 03:54
no clue what im to do here

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

// Your code above this line
return result;
}

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

Saboor Malik
@MathematicsCoding
Mar 15 2017 03:54
That one is hard but managed to pass
I will give you two hints
HeebieGeeBee
@HeebieGeeBee
Mar 15 2017 03:55
@Zaluth doesnt scroll anywhere
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:55
Add "Spaces" and add something between myNoun or myAdjective or etc... with ""
Good Luck :p
Zaluth
@Zaluth
Mar 15 2017 03:55
@HeebieGeeBee weird. it works for me
Joel
@MMK123
Mar 15 2017 03:55
@MathematicsCoding thanks
CamperBot
@camperbot
Mar 15 2017 03:55
mmk123 sends brownie points to @mathematicscoding :sparkles: :thumbsup: :sparkles:
:cookie: 186 | @mathematicscoding |http://www.freecodecamp.com/mathematicscoding
Saboor Malik
@MathematicsCoding
Mar 15 2017 03:55
:p
Joel
@MMK123
Mar 15 2017 03:57
dont i need to define what "" is though?
actually nvm
result = ""
Joseph
@revisualize
Mar 15 2017 03:58
@MMK123 "" is a string.
Joel
@MMK123
Mar 15 2017 03:58
hmmmmmmmmmmmmm
ok i will think about this one for a while
Joseph
@revisualize
Mar 15 2017 03:58

@MMK123 Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

ivorygrant
@ivorygrant
Mar 15 2017 04:02

for the golf code, I'm not sure why my Eagle code is not correct:

else if(par,strokes<=par-2){
return "Eagle";

i got the hole in one code
shouldn't i be comparing the strokes to par-2?
Joel
@MMK123
Mar 15 2017 04:04

@revisualize
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
the " " was so " " but " " so " ";

// Your code above this line
return result;
}

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

not sure what im doing
Joseph
@revisualize
Mar 15 2017 04:04
@MMK123 You're not using the parameters and you're not assigning the value to result.
Joel
@MMK123
Mar 15 2017 04:05
ohhh so i do need to assign value to result.. ok
buuuuuuuuuuuut result is going to have 4 values??
how does that work
maybe i do var result1 = "example"
var result2 = "example"
etc?
ivorygrant
@ivorygrant
Mar 15 2017 04:07
since you've defined the variables, you need to add them
Joel
@MMK123
Mar 15 2017 04:07
i dont understand how i assign four different values to one variable
ivorygrant
@ivorygrant
Mar 15 2017 04:07
so the words around the variables should be strings
Joseph
@revisualize
Mar 15 2017 04:07
@MMK123 No.
@MMK123 Do you understand what a parameter is?
Joel
@MMK123
Mar 15 2017 04:08
I don't think so
Joseph
@revisualize
Mar 15 2017 04:08

@MMK123 Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

@MMK123 Do you want more of an explanation about parameters?

If I have this code:

function addThree (num) {
    var result;
    result = num + 3;
    return result;
}

So, when we make the function call of:

addThree(10);

You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
When we do addThree(10) then the value of the parameter num is passed the argument value of ... 10
Then if you follow the code through.. result = num + 3; ... and we know the value of num is 10.
Therefore, if we follow through the function we end up with ... result = 10 + 3; then result = 13; then we return the result.

@MMK123 I have more of an explanation as well.
Joel
@MMK123
Mar 15 2017 04:11
ok i get it
let me go back to my code and try again
Joseph
@revisualize
Mar 15 2017 04:11
I just ate 6 Dove dark chocolates and I'm not ashamed.
ivorygrant
@ivorygrant
Mar 15 2017 04:12
the bite sized ones? i could eat more lol
plus dark choc > regular choc
healthwise
hey joseph, have you done the golf code challenge?
Joseph
@revisualize
Mar 15 2017 04:14
@ivorygrant I have.
Sam Felder
@sf8193
Mar 15 2017 04:15
function bouncer(arr) {
  var save;
  for(var i=0; i<arr.length; i++){
    save=arr[i];
    console.log(save);
    if(save===""||save===null ||save===false || save===0 || save===undefined)
    {  
      delete arr[i];
//       arr.splice(i,1);
    } 
    if(arr[i]===null)
      arr.splice(i,1);
  }
  return arr;
}

bouncer([7, "ate", "", false, 9]);

why is this giving me [7, "ate",null,null,9]?

I'm trying to get the null to go away with splice but it doesn't work

ivorygrant
@ivorygrant
Mar 15 2017 04:15
i got the hole in one code, but for the eagle code I have:
else if(par,strokes<=par-2){
return "Eagle";
Sam Felder
@sf8193
Mar 15 2017 04:15
if anyone has any ideas i would really appreciate it
Joseph
@revisualize
Mar 15 2017 04:15
@ivorygrant This: else if(par,strokes<=par-2){ isn't how you make the if condition.
@ivorygrant This: else if(strokes<=par-2){ is how you make the if condition.
Johnny vo
@jphivo
Mar 15 2017 04:16
Hello, can someone help me with the " Convert Celsius to Fahrenheit" challenge?
ivorygrant
@ivorygrant
Mar 15 2017 04:16
so why are we not passing the par num? I did it this way for the hole in one
if (par,1){
return "Hole-in-one!";
Joseph
@revisualize
Mar 15 2017 04:16
@jphivo What is the mathematical formula to convert celsius to fahrenheit?
@ivorygrant No.
@ivorygrant You're supposed to be comparing strokes to something.
Johnny vo
@jphivo
Mar 15 2017 04:18
@revisualize Temperture in Celsius times 9/5, plus 32, I think...?!
Joseph
@revisualize
Mar 15 2017 04:18
@jphivo How would you write that out like math?
ivorygrant
@ivorygrant
Mar 15 2017 04:18
the way I wrote it, the challenge shows that as correct...hmm
Johnny vo
@jphivo
Mar 15 2017 04:19
@revisualize That's my problem. I'm not sure how to do that. I have to use the "operator" signs.
Joseph
@revisualize
Mar 15 2017 04:19
@jphivo Yes.
+ - * /
Johnny vo
@jphivo
Mar 15 2017 04:21
so, first one they are asking me to convertToF(0) should return a number. How should I write that?
Joseph
@revisualize
Mar 15 2017 04:22
@jphivo How would you write that out like math?
Johnny vo
@jphivo
Mar 15 2017 04:25
I'm not sure, that's what I'm struggling with. C=( 32 )* 9/5
badalsaibo
@heyDante
Mar 15 2017 04:25
Anyone uses GSAP?
Joseph
@revisualize
Mar 15 2017 04:25
@jphivo
The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32
Fahrenheit is the temperature in Celsius times 9/5, plus 32
Fahrenheit is Celsius times 9/5, plus 32
Fahrenheit is Celsius times 9/5 + 32
Fahrenheit is Celsius * 9/5 + 32
....
Xavier Corena
@corenaxavier
Mar 15 2017 04:26
Hi Guys!
ivorygrant
@ivorygrant
Mar 15 2017 04:26
@jphivo you're getting there, just put it so you take into account order of operations since JS doesn't do that
btw Joseph, i got the golf code. thanks a bunch.
Arun Subbiah Arunachalam
@arsubbu
Mar 15 2017 04:27
what is wrong with this code

function titleCase(str) {
var newString=str.split(" ");
var newString1="";
var newString2="\"";
for(var i=0; i<newString.length;i++)
{

for(var j=0;j<newString[i].length;j++)
  {

    if(j>0)
    {

      newString1+=newString[i].charAt(j).toLowerCase();  

    }
    else
    {
      newString1=newString[i].charAt(j).toUpperCase();  

    }
  }
newString2+=newString1 + " ";

}
newString2=newString2.trim()+ "\""+".";
return newString2;
}

titleCase("sHoRt AnD sToUt");

Xavier Corena
@corenaxavier
Mar 15 2017 04:27
I'm having trouble with the "Stand in Line" problem. Firstly, I dont know much of what to do
Arun Subbiah Arunachalam
@arsubbu
Mar 15 2017 04:27
It works just fine. but the app still does not pass the testcase
Joseph
@revisualize
Mar 15 2017 04:27
I need to finish watching this lecture video.
ivorygrant
@ivorygrant
Mar 15 2017 04:27
@corenaxavier is that the queue problem?
Xavier Corena
@corenaxavier
Mar 15 2017 04:28
@ivorygrant Yeah. Are you also working on that?
Johnny vo
@jphivo
Mar 15 2017 04:28
@ivorygrant I'm still not sure how to write the code.
ivorygrant
@ivorygrant
Mar 15 2017 04:29
yep i completed it earlier; basically you need to add two commands: one that adds a number, and another that takes it off
Johnny vo
@jphivo
Mar 15 2017 04:29
C = 9/5 + 32;
Joseph
@revisualize
Mar 15 2017 04:29

@jphivo There is the function declaration of function convertToF(celsius) { .. You have a function name of convertToF and a parameter of celsius
Parameters are used just like variables. So, inside of the function you can use celsius JUST like any other variable.
If I have this code:

function addThree (num) {
    var result;
    result = num + 3;
    return result;
}

So, when we make the function call of:

addThree(10);

You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
When we do addThree(10) then the value of the parameter num is passed the argument value of ... 10
Then if you follow the code through.. result = num + 3; ... and we know the value of num is 10.
Therefore, if we follow through the function we end up with ... result = 10 + 3; then result = 13; then we return the result.

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32
Fahrenheit is the temperature in Celsius times 9/5, plus 32
Fahrenheit is Celsius times 9/5, plus 32
Fahrenheit is Celsius times 9/5 + 32
Fahrenheit is Celsius * 9/5 + 32
....

ivorygrant
@ivorygrant
Mar 15 2017 04:30
@corenaxavier it's two of the push, pop, shift, and unshift
@jphivo i completed it earlier, i'll do it again so i can try to explain it better
but you're very very close
if you just write everything out and assign it correctly it should work
Joseph
@revisualize
Mar 15 2017 04:32

@corenaxavier Gist by revisualize / FreeCodeCamp - Stand in Line.js

// How do you add a number (item) to the end of an array (arr)? What does this method return?
// How do you remove the first element from an array (arr)? What does this method return?

You're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

You just need to add a number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).
But, there is another part of this challenge. You need to know What the methods that do those two things return.

Xavier Corena
@corenaxavier
Mar 15 2017 04:35
@revisualize Okay. I'm trying to understand.
It still doesn't make sense at all.
ivorygrant
@ivorygrant
Mar 15 2017 04:36
@jphivo ok looked at again and you basically have it, you just need to properly assign that answer to the variable. Since you are given a number Celsius, that's the number you should be doing the calculating. then you just need to assign that answer to another variable
Joseph
@revisualize
Mar 15 2017 04:38
@corenaxavier How can I help?
@corenaxavier What part are you stuck with?
@corenaxavier How do you add an element to the end of an array? What if the array was arr and what if the element was item?
ivorygrant
@ivorygrant
Mar 15 2017 04:40
@jphivo did that explanation make sense? lmk
Johnny vo
@jphivo
Mar 15 2017 04:42
@ivorygrant I'm sorry but it doesn't. I'm having trouble how to write it. Can you please write me one example, so that I can understand it better?!
Joseph
@revisualize
Mar 15 2017 04:43
I did.
andry91959
@andry91959
Mar 15 2017 04:44
hello, If I want to get the output of" Hello, World.
Welcome to 30 Days of Code!" is this the right code?

function processData(inputString) {
// This line of code prints the first line of output
var welcome="";
welcome="Hello, world." + inputString;
// Write the second line of output that prints the contents of 'inputString' here.
return(welcome);
}

console.log("Welcome to 30 Days of Code!");

Xavier Corena
@corenaxavier
Mar 15 2017 04:44
@revisualize Well, I see the example BUT I don't understand how it would relate to this specific. Because what i'm understanding is
ivorygrant
@ivorygrant
Mar 15 2017 04:45
@jphivo sure so if i wanted to convert miles to km, it would look something like this: km = miles * 1.6 right? apply that same logic to convert a celsius to fahrenheit.
Joseph
@revisualize
Mar 15 2017 04:46
@corenaxavier How do you add an element to the end of an array? What if the array was arr and what if the element was item?
Xavier Corena
@corenaxavier
Mar 15 2017 04:46

@revisualize function nextInLine (arr, item) {

}
return 1 + 2 +3 + 4 + 5;

Joseph
@revisualize
Mar 15 2017 04:46
@corenaxavier With that code you have the return statement outside of the function.
@corenaxavier You're also returning some number.
ivorygrant
@ivorygrant
Mar 15 2017 04:47
you're very close, and i believe your misunderstanding is just assigning the right variables
Joseph
@revisualize
Mar 15 2017 04:47
@corenaxavier Your randomly placed return statement is returning 15
@corenaxavier How do you add an element to the end of an array? What if the array was arr and what if the element was item?
ivorygrant
@ivorygrant
Mar 15 2017 04:49
anyone else watching the sixers/warriors game. lol if philly wins haha
Xavier Corena
@corenaxavier
Mar 15 2017 04:50
@revisualize Well, let's see. I'm confused in the part when you say Array and arr.
thats pretty much just this correct?function nextInLine(arr, item) {
Joseph
@revisualize
Mar 15 2017 04:51
@corenaxavier What is this []?
var arr = [];
The variable arr is an Array
@corenaxavier Question: Do you know what an array is?
Xavier Corena
@corenaxavier
Mar 15 2017 04:54
@revisualize I spent 10 hours breezing by this stuff yesterday I don't think I memorized that.
Maybe slowing down and really viewing the material in debth would be best.
Joseph
@revisualize
Mar 15 2017 04:54
@corenaxavier THAT is your problem.
@corenaxavier See, I did the same thing when I went through Codecademy. I focused on getting the tests correct and not on learning the material.
@corenaxavier Sure, I got all the way through the JavaScript section on Codecademy. But, I didn't actually learn anything.
@corenaxavier If you don't know what an array is.. You really need to go back through the lessons. Because they're going to get harder and harder and harder and the information compounds upon the previous.
Matthew
@IMDBLM
Mar 15 2017 04:57
@corenaxavier This is what happened to me in FCC last year. I breezed through stuff but had to stop bc I understood nothing. This time around I'm going slower.
Xavier Corena
@corenaxavier
Mar 15 2017 04:57
@revisualize Definitely. @IMDBLM You can't rush the process. Im going to the back of the line :[
haha thanks!
Joseph
@revisualize
Mar 15 2017 04:57
I've done the Basic JavaScript secont of FreeCodeCamp about 3 times now.
Some lessons I've done about 5 or 6 times.
Xavier Corena
@corenaxavier
Mar 15 2017 04:58
I'm so excited to learn this stuff. I switched my major to CS
Matthew
@IMDBLM
Mar 15 2017 04:58
@revisualize That's good to hear. I think I should do the same!
Xavier Corena
@corenaxavier
Mar 15 2017 04:58
@revisualize Awesome. You've got the the principals down pat.
@IMDBLM Awesome website!
@IMDBLM Are you working for anyone as a programer yet?
Matthew
@IMDBLM
Mar 15 2017 05:02
@corenaxavier Nope. I suck mega bad.
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 05:02
is this correct, If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
case 1:
switch(card) {
    case 1:
      if (card === 2 || card === 3 || card === 4 || card === 5 || card === 6) {
        count = count + 1 + " Bet";
      } count = count + 1 + " Hold";
      break;
Joseph
@revisualize
Mar 15 2017 05:03
@sourabhrangdal That is not correct.
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 05:03
@revisualize ok
Xavier Corena
@corenaxavier
Mar 15 2017 05:04
@IMDBLM Ah, how much time have you been coding now?
Matthew
@IMDBLM
Mar 15 2017 05:04
@corenaxavier OH the podcast page. That's a template I bought because it was complex, what I needed. I've been an intern with the Greek Orthodox Archdiocese for a few years now, but I'm mostly working on pre-fab web templates and checking code for particular stuff.
Joseph
@revisualize
Mar 15 2017 05:04
@sourabhrangdal Look. A case statement is compared to the value in the switch
so. if card is in your switch. and you have case 1: it would do is card === 1 true or false?
If it is true. It will do stuff inside of the case statement.
Matthew
@IMDBLM
Mar 15 2017 05:06
@corenaxavier I'm a total hack, man. No joke. As an intern I'm basically a monkey following instructions. :-D
Joseph
@revisualize
Mar 15 2017 05:06
@sourabhrangdal There is no card in any deck of cards that is 1
@IMDBLM You're an intern? Are you a software development intern?
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 05:07
@revisualize ok so, the case would be
switch(card) {
case (card === 2 || card === 3 || card === 4 || card === 5 || card === 6)

}
Joseph
@revisualize
Mar 15 2017 05:08
@sourabhrangdal That isn't how case statements work.
Saketh Ramanavarapu
@S522616
Mar 15 2017 05:08

// Initialize these three variables
var a = 6;
var b = 15;
var c = "I am a String!";

// Do not change code below this line

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

I was unable to find whats wrong with my code
??
Joseph
@revisualize
Mar 15 2017 05:08
@sourabhrangdal That would be doing
is card === (card === 2 || card === 3 || card === 4 || card === 5 || card === 6) True or false.
@sourabhrangdal If you want to use a switch it is just individual case statements.
case 2:
case 3:
case 4:
case 5:
case 6:
...
Saketh Ramanavarapu
@S522616
Mar 15 2017 05:09
My Assignment is not moving forward please can some one help
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 05:09
@revisualize
switch(card) {
case 2:
case 3:
case 4:
case 5:
case 6:
//statement
count+= "";
}
@revisualize is card === (card === 2 || card === 3 || card === 4 || card === 5 || card === 6) false.
Johnny vo
@jphivo
Mar 15 2017 05:10
@revisualize Thank you, I finally got it.
CamperBot
@camperbot
Mar 15 2017 05:10
jphivo sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
Richard Belotte
@belotte
Mar 15 2017 05:10
Can someone one explain why I would use a global string object as opposed to string primitive if methods can be used on primitives as well?
Joseph
@revisualize
Mar 15 2017 05:10
@sourabhrangdal No. That logic doesn't work.
CamperBot
@camperbot
Mar 15 2017 05:10
:star2: 3525 | @revisualize |http://www.freecodecamp.com/revisualize
Sourabh Rangdal
@sourabhrangdal
Mar 15 2017 05:10
@revisualize ok
Joseph
@revisualize
Mar 15 2017 05:10
@sourabhrangdal Should you be adding a string to count?
JenimDacket
@JenimDacket
Mar 15 2017 05:10
Is there a cleaner way to do this????
function truncateString(str, num) {
  if(str.length>num && num>3){
    return str.slice(0, num-3)+"..."; 
  }
  else if(num<3){
    return str.slice(0, num) +"...";
  }
  else if(str.length<=num){
    return str;
  }

}

truncateString("spleechless alabaster", 2);