These are chat archives for FreeCodeCamp/HelpJavaScript

26th
Aug 2018
Javierguaregua
@Javierguaregua
Aug 26 2018 06:46 UTC
a rookie question
I'm not getting anything in the Javascript console

```function startGame() {

var userInput =
userInput.toLowerCase();

function getComputerChoice () {
var aleatorio = Math.floor(Math.random * 3);
switch (aleatorio){
case 0:
return "paper";
case 1:
return "scissor";
case 2:
return "rock";
default:
console.log("error in getComputerChoice");
}
}

function determineWinner(userChoice, computerChoice) {
      if (userChoice === computerChoice ){
      console.log("It's a draw!");
    } else if (userChoice === "rock" && computerChoice === "paper" ){
          console.log ("You lose!");
    } else if (userChoice === "paper" && computerChoice == "rock") {
          console.log ("You win!");
    } else if  (userChoice === "scissors" && computerChoice === "paper") {
          console.log("You win!");
    } else if (userChoice === "paper" && computerChoice === "scissors"){
          console.log("You lose!");
    } else if (userChoice === "rock" && computerChoice == "scissors"){
          console.log("You win!");
    } else if (userChoice === "scissors" && computerChoice === "rock") {
          console.log("You lose!");
    } else {
          console.log ("Not working");
    }
}

console.log()
}

```

(Don't complain about the lot of else if xd, I'll fix it tomorrow )
Niraj Nandish
@Nirajn2311
Aug 26 2018 06:55 UTC
@Javierguaregua What exactly are you trying to do
Niraj Nandish
@Nirajn2311
Aug 26 2018 08:24 UTC
function makeClass() {
  "use strict";
  /* Alter code below this line */
  class Vegetable {
    constructor(name) {
      this.name = name;
    }
  }
  /* Alter code above this line */
  return Vegetable;
}
const Vegetable = makeClass();
const carrot = new Vegetable('carrot');
console.log(carrot.name); // => should be 'carrot'
Can someone explain me what is going on in the above code
Especially the line const Vegetable = makeClass()
hensn5250
@hensn5250
Aug 26 2018 08:27 UTC
i can try
const Vegetable = makeClass(); sets Vegatable as a instance of the Vegatable class
Niraj Nandish
@Nirajn2311
Aug 26 2018 08:29 UTC
So makeClass function will define the class vegetable and assign to vegetable
hensn5250
@hensn5250
Aug 26 2018 08:32 UTC
well on second look makeClass() only return Vegetable
will test it in console.... 1 sec
hensn5250
@hensn5250
Aug 26 2018 08:37 UTC
makeClass returns the class Vegatable, which is simply a function
Niraj Nandish
@Nirajn2311
Aug 26 2018 08:38 UTC
No probs I understood it
makeClass() is a function which makes the class
And then we are associating that class with a variable
hensn5250
@hensn5250
Aug 26 2018 08:38 UTC
yes, the class is technically a function as well
Niraj Nandish
@Nirajn2311
Aug 26 2018 08:39 UTC
:+1:
hensn5250
@hensn5250
Aug 26 2018 08:40 UTC
no prob... the way i view classes in JS are that they are functions that have constructors
Javier Pons
@JavierPons
Aug 26 2018 12:26 UTC
hi
anybody can explain how I can . sum or rest same object methods?
Chris Cullen
@123xylem
Aug 26 2018 14:35 UTC
I have a webpage made that works fine for FF Chrome... when I open in IE it is unrecognisable.. How do i fix this?
@123xylem ie javascript works differently than firefox and chrome you might need to use polyfills
Pagnito
@Pagnito
Aug 26 2018 17:38 UTC
hey im tryin to find the file nodevars.bat and it doesnt seem to exist
anyone know anything about that?
Javierguaregua
@Javierguaregua
Aug 26 2018 18:50 UTC
nvm, just deleted the first function and now I have output
now I need to fix that
Pagnito
@Pagnito
Aug 26 2018 22:01 UTC
if (taxiData) {
      this.setState({status: 'LOADED'});
      const points = taxiData.reduce((accu, curr) => {
        accu.push({
          position: [Number(curr.pickup_longitude), Number(curr.pickup_latitude)],
          pickup: true
        });
        accu.push({
          position: [Number(curr.dropoff_longitude), Number(curr.dropoff_latitude)],
          pickup: false
        });
        console.log(accu)
        return accu;
      }, []);
      this.setState({
        points,
        status: 'READY'
      });
    }
lookin at this code, couldnt they have also used map?