These are chat archives for FreeCodeCamp/HelpJavaScript

18th
May 2017
Aizaz Shahid
@aizazshahid
May 18 2017 00:00
@GingerJava first tell, what do you want to do :)
@GingerJava paste the full function code !
Heather
@GingerJava
May 18 2017 00:00
@forwebtech push add numbers from 1-9 to myArray with a for loop
odd* numbers not add numbers lol

// Example
var ourArray = [];

for (var i = 0; i < 10; i += 2) {
ourArray.push(i);
}

// Setup
var myArray = [];

// Only change code below this line.
for (var i = 1; i < 9; i +=2);
myArray.push(i);

Aizaz Shahid
@aizazshahid
May 18 2017 00:01
then use a logic into your loop, like i % 2 === 0 even number remainder always be zero !
and also do that for ( , , i++ )
or you can initialize your i to 2 then your logic will work !
Heather
@GingerJava
May 18 2017 00:02
@forwebtech but then it won't include 1 right?
Aizaz Shahid
@aizazshahid
May 18 2017 00:03
yes !
@GingerJava are you doing FCC challenge ? and do you want to store even numbers ?
Heather
@GingerJava
May 18 2017 00:04
@forwebtech no the instructions say odd numbers. its the iterate odd numbers with a for loop challenge.
Aizaz Shahid
@aizazshahid
May 18 2017 00:05
oh, so just change that i < 9 to i <= 9
Heather
@GingerJava
May 18 2017 00:05
@forwebtech nope that returned 11
Aizaz Shahid
@aizazshahid
May 18 2017 00:05
no it will not return 11 !
because your loop will stopped after returning the 9 !
why don't you try that !
Dan Couper
@DanCouper
May 18 2017 00:10
for (var i = 1; i <= 9; i +=2)  {
  myArray.push(i);
}
not
for (var i = 1; i < 9; i +=2);
myArray.push(i);
otherwise should be fine
Aizaz Shahid
@aizazshahid
May 18 2017 00:16
@GingerJava also you forgot { } to add, as @DanCouper mentioned. remove that ;
David Amanze
@GodKingShogun
May 18 2017 00:25
did someone call me out. i just got back but i couldn't scroll to the message
3gimpfingers
@3gimpfingers
May 18 2017 00:31
Why does this function not think the first wheels, seats, and engines are variables? :
var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = wheels;
  this.seats = seats;
  this.engines = engines;
};
Aizaz Shahid
@aizazshahid
May 18 2017 00:34
@3gimpfingers what do you mean by first ?
3gimpfingers
@3gimpfingers
May 18 2017 00:36
@forwebtech this.wheels part is not a variable, but a property of the construct, the = wheels is a variable. How does it know the difference?
Aizaz Shahid
@aizazshahid
May 18 2017 00:37
@3gimpfingers this.wheels is also a variable but it is a global variable which can be access outside the object with the help of that object. this refers to the current object.
Stephen James
@sjames1958gm
May 18 2017 00:38
@3gimpfingers When you call a constructor function with new js creates a new object and assign it to this.
this.wheels refers to the wheels property on the new object
Aizaz Shahid
@aizazshahid
May 18 2017 00:38
@3gimpfingers and function ( wheels, seats, engines ) they are parameters, which are used to pass the values to those variables this.... at the time of initialization!
@3gimpfingers
like:
var bmw = new Car( 2, 3, 1 );
bmw.wheels;   // 2 returns, and `.wheels` is the property of that Car.
Mike
@MikeJSchorah
May 18 2017 00:40
With Big O notation--Are nested for loops the only things that I really need to avoid?
@sjames1958gm
3gimpfingers
@3gimpfingers
May 18 2017 00:41
@forwebtech @sjames1958gm If I want to alternate between the variable and the property in a function, how do I tell the function what the difference is? For instance: If I have a property with the same name as a parameter in a function, how do I tell the function it's the parameter and not the property, and vice versa, I want to reference?
Stephen James
@sjames1958gm
May 18 2017 00:41
@3gimpfingers Well a property is always referenced on an object - like this. so by supplying an object you make that distinction.
Aizaz Shahid
@aizazshahid
May 18 2017 00:41
@3gimpfingers well in this case its not a function actually your are making a object constructor.
Mike
@MikeJSchorah
May 18 2017 00:42
Does anyone know anything about Big O notation?
Cory Johnson
@CygnusSW
May 18 2017 00:42
@MikeJSchorah Nested complex data types and heavy DOM manipulation can also impact performance, but the DOM manipulation isn't generally measured in Big O (at least not to my knowledge).
Mike
@MikeJSchorah
May 18 2017 00:42
Thanks @Rom2711
CamperBot
@camperbot
May 18 2017 00:42
mikejschorah sends brownie points to @rom2711 :sparkles: :thumbsup: :sparkles:
:cookie: 429 | @rom2711 |http://www.freecodecamp.com/rom2711
Mike
@MikeJSchorah
May 18 2017 00:43
Do I really need to know this for interviews with startups?
Cory Johnson
@CygnusSW
May 18 2017 00:43
For front end, probably not
3gimpfingers
@3gimpfingers
May 18 2017 00:43
@forwebtech Okay, but if it's a function @sjames1958gm If I don't want to use this.
Stephen James
@sjames1958gm
May 18 2017 00:43
@MikeJSchorah It is probably something to understand at least to some degree - maybe not in depth.
Cory Johnson
@CygnusSW
May 18 2017 00:43
Knowing more about async programming event loops, etc is probably more useful
Mike
@MikeJSchorah
May 18 2017 00:43
Thanks @Rom2711 So just Google and Facebook, then huh
CamperBot
@camperbot
May 18 2017 00:43
mikejschorah sends brownie points to @rom2711 :sparkles: :thumbsup: :sparkles:
:warning: mikejschorah already gave rom2711 points
HeebieGeeBee
@HeebieGeeBee
May 18 2017 00:44
@JLuboff think im getting closer, but theres som odd behaviour sometimes on a the occasional tile hit
Mike
@MikeJSchorah
May 18 2017 00:44
@sjames1958gm Thanks. Have you read Cracking the Coding Interview or know anything about it?
CamperBot
@camperbot
May 18 2017 00:44
mikejschorah sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7361 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 18 2017 00:44
@MikeJSchorah I have not.
@3gimpfingers Well you have to have some object to reference the properties on.
Joseph
@revisualize
May 18 2017 00:46
Hey hey.
3gimpfingers
@3gimpfingers
May 18 2017 00:46
@sjames1958gm what I understand is that I need to use bracket notation and use quotes to reference a property, and not use quotes for variables. Is that correct?
Javed Kadri
@devajirdak
May 18 2017 00:46

var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.
var singleVal = array.reduce(function(acc, val) {
return acc + val;
}, 0);

singleVal = array;

hy guys, why would this not work ? Thanks
Joseph
@revisualize
May 18 2017 00:47
@devajirdak Why are you overwriting singleVal back to the value of array?
Aizaz Shahid
@aizazshahid
May 18 2017 00:47
@3gimpfingers i think you are talking about that :
function foo(a) {
  this.a = a + 2;
  return this.a;
}

console.log( foo(12) ); // 14
Stephen James
@sjames1958gm
May 18 2017 00:47
@devajirdak Why are you reseting singleVal back to array?
Joseph
@revisualize
May 18 2017 00:47
@devajirdak By doing that you
're undoing all of your reduce operations.
@devajirdak Remove this: singleVal = array;
Javed Kadri
@devajirdak
May 18 2017 00:48
make sense, it was there from before. Thanks @revisualize
CamperBot
@camperbot
May 18 2017 00:48
devajirdak sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3980 | @revisualize |http://www.freecodecamp.com/revisualize
Stephen James
@sjames1958gm
May 18 2017 00:50
@3gimpfingers If you are referencing a named property you can do obj.prop or obj["prop"] or if in a variable obj[var]
Joseph
@revisualize
May 18 2017 00:51
Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
Jasmine J
@Kitana16
May 18 2017 00:52
Can anyone help me with a sorting issue
Netrunner21
@Netrunner21
May 18 2017 00:52
@Kitana16 sure
Joseph
@revisualize
May 18 2017 00:52
@Kitana16 Sure.
@Kitana16 Are you using default .sort()?
Jasmine J
@Kitana16
May 18 2017 00:53
http://codepen.io/JazzItUp/pen/MmGEVm --- i can currently sort by name and price but i also need to sort by color
Joseph
@revisualize
May 18 2017 00:54
@Kitana16 does color have a weighted value?
Or is it just color name?
Jasmine J
@Kitana16
May 18 2017 00:55
a name
Joseph
@revisualize
May 18 2017 00:55
If it is color name the how do you want to sort?
By alpha?
Jasmine J
@Kitana16
May 18 2017 00:55
color name ascfending
Joseph
@revisualize
May 18 2017 00:55
Okay. Well you'd have to capture all of the names.
However there is going to be an issue if two color names have the same first letter.
Then you're going to have an issue with the fact that you have multiple yellow.
You're also going to have to sort by something else with color.
If everything is yellow and you sort by yellow.. It's not really going to do anything.
If one is blue and the rest are yellow. You can put the blue on top but... What about the rest of the yellows?
If you have 3 blue and 6 yellow...
That could be a challenge.
Jasmine J
@Kitana16
May 18 2017 00:58
i figure this can work by the color then name
Joseph
@revisualize
May 18 2017 00:59
I'm at an event and that problem is a little beyond the scope of what I can allot time for.
Jasmine J
@Kitana16
May 18 2017 00:59
that is fine
thank u for the input
@revisualize thanks
CamperBot
@camperbot
May 18 2017 00:59
kitana16 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3981 | @revisualize |http://www.freecodecamp.com/revisualize
Jasmine J
@Kitana16
May 18 2017 01:02
@Netrunner21 can you help?
Netrunner21
@Netrunner21
May 18 2017 01:02
@Kitana16 I'm not that deep into the projects yet.
@Kitana16 I can help with basic sorting issues for algoritms, but I wouldn't know where to begin on how to sort colors.
3gimpfingers
@3gimpfingers
May 18 2017 01:03
@sjames1958gm Okay, so it's not possible to reference a variable in dot notation. Thanks, man. That makes sense. :)
CamperBot
@camperbot
May 18 2017 01:03
3gimpfingers sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7362 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
3gimpfingers
@3gimpfingers
May 18 2017 01:05
@forwebtech Yes, I am talking about that, but @sjames1958gm made it quite clear for me.
@forwebtech Thanks for the help.
CamperBot
@camperbot
May 18 2017 01:05
3gimpfingers sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 565 | @forwebtech |http://www.freecodecamp.com/forwebtech
3gimpfingers
@3gimpfingers
May 18 2017 01:06
@revisualize Yes, that makes sense. I thank you.
CamperBot
@camperbot
May 18 2017 01:06
3gimpfingers sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3982 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 18 2017 01:07
You're welcome. ?
Netrunner21
@Netrunner21
May 18 2017 01:07
@Kitana16 Here's a thought, since you only have a few items for sale, why don't you give each items a specific HTML ID or class based on their color. All the yellows would have class="yellow".
Joseph
@revisualize
May 18 2017 01:07
Heheh.
3gimpfingers
@3gimpfingers
May 18 2017 01:09
@revisualize :D You're quite thorough with explanations. I like that. We don't take enough time for that anymore.
Keon Samuel
@keonsam
May 18 2017 01:09
doesn't indexOf work on arrays?
nvm I was in the wrong doc.
Netrunner21
@Netrunner21
May 18 2017 01:10
@Kitana16 also, when you reference background-color in your js, you didn't include the hyphen.
Csaba Balogh
@JasonCorp84
May 18 2017 01:14
re
talshir
@talshir
May 18 2017 01:14
Hey all, I'm having trouble with the Stand In Line challenge. How do I get the function to return the value that was removed from the array?
Csaba Balogh
@JasonCorp84
May 18 2017 01:14
do we have to use regExp at Falsy Bouncer ?
linusidom
@linusidom
May 18 2017 01:14
Newbie Question (FCC Advanced Algorithms: Record Collection: https://www.freecodecamp.com/challenges/record-collection). The Console Log never seems to update. No matter what I return I keep getting the Object "collection" back. I know the final result should be a modified version of "collection" however how can test iterations of my code with no console logging?
Stephen James
@sjames1958gm
May 18 2017 01:15
@JasonCorp84 No
@talshir You can assign it to a variable and return that variable or return arr.shift(); directly
Csaba Balogh
@JasonCorp84
May 18 2017 01:15
@sjames1958gm thank you
CamperBot
@camperbot
May 18 2017 01:15
jasoncorp84 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7363 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Csaba Balogh
@JasonCorp84
May 18 2017 01:17
Then how we check if it is NaN ?
isNaN(value) will remove anything that is string also
talshir
@talshir
May 18 2017 01:18
@sjames1958gm can you tell me what's wrong with my code?
function nextInLine(arr, item) {
var a = testArr[0];
arr = testArr.push(item);
arr = testArr.shift();
return a;
}
Csaba Balogh
@JasonCorp84
May 18 2017 01:18

 if (value !== false && value !== "" && value !== null && value !== undefined && value !== 0 && isNaN(value) === false){
      return true;
Stephen James
@sjames1958gm
May 18 2017 01:19
@talshir You should only be using arr inside the function - not testArr
don't assign result of push to anything as it is a number not an array
@talshir Just return the shifted value -
@JasonCorp84 Try Number.isNaN rather than just isNaN
Netrunner21
@Netrunner21
May 18 2017 01:21
@JasonCorp84 I believe you can use just Boolean
@what's the name of the challenge again?
linusidom
@linusidom
May 18 2017 01:22
@JasonCorp84
Csaba Balogh
@JasonCorp84
May 18 2017 01:22
Falsy Bouncer
linusidom
@linusidom
May 18 2017 01:22
@JasonCorp84
Try this:
return arr.filter(function(item){
if(item === false || item === null || item === 0 || item === "" || item === undefined || Number.isNaN(item) !== false){
return false;
}
return true;
});
Netrunner21
@Netrunner21
May 18 2017 01:23
@JasonCorp84 nevermind, I thought this was Boo Whoo
Csaba Balogh
@JasonCorp84
May 18 2017 01:23
|| is not correct I believe
Leonardo de Melo
@Leonardo-demeloweb
May 18 2017 01:23
hello guys! i am stuck on this, any help to understand whats is wrong with? i researched by issues on git and did not achieve the mistake done here. Thought this is a common problem with this challenge

var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {

  // Only change code below this line.

  var gear = 0;

  this.getGear = function(change){
    gear += change;
  };

  this.setGear = function(){
    return gear;
  };


};

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(3);
Netrunner21
@Netrunner21
May 18 2017 01:23
@JasonCorp84 point still stands. I have one line of code about 20 characters long.
Csaba Balogh
@JasonCorp84
May 18 2017 01:24
@Netrunner21 thank you
CamperBot
@camperbot
May 18 2017 01:24
jasoncorp84 sends brownie points to @netrunner21 :sparkles: :thumbsup: :sparkles:
:cookie: 300 | @netrunner21 |http://www.freecodecamp.com/netrunner21
Netrunner21
@Netrunner21
May 18 2017 01:25
@JasonCorp84 did you get it to work?
Csaba Balogh
@JasonCorp84
May 18 2017 01:25
nope, it try to find out what do you mean by number
function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  function noFalsy(value, index, array) {


    if (value !== false && value !== "" && value !== null && value !== undefined && value !== 0 && arr.isNaN(value) !== false){
      return true;
    }

    else {
      return false;
    }
  }
  return arr.filter(noFalsy);
  //return jo;
}

bouncer([false, null, 0, NaN, undefined, "", "a"]);
this is how it looks
Netrunner21
@Netrunner21
May 18 2017 01:26
@JasonCorp84 You can straight up filter Booleans.
linusidom
@linusidom
May 18 2017 01:27

@talshir
Try this:
var nextInLine = arr;

nextInLine.push(item);
var popped = arr[0];
nextInLine.shift();

return popped; // Change this line

Csaba Balogh
@JasonCorp84
May 18 2017 01:27
nice, I completely missed that part
Netrunner21
@Netrunner21
May 18 2017 01:27
@JasonCorp84 works now?
Csaba Balogh
@JasonCorp84
May 18 2017 01:28
I am not that fast, but I just realized it could be way simpler than it is. So I have a complete clue now
2 min probably
Netrunner21
@Netrunner21
May 18 2017 01:30
@JasonCorp84 Cool. Let me know if you get stuck.
Mauro
@mauronml
May 18 2017 01:30
Hello Everyone. Has anyone gotten the Forismatic API to work with Codepen? http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en
here’s my pen for reference: http://codepen.io/mauronml/pen/VbQpWd
Gulsvi
@gulsvi
May 18 2017 01:32
@mauronml Codepen is going to enforce HTTPS in a couple of weeks. Forismtaic doesn't support HTTPS. Whether or not it's working now, it's probably best to use a different API. This one is popular: https://quotesondesign.com/api-v4-0/
Mauro
@mauronml
May 18 2017 01:32
I’m getting GET https://crossorigin.me/http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en&_=1495071117834 403 () error
@SkyCoder01 yeah, weird thing is you can do an https request to forismatic now as well
but not in codepen
Leonardo de Melo
@Leonardo-demeloweb
May 18 2017 01:34
like this works!

var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {

  // Only change code below this line.

  var gear = 0;


  this.getGear = function(){
    return gear;
  };


   this.setGear = function(change){
    gear = change;
  };


};

var myCar = new Car();

var myBike = new Bike();
Gulsvi
@gulsvi
May 18 2017 01:34
@mauronml I think that's because you're using a CORS proxy as a HTTPS proxy. I don't like proxies - they go down without notice
Mauro
@mauronml
May 18 2017 01:35
@SkyCoder01 no, i meant if you browse the api with https it works. On codepen it does not work whether i use the CORS proxy or not. I get different errors.
@SkyCoder01 I have been able to get it to work with other API, so yeah, something is wonky with forismatic’s API
@SkyCoder01 maybe someone here had found a workaround :p
Long Nguyen
@longnt80
May 18 2017 01:36
@mauronml maybe you can use another API?
Mauro
@mauronml
May 18 2017 01:37
@longnt80 yep. that’s what I’m gonna have to do
Gulsvi
@gulsvi
May 18 2017 01:37
@mauronml Interesting, seems they support HTTPS now :) they never did in the past, so in the front end room, we've always told people to use a different API. Let me debug more
Netrunner21
@Netrunner21
May 18 2017 01:37
I see @QuincyLarson is in the room. Thanks for FreeCodeCamp. This is really great.
CamperBot
@camperbot
May 18 2017 01:37
netrunner21 sends brownie points to @quincylarson :sparkles: :thumbsup: :sparkles:
:star2: 1292 | @quincylarson |http://www.freecodecamp.com/quincylarson
Mauro
@mauronml
May 18 2017 01:38
@SkyCoder01 yep, though it does not seem they are sending CORS headers in their http/https requests, so you still need a CORS proxy. Let me know if you figure something out!
Gulsvi
@gulsvi
May 18 2017 01:39
@mauronml It works fine - just use jsonp as your data type and change our URL:
$("#getQuote").on("click", function(e) {
  e.preventDefault();
  var quotesAPI = "https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?";
  $.ajax({
    url: quotesAPI,
    dataType: "jsonp",
    success: function(data) {
      console.log(data.quoteText);
      $(".message").html(data.quoteText);
    }
  });
});
You don't need a CORS proxy for any of the front-end projects here at Free Code Camp
RocioAlvarezB
@RocioAlvarezB
May 18 2017 01:40
I maybe overthinking this and its confusing me but what does console.log mean
Mauro
@mauronml
May 18 2017 01:40
@SkyCoder01 Woot! Yes, that worked. TYVM!
Long Nguyen
@longnt80
May 18 2017 01:40
@RocioAlvarezB console.log : to log result into the console
RocioAlvarezB
@RocioAlvarezB
May 18 2017 01:43
@longnt80 xD wow pretty self explanatory lol thanks
CamperBot
@camperbot
May 18 2017 01:43
rocioalvarezb sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @longnt80 |http://www.freecodecamp.com/longnt80
xiongyunlong
@xiongyunlong
May 18 2017 02:08

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

help
me
buddermancer
@buddermancer
May 18 2017 02:12
Hello
Anyone still here?
I need to know if it will teach what the return element means in JS
Pamela guy
@219tenderlips
May 18 2017 02:13

help please
// Setup
var myStr = "Jello World";

// Only change code below this line

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

myStr = "Hello World";

what am I doing wrong?
buddermancer
@buddermancer
May 18 2017 02:13
Which Challenge? @219tenderlips
Pamela guy
@219tenderlips
May 18 2017 02:13
understand String Immutability
Correct the assignment to myStr to achieve the desired effect.
buddermancer
@buddermancer
May 18 2017 02:14
Alright
You need to remove the original myStr variable
or
the one before // Fix Me
the myStr = "Hello World";
Pamela guy
@219tenderlips
May 18 2017 02:15
comment it out?
buddermancer
@buddermancer
May 18 2017 02:15
remove it
it says "fix me" so you fix it instead of creating a new one
Because in the line you did, myStr[0] = "H"; // Fix Me
myStr = "Hello World";
Eric Hasegawa
@EricHasegawa
May 18 2017 02:16
I've been stuck on the "Profile Lookup" challenge all day, can anyone lend a hand?
buddermancer
@buddermancer
May 18 2017 02:16
You're changing myStr
twice
What is Profile Lookup under
JS?
What Section
Eric Hasegawa
@EricHasegawa
May 18 2017 02:16
@buddermancer Yeah basic javascript
buddermancer
@buddermancer
May 18 2017 02:17
Let me see
Pamela guy
@219tenderlips
May 18 2017 02:17
yes
Eric Hasegawa
@EricHasegawa
May 18 2017 02:17
Near the end of the first course on JS @buddermancer
buddermancer
@buddermancer
May 18 2017 02:17
I'm not on it yet
@219tenderlips Did you finish the challenge?
I'm not at that point in JS yet
@EricHasegawa
I'd recommend resetting and trying again
Eric Hasegawa
@EricHasegawa
May 18 2017 02:18
@buddermancer No worries thanks anyway
CamperBot
@camperbot
May 18 2017 02:18
erichasegawa sends brownie points to @buddermancer :sparkles: :thumbsup: :sparkles:
:cookie: 176 | @buddermancer |http://www.freecodecamp.com/buddermancer
buddermancer
@buddermancer
May 18 2017 02:18
@219tenderlips Did you complete the challenge?
Pamela guy
@219tenderlips
May 18 2017 02:18
no
buddermancer
@buddermancer
May 18 2017 02:18
What's wrong now?
send me the script
you have
Pamela guy
@219tenderlips
May 18 2017 02:19
just looking over what you wrote
Claudio Restifo
@Marmiz
May 18 2017 02:19
@EricHasegawa what's your code looking like?
amelink
@amelink
May 18 2017 02:20
Hi , can someone help me for the "Profile Lookup" please ?
buddermancer
@buddermancer
May 18 2017 02:20
@EricHasegawa Has the same issue @amelink
You two should try to work together
Or someone could help both of you
@219tenderlips I think I found another issue with your code
@amelink I cannot help you though, I'm not on Profile Lookup yet
Pamela guy
@219tenderlips
May 18 2017 02:21
what is it please?
buddermancer
@buddermancer
May 18 2017 02:21
It says that you cannot assign a certain letter to the variable
You have to change the entire script
But you are assigning the first letter "J" to the letter "H"
Pamela guy
@219tenderlips
May 18 2017 02:22
that is correct
Netrunner21
@Netrunner21
May 18 2017 02:22
@amelink I can
buddermancer
@buddermancer
May 18 2017 02:22
you have myStr[0] = "H";
You need to put the whole new string in
Becuase Strings are immutable and you have to change the whole string not just one letter
Eric Hasegawa
@EricHasegawa
May 18 2017 02:23
Thanks @leftynaut for your help with Checkpoint: Profile Lookup
CamperBot
@camperbot
May 18 2017 02:23
erichasegawa sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
:cookie: 638 | @leftynaut |http://www.freecodecamp.com/leftynaut
amelink
@amelink
May 18 2017 02:23

I did it :function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0 ; i < contacts.length ; i++) {
if (firstName == contacts[i].firstName) {
if (contacts[i].hasOwnProperty(prop)) {
console.log(contacts[i].prop);
return contacts[i].prop;
} else {
return "No such property";
}
} else {
return "No such contact";
}

}
// Only change code above this line
}

I don't know why it doesn't working
Eric Hasegawa
@EricHasegawa
May 18 2017 02:23
@amelink I just finished the challenge, what's the problem?
Netrunner21
@Netrunner21
May 18 2017 02:23
try contacts[i][prop]
buddermancer
@buddermancer
May 18 2017 02:23
Tell me what happens @219tenderlips
Netrunner21
@Netrunner21
May 18 2017 02:24
You can't use dot notation on a variable (prop)
Pamela guy
@219tenderlips
May 18 2017 02:24
var myStr = "Jello World";
buddermancer
@buddermancer
May 18 2017 02:24
"Hello World" is what you're trying to change it to
Pamela guy
@219tenderlips
May 18 2017 02:24
myStr = "Hello World";
buddermancer
@buddermancer
May 18 2017 02:24
Yes
Eric Hasegawa
@EricHasegawa
May 18 2017 02:24
@amelink First of all I think your first if statement should have three equals signs between firstName and contacts[i].firstName (===)
Pamela guy
@219tenderlips
May 18 2017 02:25
thank you
buddermancer
@buddermancer
May 18 2017 02:25
Sorry, the first instructions I gave you were wrong, I was looking at my solution and not the original, that's why I told you to remove the correct script
by accident
Pamela guy
@219tenderlips
May 18 2017 02:26
ok
Claudio Restifo
@Marmiz
May 18 2017 02:26
@amelink don't use dot notation on variables:
contacts[i].prop
Use the square brakets notation[]
Netrunner21
@Netrunner21
May 18 2017 02:26
@amelink also you're not going to be using console log in this challenge. Not sure what you are using it for.
Claudio Restifo
@Marmiz
May 18 2017 02:27
@amelink let me reformat your code for better readability:
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0 ; i < contacts.length ; i++) {
if (firstName == contacts[i].firstName) {
if (contacts[i].hasOwnProperty(prop)) {
console.log(contacts[i].prop);
return contacts[i].prop;
} else {
return "No such property";
}
} else {
return "No such contact";
}
}
// Only change code above this line
}
Netrunner21
@Netrunner21
May 18 2017 02:27
@amelink @Marmiz is right. You'll use contacts[i][prop]
BigData95
@BigData95
May 18 2017 02:28
 var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  for( var i = 0; i < contacts.length; i++){
    if(firstName === contacts[i].firstName){
      if(contacts[i].hasOwnProperty(prop) !== false ){
        return contacts[i].prop;
      }else{
        return "No such property";
      }
    }else{
      return "No such contact";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Hi. Any help?
I think i might be wrong on the if tatement
Claudio Restifo
@Marmiz
May 18 2017 02:28
@Netrunner21 FYI console.log won't affect the outcome of a function (unless you're logging a non existing variable)
Netrunner21
@Netrunner21
May 18 2017 02:28
I think it can be removed
d38tang
@d38tang
May 18 2017 02:28
Hi, could someone help me on Search and Destroy?
function destroyer(arr) {
  var newArray = arr.filter(function(elements){
    var match = false;
    for (var i = 1; i < arguments.length; i++){
      if (elements === arguments[i]){
        match = true;
        break;
      }
    }
    return !match;
  });
  return newArray;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Claudio Restifo
@Marmiz
May 18 2017 02:29
@Netrunner21 it can, but can be left there :)
You usually keep them while testing and remove them in the "final product"
Pamela guy
@219tenderlips
May 18 2017 02:29

still not working
// Setup
var myStr = "Jello World";

// Only change code below this line

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

var myStr = "Jello World";
myStr = "Hello World";

Netrunner21
@Netrunner21
May 18 2017 02:29
@Marmiz I usually just return what I'm testing. To each their own I guess
amelink
@amelink
May 18 2017 02:29

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

}
// Only change code above this line
}

it's still not working
Netrunner21
@Netrunner21
May 18 2017 02:30
@amelink It's very very close. Looks almost identical to mine. Let me find what's different.
Andrew Saganda
@asaganda
May 18 2017 02:31
how difficult is it to start the "counting cards" problem for js?
any advice of how to start the logic?
Claudio Restifo
@Marmiz
May 18 2017 02:31
@Netrunner21 that's not a very good way of testing :) (according to the needs of course)
returning will stop a function execution and sometimes you need to test if the callbacks or promises are passed down. :)
It all depends on the needs.
All I'm saying is that a console.log won't affect the outcome of the FCC test ;)
abraham anak agung
@padunk
May 18 2017 02:32
@d38tang you are returning true or false in filter.
Netrunner21
@Netrunner21
May 18 2017 02:32
@amelink only different is this line:
if (contacts[i].hasOwnProperty(prop) === true) {
buddermancer
@buddermancer
May 18 2017 02:32
Is there a command in JS to display text?
d38tang
@d38tang
May 18 2017 02:32
@padunk i thought that is what your supposed to return
Netrunner21
@Netrunner21
May 18 2017 02:32
@Marmiz I gotcha. Thanks for explaining that to me.
CamperBot
@camperbot
May 18 2017 02:32
netrunner21 sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 873 | @marmiz |http://www.freecodecamp.com/marmiz
buddermancer
@buddermancer
May 18 2017 02:33
Is there a command in JS to display text?
Claudio Restifo
@Marmiz
May 18 2017 02:33
@amelink you're returning no such contact inside the loop. But what if the contact is in the next chunk?
amelink
@amelink
May 18 2017 02:33
still not working
abraham anak agung
@padunk
May 18 2017 02:33
@d38tang no read the instruction again
Netrunner21
@Netrunner21
May 18 2017 02:33
here's mine:
function lookUpProfile(firstName, prop){
// Only change code below this line

for (var i = 0; i < contacts.length ; i++) {
  if (contacts[i].firstName == firstName) {
     if (contacts[i].hasOwnProperty(prop) === true) {
       return contacts[i][prop];
     }
  return "No such property"; 
  } 
}
return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
Eric Hasegawa
@EricHasegawa
May 18 2017 02:33
@asaganda A lot of people seem to have trouble with it, I'd start by creating a switch statement that groups the cards into 3 sets (ones that change count by +1, -1, and 0 )
Does that make sense?
abraham anak agung
@padunk
May 18 2017 02:34
@buddermancer what you mean by display text? you could print it with console.log();
Andrew Saganda
@asaganda
May 18 2017 02:34
@EricHasegawa yes that does, thanks. I was thinking that also but i wanted to confirm
CamperBot
@camperbot
May 18 2017 02:34
asaganda sends brownie points to @erichasegawa :sparkles: :thumbsup: :sparkles:
:cookie: 218 | @erichasegawa |http://www.freecodecamp.com/erichasegawa
d38tang
@d38tang
May 18 2017 02:34
@padunk this is what documentation says: "Function is a predicate, to test each element of the array. Return true to keep the element, false otherwise, taking three arguments:"
Netrunner21
@Netrunner21
May 18 2017 02:35
@amelink Yours looks very similar to mine, and mine passes. Not sure what's causing yours to fail.
Eric Hasegawa
@EricHasegawa
May 18 2017 02:35
@asaganda Of course, anything else with that I can help with?
Andrew Saganda
@asaganda
May 18 2017 02:35
let you know, thanks
Thomas Magnus
@tmag298
May 18 2017 02:35
Can somebody help me figure out how to even begin this challange?
BigData95
@BigData95
May 18 2017 02:35
Thanks guys, sorry for the 6 edits, I'm super new on this.
Eric Hasegawa
@EricHasegawa
May 18 2017 02:35
@tmag298 What challenge?
Thomas Magnus
@tmag298
May 18 2017 02:35
It's actually not even a challange I sorta misspoke lol
I'm on the Word Blanks chapter where you have to create a Madlib generator but I don't even know how to start
Gaurav Anil
@Gaurav-77
May 18 2017 02:36
I' stuck in a challenge. Can someone help ?
Eric Hasegawa
@EricHasegawa
May 18 2017 02:36
@tmag298 Oh yeah, I'll see what I did one second
Netrunner21
@Netrunner21
May 18 2017 02:36
@amelink your last return should be outside the loop like @Marmiz mentioned.
@Gaurav-77 which one?
Eric Hasegawa
@EricHasegawa
May 18 2017 02:36
@tmag298 What's the challenge called?
Thomas Magnus
@tmag298
May 18 2017 02:36
@EricHasegawa You the man!
Word Blanks
Gaurav Anil
@Gaurav-77
May 18 2017 02:37
The card counting one in JavaScript
Thomas Magnus
@tmag298
May 18 2017 02:37
it's just a chapter in the map not really a challenge like build your own website thing
buddermancer
@buddermancer
May 18 2017 02:37
Hello I need assistance with the challenge "Stand in Line"
Netrunner21
@Netrunner21
May 18 2017 02:37
@Gaurav-77 Ok. have you started or need help getting started?
Gaurav Anil
@Gaurav-77
May 18 2017 02:37
Yeah I'm stuck there, I don't understand the question.
d38tang
@d38tang
May 18 2017 02:37
Can you use console.log for these assignments?
Gaurav Anil
@Gaurav-77
May 18 2017 02:38
It says:-

Count Change Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K', 'A'

You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then 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.

Example Output
"-3 Hold"
"5 Bet"

Hint
Do NOT reset count to 0 when value is 7, 8, or 9.

buddermancer
@buddermancer
May 18 2017 02:38
That's not the one I'm on
abraham anak agung
@padunk
May 18 2017 02:38
@d38tang hmmm... is your challenge is seek and destroy?
Netrunner21
@Netrunner21
May 18 2017 02:38
@Gaurav-77 basically you're going to output strings that tell you whether you should hold or bet.
amelink
@amelink
May 18 2017 02:39
still not working
Gaurav Anil
@Gaurav-77
May 18 2017 02:39
So far I did this:-
Eric Hasegawa
@EricHasegawa
May 18 2017 02:39
@tmag298 Yeah I know what you mean, basically the challenge is asking you to edit the "result" variable so that it produces a mad libs style sentence, and they want you to do this using a mix of strings (like your own words you put in) and the variables they give you (like myNoun, myAdjective etc.)
Gaurav Anil
@Gaurav-77
May 18 2017 02:39

var count = 0;

function cc(card) {
// Only change code below this line
if(card==2 || card==3 || card==4 || card==5 || card==6) {
count++;
console.log( count + "Bet");
} else if(card==7 || card==8 || card==9) {
count = 0;
console.log(count + "Bet");
} else {
console.log(count + "Bet" + " " + "Hold");
}

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

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

Netrunner21
@Netrunner21
May 18 2017 02:39
@Gaurav-77 use backticks to paste your code
d38tang
@d38tang
May 18 2017 02:39
@padunk yes
Netrunner21
@Netrunner21
May 18 2017 02:39
they're below the esc button
Gaurav Anil
@Gaurav-77
May 18 2017 02:40
@Netrunner21 backticks ?
okay.
abraham anak agung
@padunk
May 18 2017 02:40

@d38tang this is the instruction in seek and destroy:
You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.

Remember to use Read-Search-Ask if you get stuck. Write your own code.

Here are some helpful links:

Arguments object
Array.prototype.filter()

are we on the same page?

Netrunner21
@Netrunner21
May 18 2017 02:40
1) Three backticks (```) They are below ESC
2) Shift + Enter
3) Paste code in hole
4) CMD+ENTER
Gaurav Anil
@Gaurav-77
May 18 2017 02:41

var count = 0;

function cc(card) {
  // Only change code below this line
  if(card==2 || card==3 || card==4 || card==5 || card==6) {
    count++;
    console.log( count + "Bet");
  } else if(card==7 || card==8 || card==9) {
    count = 0;
   console.log(count + "Bet");
  } else {
   console.log(count + "Bet" + " " + "Hold");
  }

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Netrunner21
@Netrunner21
May 18 2017 02:42
@amelink can you paste your code special so I can see it more clearly?
Claudio Restifo
@Marmiz
May 18 2017 02:42

@Gaurav-77 the instruction states:

The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold"

So it's not enough to return count

d38tang
@d38tang
May 18 2017 02:43
@padunk Yes and this is my code:
function destroyer(arr) {
  var newArray = arr.filter(function(elements){
    var match = false;
    for (var i = 1; i < arguments.length; i++){
      if (elements === arguments[i]){
        match = true;
        break;
      }
    }
    return !match;
  });
  return arguments.length;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
amelink
@amelink
May 18 2017 02:43
thanks @Netrunner21
CamperBot
@camperbot
May 18 2017 02:43
amelink sends brownie points to @netrunner21 :sparkles: :thumbsup: :sparkles:
:cookie: 302 | @netrunner21 |http://www.freecodecamp.com/netrunner21
Netrunner21
@Netrunner21
May 18 2017 02:43
@Gaurav-77 I used a switch case on mine for the counting, and you'll need += to add up the counts.
d38tang
@d38tang
May 18 2017 02:43
@padunk return arguments.length should be return newArray
Netrunner21
@Netrunner21
May 18 2017 02:44
@amelink you're welcome
abraham anak agung
@padunk
May 18 2017 02:44
@d38tang no. return arguments.length will return the length of your arguments. and your arguments consist of array [], 2, 3. so your arguments have length of 3
Gaurav Anil
@Gaurav-77
May 18 2017 02:45
okay, I'll try.
Netrunner21
@Netrunner21
May 18 2017 02:45
@Gaurav-77 I used cases 2-6 with a count += 1; 10 through A with a count -= 1;
Gaurav Anil
@Gaurav-77
May 18 2017 02:45
Thank You. @Netrunner21
CamperBot
@camperbot
May 18 2017 02:45
gaurav-77 sends brownie points to @netrunner21 :sparkles: :thumbsup: :sparkles:
:cookie: 303 | @netrunner21 |http://www.freecodecamp.com/netrunner21
d38tang
@d38tang
May 18 2017 02:45
@padunk Yes I know, I used it to debug. The code has return newArray
Netrunner21
@Netrunner21
May 18 2017 02:46
@Gaurav-77 No problem. Also remember the function is being called five separate times. That's why you have to use += and -=
buddermancer
@buddermancer
May 18 2017 02:47
Hello i need help with something
Can anyone assist me?
abraham anak agung
@padunk
May 18 2017 02:47
@d38tang ok. your filter returning false or true, not removing anything. you need to find if 2 and 3 is in the array and remove it.
Netrunner21
@Netrunner21
May 18 2017 02:47
@buddermancer yes
buddermancer
@buddermancer
May 18 2017 02:47
challenge "Stand in Line"
Netrunner21
@Netrunner21
May 18 2017 02:47
alright let me look it up @buddermancer
Eric Hasegawa
@EricHasegawa
May 18 2017 02:48
@tmag298 You still there?
Netrunner21
@Netrunner21
May 18 2017 02:48
@buddermancer this one gives everyone fits
buddermancer
@buddermancer
May 18 2017 02:48
Can we pm?
d38tang
@d38tang
May 18 2017 02:48
@padunk returning false would not add the element to the new array
Netrunner21
@Netrunner21
May 18 2017 02:48
sure
send me a pm
buddermancer
@buddermancer
May 18 2017 02:49
I just did
Thomas Magnus
@tmag298
May 18 2017 02:49
@EricHasegawa Thank you so much!
CamperBot
@camperbot
May 18 2017 02:49
tmag298 sends brownie points to @erichasegawa :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @erichasegawa |http://www.freecodecamp.com/erichasegawa
Thomas Magnus
@tmag298
May 18 2017 02:49
@EricHasegawa do you know what they mean when they say " wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib)." ?
Like should I create another wordBlanks?
abraham anak agung
@padunk
May 18 2017 02:50
@d38tang yes
d38tang
@d38tang
May 18 2017 02:51
@padunk Somehow there is a differnece between 2 and arguments[1] for this assignment. When I use elements === 2 it removes 2. When I use arguments[1] it does not remove 2.
Eric Hasegawa
@EricHasegawa
May 18 2017 02:51
@tmag298 It just means every word should have a space between them I think, and that no 2 variable words should be together (they should all at least be separated by spaces)
abraham anak agung
@padunk
May 18 2017 02:53
@d38tang elements in filter is different with arguments. your elements came from your array [1,2,3,1,2,3] but your arguments consist of [1,2,3,1,2,3],2,3
enviro3
@enviro3
May 18 2017 02:53
Hi Everyone, I really need help with the Switch Statements JS challenge. here is what I currently have. I'm not sure I am naming the cases correctly? https://www.evernote.com/l/Ac_Jbm-cafBMNKv1rGB7neXYJ0pYdS5eMeA
oh i should note this is the challenge called: "Selecting from many options with Switch Statements"
d38tang
@d38tang
May 18 2017 02:54
@padunk No it was fine. I just had to convert arguments from being an object to an array and it worked.
Claudio Restifo
@Marmiz
May 18 2017 02:55
@enviro3 well' you're testing as a case='aplpha' but your function is passing a val=1
abraham anak agung
@padunk
May 18 2017 02:55
@d38tang :+1:
Daniel Zeff
@Diesirae9
May 18 2017 02:55
Hey guys can can you guys clarify something for me?
Eric Hasegawa
@EricHasegawa
May 18 2017 02:56
@enviro3 Yeah the function will pass numbers as the values, for example case 1 should return "alpha" etc.
enviro3
@enviro3
May 18 2017 02:56
oooohh, thank you @EricHasegawa and @Marmiz !
Claudio Restifo
@Marmiz
May 18 2017 02:56
@Diesirae9 if we may :)
Daniel Zeff
@Diesirae9
May 18 2017 02:57
What is the difference between a for loop and a while loop.
Claudio Restifo
@Marmiz
May 18 2017 02:58
@Diesirae9 the while will execute as long as the condition is evaluated as true
for will execute as long as the three expression are matched
Eric Hasegawa
@EricHasegawa
May 18 2017 02:58
@enviro3 Yeah no problem! And for next time it's common for people to paste their formatted code directly into the chat instead of linking it by the way
enviro3
@enviro3
May 18 2017 03:00
@EricHasegawa good to know :) Cheers!
Claudio Restifo
@Marmiz
May 18 2017 03:01
@Diesirae9 in practice you may use one or the other but in general the for is used for when you know how many times you need to loop.
The while is used for when you don't know it yet (example you're waiting for a user input)
Daniel Zeff
@Diesirae9
May 18 2017 03:02
So, if I were needing to go through a string to upperCase spot [0] a while statement would be more useful? :)
Claudio Restifo
@Marmiz
May 18 2017 03:04
@Diesirae9 it probably won't matter so chose the one you prefer/ feel more confortable with
Daniel Zeff
@Diesirae9
May 18 2017 03:06
I am more comfortable with for statements so far. May I show what I have so far?

function titleCase(str) {
 var words = str.toLowerCase().split(" ");
 var upperCase;
  for (i=0;i < words.length; i++) {
    upperCase = words[i].toUpperCase().charAt(i) + words.slice();
  }
return upperCase;

}
titleCase("I'M A LITTLE TEA POT Cat Dog frothy latte is yum");
ooo sorry charAt should be set to 0
eyesore-
@eyesore-
May 18 2017 03:12
@Diesirae9 Is the challenge to capitalize every word? Right now words.slice() isn't really doing what you think it is.
Daniel Zeff
@Diesirae9
May 18 2017 03:12
this is correct @eyesore-
eyesore-
@eyesore-
May 18 2017 03:14
@Diesirae9 words.slice with no arguments will just make a copy of the entire words array.
@Diesirae9 another thing is that you would want to specify what you are capitalizing before calling toUppercase()
Netrunner21
@Netrunner21
May 18 2017 03:15
I remember doing this challenge and having a ton of loops and splits to isolate the first letter. I'm sure there's a better way.
Daniel Zeff
@Diesirae9
May 18 2017 03:16
So far I know that:
eyesore-
@eyesore-
May 18 2017 03:16
I think the most straight forward way to do it is split and then map.
Daniel Zeff
@Diesirae9
May 18 2017 03:16

oops
Andrew Saganda
@asaganda
May 18 2017 03:17
@EricHasegawa I separated out the cases in the order in which you described. Do i create the string which contains the current count and player's decision with if/else statement(s)?
Daniel Zeff
@Diesirae9
May 18 2017 03:17
words.toUpperCase().charAt(0) + words.slice();
works to uppercase the first letter of a string.
how to I get it to go through my array
abraham anak agung
@padunk
May 18 2017 03:18
@Netrunner21 use regex if you interested :) that is faster. but finding the regex is quite hard
Netrunner21
@Netrunner21
May 18 2017 03:20
@Diesirae9 if you're going to do that I think you'd need to swap placement of toUpperCase and charAr(0)
@padunk at some point I'll go back and optimize some code and consider regex
eyesore-
@eyesore-
May 18 2017 03:20
@Diesirae9 That expression that you have there does not work how you think. Every time you loop you are adding 1 letter with the entire words array.
Ertonts
@Ertonts
May 18 2017 03:21
stucked Nesting For Loops
Daniel Zeff
@Diesirae9
May 18 2017 03:21
I see.
Netrunner21
@Netrunner21
May 18 2017 03:21
@Ertonts let me help
Ertonts
@Ertonts
May 18 2017 03:21
Thanks
Get confused
eyesore-
@eyesore-
May 18 2017 03:21
@Diesirae9 As you loop through the words array you need to mutate that index.
Ertonts
@Ertonts
May 18 2017 03:22

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {

product = product * multiplyAll[arr];

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

this is my code

Netrunner21
@Netrunner21
May 18 2017 03:23
@Ertonts your two lines with the for are correct
it's your third line that needs work
Daniel Zeff
@Diesirae9
May 18 2017 03:23
So how do I mutate and index?
Ertonts
@Ertonts
May 18 2017 03:24
@Netrunner21 Any hint?
Netrunner21
@Netrunner21
May 18 2017 03:24
@Ertonts remember, you're multiplying all the values together, so your product needs *=
Daniel Zeff
@Diesirae9
May 18 2017 03:24
Not yet, I would need to use it at the end?
make my array a string again?
eyesore-
@eyesore-
May 18 2017 03:24
@Diesirae9 Let's start here:
var words = str.toLowerCase().split(" ");
for (i=0;i < words.length; i++) {
 words[i] = words[i].toUpperCase().charAt(0) + words.slice();
}
Netrunner21
@Netrunner21
May 18 2017 03:24
@Ertonts each time it loops through the array, it has to multiply it by the product
@Ertonts each index gets multiplied by the one that came before it
@Ertonts arr[i] referrences the which array is being used, and arr[i][j] is the array's specific value at that moment in the loop
eyesore-
@eyesore-
May 18 2017 03:26
@Diesirae9 So as we loop that will replace each index with whatever we tell it. Now we just need to fix that expression: words[i].toUpperCase().charAt(i) + words.slice()
Daniel Zeff
@Diesirae9
May 18 2017 03:28
ok
Ertonts
@Ertonts
May 18 2017 03:29
product *= multiplyAll[i][j];
something like this?
Daniel Zeff
@Diesirae9
May 18 2017 03:29
currently its looping through my string, removes the first letter of my last world of the string, and slices it to the front of my string.
not quite what I want lol
eyesore-
@eyesore-
May 18 2017 03:30
@Diesirae9 Yeah, the code you posted is not doing that haha
@Diesirae9 You are looping through the array of words which is good.
Netrunner21
@Netrunner21
May 18 2017 03:31
@Ertonts yes, but you'll need to use the argument given to you by the function. Should be arr instead of MultiplyAll
Daniel Zeff
@Diesirae9
May 18 2017 03:31
ooo here I will add the one I am talking about.

function titleCase(str) {
 var words = str.toLowerCase().split(" ");
 var upperCase;
  for (i=0;i < words.length; i++) {
    upperCase = words[i].toUpperCase().charAt(0) + words.slice();
  }
return upperCase;

}
titleCase("I'M A LITTLE TEA POT Cat Dog frothy latte is yum");
eyesore-
@eyesore-
May 18 2017 03:32
@Diesirae9 I'm going to comment what your code is doing. Give me a bit.
Daniel Zeff
@Diesirae9
May 18 2017 03:33
ok :)
Ertonts
@Ertonts
May 18 2017 03:34
passed it! Thanks @Netrunner21 !
CamperBot
@camperbot
May 18 2017 03:34
ertonts sends brownie points to @netrunner21 :sparkles: :thumbsup: :sparkles:
:cookie: 305 | @netrunner21 |http://www.freecodecamp.com/netrunner21
Netrunner21
@Netrunner21
May 18 2017 03:35
@Ertonts you're welcome
eyesore-
@eyesore-
May 18 2017 03:39
@Diesirae9

function titleCase(str) {

  // str.toLowerCase() = "i'm a little tea pot cat dog frothy latte is yum"
  // str.toLowerCase().split(" ") = ["i'm", "a", "little", "tea", "pot", "cat", "dog", "frothy", "latte", "is", "yum"]

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

    // 1st loop: uppercase = "Ii'm,a,little,tea,pot,cat,dog,frothy,latte,is,yum"
    // 2nd loop: uppercase = "Ai'm,a,little,tea,pot,cat,dog,frothy,latte,is,yum"
    // last loop: uppercase = "Yi'm,a,little,tea,pot,cat,dog,frothy,latte,is,yum"

      upperCase = words[i].toUpperCase().charAt(0) + words.slice();
  }
    return upperCase;
}

titleCase("I'M A LITTLE TEA POT Cat Dog frothy latte is yum");
Daniel Zeff
@Diesirae9
May 18 2017 03:40
I see
So no what? lol
now*
Masaki
@masaki1223
May 18 2017 03:43
Hello, how can I make ['1','2','3'] into [1,2,3]?
eyesore-
@eyesore-
May 18 2017 03:44
@Diesirae9 There is a couple ways to solve this and I think the way you were thinking was having uppercase be a string with the answer, correct?
@masaki1223 you can loop through the array and do+ on each index
Netrunner21
@Netrunner21
May 18 2017 03:45
@masaki1223 .join() works
eyesore-
@eyesore-
May 18 2017 03:45
@Netrunner21 join would do '1,2,3'
Leonardo de Melo
@Leonardo-demeloweb
May 18 2017 03:45
whats is wrong here?
var string = "Split me into an array";
var array = [];



array = string.split();
Daniel Zeff
@Diesirae9
May 18 2017 03:45
I think technically I was thinking upperCase would still be an Array with the right answer. @eyesore-
eyesore-
@eyesore-
May 18 2017 03:46
@Leonardo-demeloweb split needs an argument.
Ariel
@twomiya
May 18 2017 03:46
var array = [1, 2, 3,4,5,6,7];
var newArray= [];
//只能在这一行下面写代码

newArray = array.reverse();
why not run?
Daniel Zeff
@Diesirae9
May 18 2017 03:47
I would need to then upperCase.join() and then return upperCase
eyesore-
@eyesore-
May 18 2017 03:47
@Diesirae9 Yeah, it wouldn't work that way. You have some options though. You could have uppercase start as an array and then push the new uppercase strings to it or you could just mutate the words array as you iterate through it.
Masaki
@masaki1223
May 18 2017 03:48
@Netrunner21 join() makes it string
abraham anak agung
@padunk
May 18 2017 03:48
@twomiya it should work, nothing wrong with the code.
Ariel
@twomiya
May 18 2017 03:49
ok
Daniel Zeff
@Diesirae9
May 18 2017 03:49
if I use uppercase after lowercasing everything, would everything be upper case?
Leonardo de Melo
@Leonardo-demeloweb
May 18 2017 03:49
@eyesore if I do like this, split o substrings string.split(" "); Thought If omitted, the entire string will be returned string.split(); do I interpreted wrong?
eyesore-
@eyesore-
May 18 2017 03:49
@masaki1223 +'1' gives you 1 and Number('1') also gives you 1
Leonardo de Melo
@Leonardo-demeloweb
May 18 2017 03:50
@eyesore if I do like this, split on substrings string.split(" "); Thought If omitted, the entire string will be returned string.split(); do I interpreted wrong?
Daniel Zeff
@Diesirae9
May 18 2017 03:50
@Leonardo-demeloweb string.split() makes every letter a string
eyesore-
@eyesore-
May 18 2017 03:50
@Diesirae9 Just that string that you are applying toUpperCase to.
@Leonardo-demeloweb @Diesirae9 if you want to split every letter you gotta do .split('')
Daniel Zeff
@Diesirae9
May 18 2017 03:51
@eyesore- but the entire string is uppercase?
ahhh
Quincy Larson
@QuincyLarson
May 18 2017 03:52
@Netrunner21 Sure thing! I'm happy you're making use of it!
eyesore-
@eyesore-
May 18 2017 03:52
@Diesirae9 So as you are iterating through your words array you can do something like words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1)
Leonardo de Melo
@Leonardo-demeloweb
May 18 2017 03:52
@eyesore- every letter separeted by ','
is I use str.split('');
eyesore-
@eyesore-
May 18 2017 03:53
@Leonardo-demeloweb i.e. if I did 'hello'.split('') it would turn into ['h', 'e', 'l', 'l', 'o']
jitendersinghwp
@jitendersinghwp
May 18 2017 03:53
hi everyone
eyesore-
@eyesore-
May 18 2017 03:54
Hi
Ertonts
@Ertonts
May 18 2017 03:54
Hi Guys! Does any of you get a programming job without a diploma? I dropped out from university due to financial reason,and i am not a geek or any kind of genius on programming, I just studied front end stuff on line, and worked on oracle database by myself,and got a Java Ocp cert,currently I am working on freecodecamp,and hopefully i can finish some of the project eventually. Please If any of you has the same case like me,give me some advice! Will appreciat
jitendersinghwp
@jitendersinghwp
May 18 2017 03:54
@eyesore- i'm iterate with javascript section and my code is this var myArray = [ ];
for (var i = 1; i <= 5; i++) {
myArray.push(i);
}
Daniel Zeff
@Diesirae9
May 18 2017 03:54
then I don't need a return?
eyesore-
@eyesore-
May 18 2017 03:55
@Diesirae9 What you got so far?
jitendersinghwp
@jitendersinghwp
May 18 2017 03:55
i'm note able to clear the challenge.
Daniel Zeff
@Diesirae9
May 18 2017 03:55
function titleCase(str) {
 var words = str.toLowerCase().split(" ");
 var upperCase;
  for (i=0;i < words.length; i++) {
    words[i] = words[i].toUpperCase() + words.slice(1);
  }
return upperCase;

}
titleCase("I'M A LITTLE TEA POT Cat Dog frothy latte is yum");
Gabe Rotberg
@grotberg
May 18 2017 03:56
@Diesirae9 you never actually assign anything to upperCase
Daniel Zeff
@Diesirae9
May 18 2017 03:56
@grotberg Think I am getting there :)
eyesore-
@eyesore-
May 18 2017 03:56
@Diesirae9 So you are making all the changes to words. Console log words at the end.
Leonardo de Melo
@Leonardo-demeloweb
May 18 2017 03:56
@eyesore- yes i understood I tried on consolestr.split(''); and saw the difference of str.split(""); and like this str.split(); but what the argument i need to use for the challenge? perhaps I misunderstood the instructions of

var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split();
Zayar Min Aye
@zayarminaye
May 18 2017 03:56
hi guys, I'm stuck in "Profile Lookup" challenge ... my loop doesn't iterate to contacts array. am i missing something ..
eyesore-
@eyesore-
May 18 2017 03:56
@Diesirae9 You don't even need uppercase anymore.
Zayar Min Aye
@zayarminaye
May 18 2017 03:56
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i<contacts.length; i++){
if(contacts[i].hasOwnProperty(firstName)){
return contacts[i].firstName;
}
else {
return "No Such Contact";
}
}
// Only change code above this line
}
your help is so much appreciated
Daniel Zeff
@Diesirae9
May 18 2017 03:58
So is slice(1) actually doing my uppercase
eyesore-
@eyesore-
May 18 2017 03:58
@Leonardo-demeloweb Oh, I think it wants you to split by word. So the argument you pass to split is what you are looking to separate by.
@Diesirae9 slice(1) is taking a copy of the current word starting at index 1 since index 0 is the capital letter.
@jitendersinghwp sorry, what is the error you are getting?
Daniel Zeff
@Diesirae9
May 18 2017 03:59
I see
Ian Arsenault
@ianarsenault
May 18 2017 04:00
Does anyone know how to get the input field value on change, when the change is being made to the input via javascript. I'm filling in a text area via javascript and it can change repeatedly. I want to be able to detect when it changes so when a form is submitted it catches it. keyup doesn't seem to work
Daniel Zeff
@Diesirae9
May 18 2017 04:00
lol right now its a mess :S
eyesore-
@eyesore-
May 18 2017 04:00
@Diesirae9 show me
Leonardo de Melo
@Leonardo-demeloweb
May 18 2017 04:00
@eyesore- I think the instruction is should split the string by its spaces. How should I do, using regular expressions?
jitendersinghwp
@jitendersinghwp
May 18 2017 04:00
@eyesore- i'm not able complete the challenge. He shows "You should be using a for loop for this." this error.
Daniel Zeff
@Diesirae9
May 18 2017 04:01
function titleCase(str) {
 var words = str.toLowerCase().split(" ");
  for (i=0;i < words.length; i++) {
    words[i] = words[i].toUpperCase() + words.slice(1);
  }
return words;

}
titleCase("i'm a little tea pot");
sorry for the spam lol
Gabe Rotberg
@grotberg
May 18 2017 04:01
@zayarminaye for that first loop, you don't need to check if the contact has the firstName property (all of them do), you need to check if the contact's firstName property is equal to the firstName passed to the function
eyesore-
@eyesore-
May 18 2017 04:01
@Leonardo-demeloweb So if you want to split by space you could do .split(' ')
@Leonardo-demeloweb remember what you are splitting by is what the argument would be.
@Diesirae9 not a mess at all. You are almost there. What is the output you are getting?
Zayar Min Aye
@zayarminaye
May 18 2017 04:03
@grotberg ok .. i will omit the for loop ...
Gabe Rotberg
@grotberg
May 18 2017 04:04
@zayarminaye well, don't omit the for loop. you still need it.
Anurag Lahon
@anuraglahon16
May 18 2017 04:04
how to solve the pig latin if([a,e,i,o,u])==str[0]{str+ 'way';} else
Gabe Rotberg
@grotberg
May 18 2017 04:04
@zayarminaye but instead of checking if contact[i] has the firstName property, check that contacts[i].firstName equals the firstName passed to the function
Leonardo de Melo
@Leonardo-demeloweb
May 18 2017 04:05
@eyesore- Now works, just a space between the ''make the difference.

var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split(' ');

var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split('');
Zayar Min Aye
@zayarminaye
May 18 2017 04:06
@grotberg
like that
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++){
if(contacts[i].firstName == firstName){
return contacts[i][firstName];
}
else {
return "No Such Contact";
}
}
// Only change code above this line
}
eyesore-
@eyesore-
May 18 2017 04:06
@Leonardo-demeloweb Yeah haha you want to put what you are splitting by as the argument. Say you want want to split every 'a' you would do split('a')
Daniel Zeff
@Diesirae9
May 18 2017 04:06
it wont let me copy paste but it looks like this

["I'Ma, little,tea,pot","Aa,little,tea,pot","LITTLEAa,little,tea,pot,little,tea,pot"]
eyesore-
@eyesore-
May 18 2017 04:07
Woah.
Daniel Zeff
@Diesirae9
May 18 2017 04:07
and it continues on like that for a good while.
Gabe Rotberg
@grotberg
May 18 2017 04:07
@zayarminaye getting there! you still need to deal with the prop part, though. THat's the part where you'll need to use hasOwnProperty() ;)
eyesore-
@eyesore-
May 18 2017 04:07
@Diesirae9 I see the issue. words.slice(1) what is that doing?
@Diesirae9 remember that words is the array of all the words. How do you just target the current word you are on?
Pedro Labrador
@PedroLabrador
May 18 2017 04:08

Hello! somebody can help me?

function getIndexToIns(arr, num) {
  arr = arr.sort();
  var index = 0;
  while (arr[index] < num)
    index++;
  return index;
}

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

it works for all test, but that case :(

Zayar Min Aye
@zayarminaye
May 18 2017 04:08
@grotberg where should i put that "prop" checking part ?..
Gabe Rotberg
@grotberg
May 18 2017 04:08
@Diesirae9 there are a few issues, but they're all in this line: words[i] = words[i].toUpperCase() + words.slice(1);
words[i].toUpperCase() takes the entire word and makes it upper case. Then words.slice(1) does slice on the entire array and adds it to the previous statement.
Pedro Labrador
@PedroLabrador
May 18 2017 04:08
it returns 0 it should return 2
Daniel Zeff
@Diesirae9
May 18 2017 04:09
slice is taking a copy of the current word starting at index 1.
Leonardo de Melo
@Leonardo-demeloweb
May 18 2017 04:09
@eyesore- (y)
@eyesore- nice
eyesore-
@eyesore-
May 18 2017 04:10
@Diesirae9 Why you take the charAt(0) part out? /: You were good there because it targeted the first letter in the word.
Pedro Labrador
@PedroLabrador
May 18 2017 04:10
can anybody help me? thanks :)
Gabe Rotberg
@grotberg
May 18 2017 04:11
@zayarminaye well the first thing you need to do is check to see if the contact exists - thats what your loop does now. Then if it exists, you need to check to see if it has the property prop. so it has to be inside that loop. If property exists, it needs to return the property. If it doesn't exist, it needs to return "No such property". You never need to return contacts[i][firstName];
Santhosh Kumar Rajagiri
@santhu342
May 18 2017 04:12
hello any one ca help me
Return Largest Numbers in Arrays
Daniel Zeff
@Diesirae9
May 18 2017 04:12
AHHH I didnt even notice I did that! @eyesore-
Gabe Rotberg
@grotberg
May 18 2017 04:12
@Diesirae9 you're not using slice on the current word though (that would be words[i]) you're using slice on the entire array of words.
Zayar Min Aye
@zayarminaye
May 18 2017 04:13
@grotberg

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

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

}
// Only change code above this line
}

eyesore-
@eyesore-
May 18 2017 04:13
@Diesirae9 Awesome, now the same way you target the current word in the first part with words[i] you want to target when you are slicing.
Gabe Rotberg
@grotberg
May 18 2017 04:14
@zayarminaye you're still doing return firstName; if you find the contact. if you return that, you'll never get to the point where you search for the property. you need to move the second part inside the first loop.
eyesore-
@eyesore-
May 18 2017 04:15
@Diesirae9 Once you've got the array with all the right words, remember you gotta join them into a string.
Daniel Zeff
@Diesirae9
May 18 2017 04:15
ok gimme just a second :)
eyesore-
@eyesore-
May 18 2017 04:15
@PedroLabrador Yo, what section you on?
@Diesirae9 no problem man!
Zayar Min Aye
@zayarminaye
May 18 2017 04:16

@grotberg

for(var i = 0; i < contacts.length; i++){
if(contacts[i].firstName == firstName){
if(contacts[i].prop == prop){
return contacts[i].prop;
}
else {
return "No such Property";
}
}
else {
return "No such contact";
}
}

am i still too far from the solution ?
Pedro Labrador
@PedroLabrador
May 18 2017 04:17
@eyesore- where do i belong
Gabe Rotberg
@grotberg
May 18 2017 04:17
@zayarminaye you're very close! instead of if(contacts[i].prop == prop){ you need to check if the contact has the property. This is where you want to use the hasOwnProperty() function
jitendersinghwp
@jitendersinghwp
May 18 2017 04:18
@eyesore- thanks
CamperBot
@camperbot
May 18 2017 04:18
jitendersinghwp sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 80 | @eyesore- |http://www.freecodecamp.com/eyesore-
eyesore-
@eyesore-
May 18 2017 04:18
@jitendersinghwp No problem!
Zayar Min Aye
@zayarminaye
May 18 2017 04:18
for(var i = 0; i < contacts.length; i++){
if(contacts[i].firstName == firstName){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i].prop;
}
else {
return "No such Property";
}
}
else {
return "No such contact";
}
}
here it is @grotberg
Santhosh Kumar Rajagiri
@santhu342
May 18 2017 04:18
ya
Pedro Labrador
@PedroLabrador
May 18 2017 04:18
´´´
test
´´´
eyesore-
@eyesore-
May 18 2017 04:18
@PedroLabrador Is that what the lesson is called or are you asking me?
Santhosh Kumar Rajagiri
@santhu342
May 18 2017 04:18
@zayarminaye yes
eyesore-
@eyesore-
May 18 2017 04:19
haha
Mukul Agrawal
@mukul09
May 18 2017 04:19
what am i doing wrong in Make Object Properties Private challenge
var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {

  // Only change code below this line.
  var gear;
  this.getGear=function(val){
    gear=val;
    return gear;
  };
  this.setGear=function(val){
    gear=this.getGear(val);
  };

};

var myCar = new Car();

var myBike = new Bike();
Pedro Labrador
@PedroLabrador
May 18 2017 04:19
@eyesore- haha both, jk, that's the lesson name
eyesore-
@eyesore-
May 18 2017 04:19
@PedroLabrador Cool, I'll help you out. Can you post your code again?
Zayar Min Aye
@zayarminaye
May 18 2017 04:19

but my code doesn't work.. result is showed "No such contact"..

this is function with parameters

lookUpProfile("Kristian", "lastName")

Gabe Rotberg
@grotberg
May 18 2017 04:19
@PedroLabrador need to use backticks ``` (usually just left of the 1 key)
Pedro Labrador
@PedroLabrador
May 18 2017 04:19
@eyesore- sure, sec
Zayar Min Aye
@zayarminaye
May 18 2017 04:20
@grotberg
Mukul Agrawal
@mukul09
May 18 2017 04:20
@zayarminaye whats your challenge name
Daniel Zeff
@Diesirae9
May 18 2017 04:20
So closee!
Zayar Min Aye
@zayarminaye
May 18 2017 04:20
Profile Lookup challenge

This is my answer but still not correct

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

Pedro Labrador
@PedroLabrador
May 18 2017 04:20

function getIndexToIns(arr, num) {
  arr = arr.sort();
  var index = 0;
  while (arr[index] < num)
    index++;
  return index;
}

getIndexToIns([3, 3, 5, 20], 5);
it works for all tests but that
Troy
@TroyTeva
May 18 2017 04:22
Hi guys, can anyone help me out with' Counting Cards"?

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

return count + (count > 0 ? "Bet":"Hold");
// Only change code above this line

eyesore-
@eyesore-
May 18 2017 04:22
@PedroLabrador Look up .sort on MDN
Santhosh Kumar Rajagiri
@santhu342
May 18 2017 04:22
@zayarminaye its working
Daniel Zeff
@Diesirae9
May 18 2017 04:23
WEWT!!!!!!!
eyesore-
@eyesore-
May 18 2017 04:23
@PedroLabrador .sort works alphabetically. If you do it with numbers you would get something like [1, 10, 2]
Gabe Rotberg
@grotberg
May 18 2017 04:24
@zayarminaye Ah, I see. A few problems - first of all, you have to use bracket notation for contacts[i].prop
eyesore-
@eyesore-
May 18 2017 04:24
@Diesirae9 You get it?
Daniel Zeff
@Diesirae9
May 18 2017 04:24
Thank you thank you thank you thank you! @eyesore- @grotberg
CamperBot
@camperbot
May 18 2017 04:24
diesirae9 sends brownie points to @eyesore- and @grotberg :sparkles: :thumbsup: :sparkles:
:cookie: 81 | @eyesore- |http://www.freecodecamp.com/eyesore-
:cookie: 380 | @grotberg |http://www.freecodecamp.com/grotberg
Gabe Rotberg
@grotberg
May 18 2017 04:24
@zayarminaye basically, because prop is a variable, you can't use dot notation. it has to be contacts[i][prop]
Pedro Labrador
@PedroLabrador
May 18 2017 04:24
@eyesore- that array i am passing by argument is already sorted, should i use teh callback function?
Daniel Zeff
@Diesirae9
May 18 2017 04:24

function titleCase(str) {
 var words = str.toLowerCase().split(" ");
 var upperCase;
  for (i=0;i < words.length; i++) {
    words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1);
  }
  words = words.join(" ");
return words;

}
titleCase("I'M A LITTLE TEA POT Cat Dog frothy latte is yum");
eyesore-
@eyesore-
May 18 2017 04:25
@Diesirae9 No problem. I came up with a couple of different ways to write it. Want to see?
Zayar Min Aye
@zayarminaye
May 18 2017 04:25
@grotberg still not working..am i missing something ?
Daniel Zeff
@Diesirae9
May 18 2017 04:25
I would love to :)
eyesore-
@eyesore-
May 18 2017 04:25
@Diesirae9 At the end just return words.join(' ') you don't need to repeat yourself.
Zayar Min Aye
@zayarminaye
May 18 2017 04:25

@grotberg

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

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

Gabe Rotberg
@grotberg
May 18 2017 04:25
@zayarminaye next, currently you're returning "No such contact" after the first time you fail to find a contact. You need to move that after the entire loop, otherwise it bails out after the first try.
@zayarminaye basically return "No such contact"; needs to be outside the for loop
Santhosh Kumar Rajagiri
@santhu342
May 18 2017 04:26

@zayarminaye

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

for(i=0;i<contacts.length;i++){
if(contacts[i].firstName == firstName){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}
else{
return "No such property";
}
}
}
return "No such contact";

// Only change code above this line
}

see this code

eyesore-
@eyesore-
May 18 2017 04:26

@Diesirae9

function titleCase(str) {
    return str
    .split(' ')
      .map( function(word) {
        return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
    })
    .join(' ')
}

and ES6:

const titleCase = str => {
    return str
    .split(' ')
      .map(word => {
        return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
    })
    .join(' ')
}
abraham anak agung
@padunk
May 18 2017 04:26
@TroyTeva has you declare var count?
Pedro Labrador
@PedroLabrador
May 18 2017 04:26
@eyesore- well, it worked, thanks a lot
CamperBot
@camperbot
May 18 2017 04:26
pedrolabrador sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 82 | @eyesore- |http://www.freecodecamp.com/eyesore-
Daniel Zeff
@Diesirae9
May 18 2017 04:27
I see
eyesore-
@eyesore-
May 18 2017 04:27
@PedroLabrador No problem!
Zayar Min Aye
@zayarminaye
May 18 2017 04:27
@grotberg .. gotcha.. thanks bro
CamperBot
@camperbot
May 18 2017 04:27
zayarminaye sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
:cookie: 381 | @grotberg |http://www.freecodecamp.com/grotberg
Zayar Min Aye
@zayarminaye
May 18 2017 04:27
@santhu342 thank you too
CamperBot
@camperbot
May 18 2017 04:27
zayarminaye sends brownie points to @santhu342 :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @santhu342 |http://www.freecodecamp.com/santhu342
Zayar Min Aye
@zayarminaye
May 18 2017 04:27
@grotberg :)
Gabe Rotberg
@grotberg
May 18 2017 04:27
@zayarminaye no problem! :+1:
Pedro Labrador
@PedroLabrador
May 18 2017 04:28
@eyesore- did you delete the reply? i wnted to read it :v
eyesore-
@eyesore-
May 18 2017 04:28
@PedroLabrador Yeah, it was just saying another possibility I could had skipped over, but if it is currently working then I was wrong haha
Daniel Zeff
@Diesirae9
May 18 2017 04:28
so are are adding .split() as a class ?
Pedro Labrador
@PedroLabrador
May 18 2017 04:29
@eyesore- i declared the callback function and it worked, who'd say
cya bro
eyesore-
@eyesore-
May 18 2017 04:30
@Diesirae9 I'm just doing method chaining. I like functional programming with less mutation since mutating values is where you get the most bugs.
Daniel Zeff
@Diesirae9
May 18 2017 04:31
do we learn method chaining later?
eyesore-
@eyesore-
May 18 2017 04:31
@Diesirae9 method chaining is sweet because it makes your code look really organized. You just have to know what your method would return. Since split returns an array then we can map through that which then returns a new array that we then join.
@Diesirae9 I'm not sure, but if you want to dive into that I'm game. I haven't actually done all FCC.
Troy
@TroyTeva
May 18 2017 04:32
@padunk Yes var count = 0;
Daniel Zeff
@Diesirae9
May 18 2017 04:34
Id be interested in learning about it
eyesore-
@eyesore-
May 18 2017 04:35
What is your next lesson? Maybe we could answer it with some functional goodness.
Troy
@TroyTeva
May 18 2017 04:36
@padunk i got it. the bottom line! Thanks!
CamperBot
@camperbot
May 18 2017 04:36
troyteva sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 323 | @padunk |http://www.freecodecamp.com/padunk
Daniel Zeff
@Diesirae9
May 18 2017 04:37
@eyesore- Id be interested in learning about it!
abraham anak agung
@padunk
May 18 2017 04:37
@TroyTeva cool, and you don't need to count 7,8,9 cause they are 0:)
Daniel Zeff
@Diesirae9
May 18 2017 04:37
@eyesore- Looks very clean that is for sure!
eyesore-
@eyesore-
May 18 2017 04:39
@Diesirae9 Let me know whenever you want to go through it.
Rick Riggs
@wikiwiggs
May 18 2017 04:41
Hey guys - Any Javascript gurus in the house tonight???
The reason for asking, is because I'm getting a weird error? Almost like I'm assigning something and moving forward, without actually allowing those assignments to finish first.
Daniel Zeff
@Diesirae9
May 18 2017 04:44
Are you going to be on tomorrow @eyesore-
eyesore-
@eyesore-
May 18 2017 04:45
@Diesirae9 Yeah, I might be.
@Diesirae9 But if I'm not send me a problem you've got and I can reply with a step by step breakdown of it.
@wikiwiggs Javascript guru is very daunting. I'll give it a shot though.
Rick Riggs
@wikiwiggs
May 18 2017 04:46
I'm using chrome on win7 64b
eyesore-
@eyesore-
May 18 2017 04:47
What is the error that you are getting?
Rick Riggs
@wikiwiggs
May 18 2017 04:47
When I look at the dev console, there is a:
pen.js:11 Uncaught TypeError: Cannot read property '0' of undefined(…)
eyesore-
@eyesore-
May 18 2017 04:49
And this is when you are running updateInventory?
Rick Riggs
@wikiwiggs
May 18 2017 04:50
@eyesore- yup, it is marking the first if statement as the problem.
eyesore-
@eyesore-
May 18 2017 04:50
I'm not getting that error at all. You are feeding it curInv and newInv, right?
Rick Riggs
@wikiwiggs
May 18 2017 04:51
@eyesore- yeah, my last line is:
console.log(updateInventory(curInv, newInv));
eyesore-
@eyesore-
May 18 2017 04:52
I'm not getting an error at all. I'm getting the console.log.
Rick Riggs
@wikiwiggs
May 18 2017 04:53
is it possible to send a screenshot here???
eyesore-
@eyesore-
May 18 2017 04:53
Yeah, just post the image I believe.
Rick Riggs
@wikiwiggs
May 18 2017 04:54
blob
abraham anak agung
@padunk
May 18 2017 04:55
@wikiwiggs i got that error too, maybe you using shift().
Rick Riggs
@wikiwiggs
May 18 2017 04:55
blob
@padunk - but shift should kick me out of this loop
eyesore-
@eyesore-
May 18 2017 04:56
Let me try to understand what you are doing a little more. arr1r, what is that? Why are you using filter?
Rick Riggs
@wikiwiggs
May 18 2017 04:56
because filter returns a new array.
eyesore-
@eyesore-
May 18 2017 04:56
What are you trying to do?
reverse every array within the array?
Rick Riggs
@wikiwiggs
May 18 2017 04:57
yup!
eyesore-
@eyesore-
May 18 2017 04:57
Don't use filter for that. Use map.
priyanka bhalla
@priyanka-bhalla
May 18 2017 04:57

// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;

eyesore-
@eyesore-
May 18 2017 04:57
Use filter when you are going to filter haha it's going to be confusing to other people looking at your code haah
priyanka bhalla
@priyanka-bhalla
May 18 2017 04:58
i m having to understand this please help me with this
Rick Riggs
@wikiwiggs
May 18 2017 04:58
@eyesore- switched it to map no change
eyesore-
@eyesore-
May 18 2017 04:59
Yeah, I just wanted to know what the filter was for. The other part was just a tip haha I knew it wouldnt fix the issue.
Zachary Orona-Calvert
@TheTRUEHoohah
May 18 2017 04:59
hey guys im doing the pom clock and my js is not working can you see whats wrong?
abraham anak agung
@padunk
May 18 2017 04:59
@wikiwiggs yes, but while your aar1r is 0, your arr2r is not. but maybe i am wrong
Zachary Orona-Calvert
@TheTRUEHoohah
May 18 2017 04:59

var count = 30;

var counter = setInterval(timer, 1000);

function timer() {
count = count - 1;
if (count <= 0) {
clearInterval(counter);
return;
}
document.getElementId("timer").innerHTML = count + "secs";
}

$("plus").on("click", function(){

count++;

});

$("minus").on("click", function(){
count-- ;
});

$("reset").on("click", function(){
timer();
});

$("timers").on("click", function(){
timer();
});

Santhosh Kumar Rajagiri
@santhu342
May 18 2017 04:59
Repeat a string repeat a string
hello how to add to in string
Zachary Orona-Calvert
@TheTRUEHoohah
May 18 2017 04:59

this is my html <body class="text-center" />

<h1>Pomodoro Clock</h1>

<h2>By Zach Orona-Calvert</h2>

<h3>FCC Project</h3>

<div class="circle"></div>
</body>
<a class="btn btn-primary timers">Timer Start</a>
<a class="btn btn-primary reset">Reset</a>
<a class="btn btn-primary plus">+</a>
<a class="btn btn-primary minus">-</a>

<span id="timer">0</span>

priyanka bhalla
@priyanka-bhalla
May 18 2017 05:00
its repeatedly showing this error studlyCapVar is defined and has a value of 10
properCamelCase is defined and has a value of "A String"
titleCaseOver is defined and has a value of 9000
studlyCapVar should use camelCase in both declaration and assignment sections.
properCamelCase should use camelCase in both declaration and assignment sections.
titleCaseOver should use camelCase in both declaration and assignment sections.
Rick Riggs
@wikiwiggs
May 18 2017 05:01
@padunk - you are right, I switched my || to && and all is well, I wasn't kicking out
It sucks when you can't see the most obvious logical things. thanks: @padunk & @eyesore-
CamperBot
@camperbot
May 18 2017 05:02
wikiwiggs sends brownie points to @padunk and @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 83 | @eyesore- |http://www.freecodecamp.com/eyesore-
:cookie: 324 | @padunk |http://www.freecodecamp.com/padunk
abraham anak agung
@padunk
May 18 2017 05:03
@priyanka-bhalla you have to use camelCase
eyesore-
@eyesore-
May 18 2017 05:03
@wikiwiggs yeah, makes sense now haha they are not the same length.
priyanka bhalla
@priyanka-bhalla
May 18 2017 05:03
but how
will u please tell me how to use it
abraham anak agung
@padunk
May 18 2017 05:04
@priyanka-bhalla my english is not good, so camelCase is you dont use space to separate two word you use Capital letter. came case become camelCase
Santhosh Kumar Rajagiri
@santhu342
May 18 2017 05:05
@padunk hello help me
eyesore-
@eyesore-
May 18 2017 05:05
@priyanka-bhalla when you type helloWorld it's camelCase. The caps in the middle are like camel humps. In HTML and CSS you do kebab-case which would be hello-world the dash is like a kebab going through the words.
abraham anak agung
@padunk
May 18 2017 05:06
@santhu342 hello, how can i help you?
Santhosh Kumar Rajagiri
@santhu342
May 18 2017 05:06
@padunk Repeat a string repeat a string
abraham anak agung
@padunk
May 18 2017 05:07
@santhu342 show me your code here with ```
Santhosh Kumar Rajagiri
@santhu342
May 18 2017 05:07

function repeatStringNumTimes(str, num) {
// repeat after me
for(var i = 0; i < num; i++){

}
return str;
}

repeatStringNumTimes("abc", 3);

how can add a str into same str value
abraham anak agung
@padunk
May 18 2017 05:08
@santhu342 you just do str + str + str would add a string into same string
Santhosh Kumar Rajagiri
@santhu342
May 18 2017 05:09
how it possiable
Johnny
@jtan3
May 18 2017 05:09
@santhu342 there's also str.repeat() method
Santhosh Kumar Rajagiri
@santhu342
May 18 2017 05:10
ok but here using for loop
how can add a string value
Rick Riggs
@wikiwiggs
May 18 2017 05:12
@padunk @eyesore- maybe I'm not out of the weeds yet. I'm getting another weird error:
blob
eyesore-
@eyesore-
May 18 2017 05:13
What is the lesson?
Rick Riggs
@wikiwiggs
May 18 2017 05:13
@eyesore- Inventory Update
All of my dev console errors went away, but now I'm having FCC equality problems.
abraham anak agung
@padunk
May 18 2017 05:16
@santhu342 you need to make a new variable and accumulate the string in a new variable
@wikiwiggs your last result is wrong, should be 7, toothpaste
Rick Riggs
@wikiwiggs
May 18 2017 05:18
yup, again another logical failure, I guess I've been staring at this code for too long.
thanks again @padunk @eyesore-
CamperBot
@camperbot
May 18 2017 05:19
wikiwiggs sends brownie points to @padunk and @eyesore- :sparkles: :thumbsup: :sparkles:
:warning: wikiwiggs already gave eyesore- points
:warning: wikiwiggs already gave padunk points
abraham anak agung
@padunk
May 18 2017 05:19
@wikiwiggs :+1: no problem, now i'm off to lunch :smile:
rishikeshct
@rishikeshct
May 18 2017 05:27
For 143
Escape Sequences in Strings question var myStr = "FirstLine\n\SecondLine\\rfn";
its right but showing error
Ogundele Olumide
@Lumexralph
May 18 2017 05:34
@rishikeshct FirstLine newline backslash SecondLine backslash carriage-return ThirdLine
Markus Kiili
@Masd925
May 18 2017 05:36
@Lumexralph Morning.
Ogundele Olumide
@Lumexralph
May 18 2017 05:37
@Masd925 Good Morning, slept well?
Markus Kiili
@Masd925
May 18 2017 05:38
@Lumexralph Yes. No problems in that department. How about you?
Ogundele Olumide
@Lumexralph
May 18 2017 05:38
@Masd925 :smile: , good very good
Markus Kiili
@Masd925
May 18 2017 05:42
@Lumexralph Calculator done?
Ogundele Olumide
@Lumexralph
May 18 2017 05:44
@Masd925 :joy: nope.... maybe when i'm done with my Python projects, hopefully next week just working on one presently and one more then i'm done
@Masd925 portfolio :smirk: ?
mandeepudp92
@mandeepudp92
May 18 2017 05:46

@mandeepudp92
hey i have this code why its not working

<div id="demo" style="width:200px">some text</div>
var x = document.getElementById("demo");
x.style.color = "#fff";
x.style.width = "100px";
x.style.backgroundColor = "green";

Markus Kiili
@Masd925
May 18 2017 05:46
@Lumexralph I will start it today :sparkles:
Ogundele Olumide
@Lumexralph
May 18 2017 05:47
@Masd925 today .......hmmmm i'll ask you
Zafar Khodjaev
@thezaff
May 18 2017 05:50
hi guys, could give some advice how to solve caesars cipher
Markus Kiili
@Masd925
May 18 2017 05:51
@thezaff What have you done so far?
Zafar Khodjaev
@thezaff
May 18 2017 05:52
nothing. should i split the string into characters first?
Markus Kiili
@Masd925
May 18 2017 05:52
@thezaff That is a good idea.
HeebieGeeBee
@HeebieGeeBee
May 18 2017 05:52
yo @Masd925 @Lumexralph
Markus Kiili
@Masd925
May 18 2017 05:52
@thezaff String replace method is another way.
@HeebieGeeBee Morning.
HeebieGeeBee
@HeebieGeeBee
May 18 2017 05:53
do you to smart ppl want to think about something
for me
Zafar Khodjaev
@thezaff
May 18 2017 05:54
@Masd925 then I should use regex?\
Markus Kiili
@Masd925
May 18 2017 05:55
@HeebieGeeBee Don't know who you are talking about. I can always call my buddy al-Khwarizmi about your problem.
Zafar Khodjaev
@thezaff
May 18 2017 05:55
Who is al-Khwarizmi?
I live in Khwarizm :D
HeebieGeeBee
@HeebieGeeBee
May 18 2017 05:56
https://heebiegeebee.github.io/JS_Arkanoid_Clone/ with this i am using a change in x and y of the ball to make it move, but when the ball hits certain points of paddle i want the angle to change, so i can kinda do it with just changing the amount x increases and decreases on every draw
Aizaz Shahid
@aizazshahid
May 18 2017 05:56
Father of Algebra !
HeebieGeeBee
@HeebieGeeBee
May 18 2017 05:56
but like that kinda affects the speed the ball travels
im trying to think of the relationship i need to make to both the x and y value
so the speed of the ball seems to stay constant but the angle its travelling changes
Zafar Khodjaev
@thezaff
May 18 2017 05:58
@forwebtech i know that, but i thought there is another guy here with such nickname
Aizaz Shahid
@aizazshahid
May 18 2017 05:58
@thezaff i don't think so.
Ogundele Olumide
@Lumexralph
May 18 2017 05:58
@HeebieGeeBee I'm thinking why use X and Y coordinates to accelerate the ball? why just use a velocity in form of an array for [x, y] coordinates on the canvas and when it reaches the screen you just change the velocity of whatever coordinate it's facing and it bounces back?
Zafar Khodjaev
@thezaff
May 18 2017 05:58
I am from Khwarizm myself. The motherland of al-Khwarizmi =)
HeebieGeeBee
@HeebieGeeBee
May 18 2017 05:59
@Lumexralph what do you mean
Aizaz Shahid
@aizazshahid
May 18 2017 05:59
good !
Ogundele Olumide
@Lumexralph
May 18 2017 05:59
@HeebieGeeBee you want the ball to bounce back when it hits the paddle, right?
HeebieGeeBee
@HeebieGeeBee
May 18 2017 05:59
it already does
but i want the angle to change
Ogundele Olumide
@Lumexralph
May 18 2017 06:00
@HeebieGeeBee angle of the ball?
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:00
to different amounts depending on where it hits the paddle
Aizaz Shahid
@aizazshahid
May 18 2017 06:00
@thezaff its in Morocco ?
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:00
yes the angle the ball is travelling
Zafar Khodjaev
@thezaff
May 18 2017 06:00
@forwebtech nope :D it's in Uzbekistan
Ogundele Olumide
@Lumexralph
May 18 2017 06:00
@HeebieGeeBee okay, your ball bounces back in horizontal direction?
Aizaz Shahid
@aizazshahid
May 18 2017 06:00
:)
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:01
yes
Aizaz Shahid
@aizazshahid
May 18 2017 06:01
@thezaff how's the atmosphere around there ?
Zafar Khodjaev
@thezaff
May 18 2017 06:01
@forwebtech the part of Uzbekistan was owned by Khwarizm in the past
@forwebtech cool
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:01
and will change on x axis too
Zafar Khodjaev
@thezaff
May 18 2017 06:01
@forwebtech U mean safety, etc?
Markus Kiili
@Masd925
May 18 2017 06:02
@thezaff You must all be buttoning your shirts recursively there.
Ogundele Olumide
@Lumexralph
May 18 2017 06:02
@HeebieGeeBee what did you do to Y-axis ?
Zafar Khodjaev
@thezaff
May 18 2017 06:02
@Masd925 did not get that)
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:02
just reverse to a negative value
Ogundele Olumide
@Lumexralph
May 18 2017 06:03
@HeebieGeeBee how does the ball accelerates?
Markus Kiili
@Masd925
May 18 2017 06:03
@thezaff Just a joke about you living in the motherland of algorithms.
Zafar Khodjaev
@thezaff
May 18 2017 06:03
@forwebtech this is the most safe country
Gaurav Anil
@Gaurav-77
May 18 2017 06:03
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable. -- this easy hell is what.
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:03
@Lumexralph what do you mean?
it just goes in arkonaoid the ball just travels at a constant rate
Aizaz Shahid
@aizazshahid
May 18 2017 06:03
@thezaff great, but i asked about the season
Zafar Khodjaev
@thezaff
May 18 2017 06:04
@Masd925 ah, recursion. haha :D but i can't imagine this
devpaaji
@devpaaji
May 18 2017 06:04
@Lumexralph hello friend
Zafar Khodjaev
@thezaff
May 18 2017 06:04
@forwebtech the weather is pretty hot, but the last night was raining and today is a bit cool weather
devpaaji
@devpaaji
May 18 2017 06:04
@Masd925 morning how are you
Aizaz Shahid
@aizazshahid
May 18 2017 06:04
@Gaurav-77 you have to make a object containing certain properties with the value which are listed in cases !
devpaaji
@devpaaji
May 18 2017 06:05
@HeebieGeeBee hello how is it going
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:05
@devpaaji hey, going ok hows you?
Aizaz Shahid
@aizazshahid
May 18 2017 06:05
@thezaff how much old is your country ?
Ogundele Olumide
@Lumexralph
May 18 2017 06:05
@HeebieGeeBee the ball how does it move? what do you mean by arkanoid?
@devpaaji HeyBro
Zafar Khodjaev
@thezaff
May 18 2017 06:06
It's independent since 1991 @forwebtech
Markus Kiili
@Masd925
May 18 2017 06:06
@thezaff Just find a button and then do the one above it and one above it etc (don't try to button your nose). That will be good enough on most workplaces.
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:06
the balls x and y values change on every frame
@Lumexralph
arkanoid is the name of the game
Ogundele Olumide
@Lumexralph
May 18 2017 06:06
@HeebieGeeBee ball moves with a constant, right?
devpaaji
@devpaaji
May 18 2017 06:06
@HeebieGeeBee have you written a user stories
Zafar Khodjaev
@thezaff
May 18 2017 06:06
@forwebtech post soviet union
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:06
@devpaaji nope
devpaaji
@devpaaji
May 18 2017 06:07
that way following step by step becomes easier
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:07
@Lumexralph yes
Aizaz Shahid
@aizazshahid
May 18 2017 06:07
@thezaff but so, it takes independent before the war ?
Ogundele Olumide
@Lumexralph
May 18 2017 06:07
@HeebieGeeBee when the ball hits the paddle, the constant changes the direction, say from positive to negative right?
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:08
@Lumexralph yes for the y
Markus Kiili
@Masd925
May 18 2017 06:08
@HeebieGeeBee If the speed is a constant, you could work just with a direction vector of length 1 (or the angle).
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:08
@Masd925 what does that mean
Ogundele Olumide
@Lumexralph
May 18 2017 06:09
@HeebieGeeBee you need to have constant velocities separate for the 2 coordinates, that's what I think
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:09
i have an x speed and y speed
Zafar Khodjaev
@thezaff
May 18 2017 06:09
@forwebtech There were 2 Khanates and 1 Emirate before Russia came in
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:09
at the moment if i want to change the angle when the ball hits the paddle i can change the x speed
which does change the angle the ball appears to travel
but the speed doesnt appear the same
Zafar Khodjaev
@thezaff
May 18 2017 06:10
@thezaff Khwarizm was a part of Khiva Khanate which is now a part of Khorezm region of Uzbekistan
Markus Kiili
@Masd925
May 18 2017 06:10
@HeebieGeeBee You can split the velocity into speed coefficient and an unit vector (that tells the direction). Those collisions only affect the unit vector here. Could be simpler.
Aizaz Shahid
@aizazshahid
May 18 2017 06:10
do you know about kazakh ssr ?
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:11
@Masd925 that sounds great, but i have no idea what you mean by that
Zafar Khodjaev
@thezaff
May 18 2017 06:11
@forwebtech Khwarizm was a large country before Mongolians
in 1097 — 1231 (wiki)
@forwebtech sure, our neighbours
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:11
@Masd925 can you give an example?
Aizaz Shahid
@aizazshahid
May 18 2017 06:12
so you are basically khan's ?
Zafar Khodjaev
@thezaff
May 18 2017 06:12
@forwebtech didn't get that
Aizaz Shahid
@aizazshahid
May 18 2017 06:12
@thezaff i am talking about khanates !
do you belonged to them ?
means the folks of your country.
Zafar Khodjaev
@thezaff
May 18 2017 06:14
We are secular sovereign Republic of Uzbekistan now
Ogundele Olumide
@Lumexralph
May 18 2017 06:14
@HeebieGeeBee @Masd925 that's what i'm thinking too, probably constants that changes the direction for both coordinates on collision
Zafar Khodjaev
@thezaff
May 18 2017 06:15
Uzbekistan includes ex Bukhara emirate, Kokand and Khiva khanates
Aizaz Shahid
@aizazshahid
May 18 2017 06:15
got it, it think i have to search it further myself :)
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:16
@Lumexralph i dont know how to describe it mathematicaly but yes there needs to be a relationship thats kept between the x and y value
so the distance travelled remains the same over time
Adel
@AdelMahjoub
May 18 2017 06:16
var vector = {
    _x: 1,
    _y: 0,

    create: function(x, y) {
        var obj = Object.create(this);
        obj.setX(x);
        obj.setY(y);
        return obj;
    },

    setX: function(value) {
        this._x = value;
    },

    getX: function() {
        return this._x;
    },

    setY: function(value) {
        this._y = value;
    },

    getY: function() {
        return this._y;
    },

    setAngle: function(angle) {
        var length = this.getLength();
        this._x = length * Math.cos(angle);
        this._y = length * Math.sin(angle);
    },

    getAngle: function() {
        return Math.atan2(this._y, this._x);
    },

    setLength: function(length) {
        var angle = this.getAngle();
        this._x = length * Math.cos(angle);
        this._y = length * Math.sin(angle);
    },

    getLength: function() {
        return Math.sqrt(this._x * this._x + this._y * this._y);
    },

    add: function(v2) {
        return vector.create(this._x + v2.getX(), this._y + v2.getY());
    },

    substract: function(v2) {
        return vector.create(this._x - v2.getX(), this._y - v2.getY());
    },

    multiply: function(val) {
        return vector.create(this._x * val, this._y * val);
    },

    divide: function(val) {
        return vector.create(this._x / val, this._y / val);
    },

    addTo: function(v2) {
        this._x += v2.getX();
        this._y += v2.getY();
    },

    substractFrom: function(v2){
        this._x -= v2.getX();
        this._y -= v2.getY();
    },

    multiplyBy: function(val) {
        this._x *= val;
        this._y *= val;
    },

    divideBy: function(v2) {
        this._x /= val;
        this._y /= val;
    }
}
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:16
but the angle it appears to travel is different
Zafar Khodjaev
@thezaff
May 18 2017 06:16
@forwebtech Sure, the history of my hometown is very interesting. I have to learn more about it too
Adel
@AdelMahjoub
May 18 2017 06:16
@HeebieGeeBee this is very old but you can try to use it for vectors
Markus Kiili
@Masd925
May 18 2017 06:17
@HeebieGeeBee Basically you can store that velocity vector with a speed and angle. Those x and y would then be speed * cos(angle) and speed * sin(angle). Those collisions would only affect the angle.
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:17
@AdelMahjoub that looks very complicated
so i can just use like 45 as the angle?
Adel
@AdelMahjoub
May 18 2017 06:18
@HeebieGeeBee each time you create a vector you get the helper function to keep track of angle etc
Aizaz Shahid
@aizazshahid
May 18 2017 06:18
@thezaff every part of this world is unique, we need to take care of it !
Markus Kiili
@Masd925
May 18 2017 06:19
@HeebieGeeBee Most languages use radians, so full angle is 2*PI
Adel
@AdelMahjoub
May 18 2017 06:19
@HeebieGeeBee you can add vectors that way you have a velocity, you can change the angle, cool
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:20
@Masd925 i dont quite understand what i would set as my x coordinate for the ball
Markus Kiili
@Masd925
May 18 2017 06:21
@HeebieGeeBee There are simple transformations between x,y and r,alpha coordinate systems https://en.wikipedia.org/wiki/Polar_coordinate_system
Ogundele Olumide
@Lumexralph
May 18 2017 06:21
@HeebieGeeBee the formula @Masd925 gave will convert from angle to vector, both representing x and y, you can use that to update the position of the ball
Markus Kiili
@Masd925
May 18 2017 06:24
@HeebieGeeBee The idea could be to store the vectors internally on polar coordinates, and then make sure those transformations on collisions would only affect the angle.
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:24
ok
@Masd925 @Lumexralph @AdelMahjoub thanks
CamperBot
@camperbot
May 18 2017 06:24
heebiegeebee sends brownie points to @masd925 and @lumexralph and @adelmahjoub :sparkles: :thumbsup: :sparkles:
:star2: 1778 | @lumexralph |http://www.freecodecamp.com/lumexralph
:cookie: 452 | @adelmahjoub |http://www.freecodecamp.com/adelmahjoub
:star2: 4091 | @masd925 |http://www.freecodecamp.com/masd925
HeebieGeeBee
@HeebieGeeBee
May 18 2017 06:24
i will try and implement
Markus Kiili
@Masd925
May 18 2017 06:25
@HeebieGeeBee A bit harder to store them, but collisions are easier to implement then.
Ogundele Olumide
@Lumexralph
May 18 2017 06:25
@HeebieGeeBee all the best, i'm facing a beast here too...... building asteroids arcade game, so we're in same building but different rooms
Adel
@AdelMahjoub
May 18 2017 06:26
@HeebieGeeBee if you are using a canvas, on collision, save the context, translate it to the center of your vector, rotate the context, restore the context, that way you don't have to deal with a lot of trigonometry
Ogundele Olumide
@Lumexralph
May 18 2017 06:26
@Masd925 canvas is a world of it's own
Markus Kiili
@Masd925
May 18 2017 06:27
@Lumexralph Don't really know anything about it.
mandeepudp92
@mandeepudp92
May 18 2017 06:27

here is html
<!DOCTYPE html>

<html>
<head>
<script type="text/javascript" src="index.js"></script>
<title></title>
</head>
<body>

<p id="demo"></p>

</body>
</html>

and here is java script
document.getElementById("demo").innerHTML = 5 + 6;
can any one tell me y its not working
Santhosh Kumar Rajagiri
@santhu342
May 18 2017 06:28
Chunky Monkey
please help me this Challenge
Ogundele Olumide
@Lumexralph
May 18 2017 06:28
@Masd925 working with X and Y coordinates, where Maths and Physics knowledge is needed
buddermancer
@buddermancer
May 18 2017 06:30
Hello
Markus Kiili
@Masd925
May 18 2017 06:30
@Lumexralph I did a physics engine with JS (acceleration, forces, friction etc) and a simple game with it. I should do something more with it. Would be a nice project on a portfolio.
buddermancer
@buddermancer
May 18 2017 06:30
Anyone here mind explaining something to me?
Adel
@AdelMahjoub
May 18 2017 06:32
if you are using sprites with canvas check those collisions detection http://dpaste.com/1MZENZD
Arvind Lairenjam
@arvind00
May 18 2017 06:32
hi all
need some help
buddermancer
@buddermancer
May 18 2017 06:33
I need some help @arvind00
Arvind Lairenjam
@arvind00
May 18 2017 06:33
anyone faced the cors issue while creating wiki search app?
how did u solve it?
@buddermancer yes tell me
buddermancer
@buddermancer
May 18 2017 06:34
Ok
Adel
@AdelMahjoub
May 18 2017 06:34
@arvind00 add &origin=* at the end of the api url
buddermancer
@buddermancer
May 18 2017 06:34
In the challenge "Stand in Line" (which I've already completed,)
Arvind Lairenjam
@arvind00
May 18 2017 06:34
@AdelMahjoub ok will try out that
buddermancer
@buddermancer
May 18 2017 06:35
Could you look at that for me
dwhite1993
@dwhite1993
May 18 2017 06:35

var Car = function() {
this.wheels = 4;
this.engines = 1;
this.seats = 5;
};

// Only change code below this line.

var myCar = new Car ();
this.wheels = 4;

The property nickname of myCar should be a string.
what am i doing wrong
where should i put the string!
priyanka bhalla
@priyanka-bhalla
May 18 2017 06:35
please help me resolve this issue
m stuck
dwhite1993
@dwhite1993
May 18 2017 06:35
whats the problem priyanka
buddermancer
@buddermancer
May 18 2017 06:35
Oh yea I can help
dwhite1993
@dwhite1993
May 18 2017 06:36
help me budder