These are chat archives for FreeCodeCamp/HelpJavaScript

8th
Nov 2017
Long Nguyen
@longnt80
Nov 08 2017 00:18
function minesweeper(matrix) {
    return matrix.map((a,r) => a.map((_,c) => dirs.reduce((p,v) => p+=(matrix[r+v.r]||[])[c+v.c]|0, 0)))
}
in this code, what is [c+v.c]|0 at the end?
Diego Mayer
@Chrono79
Nov 08 2017 00:34
| is bitwise or
Long Nguyen
@longnt80
Nov 08 2017 01:07
@Chrono79 so it is (matrix[r+v.r]||[])[c+v.c] OR 0?
Ken Haduch
@khaduch
Nov 08 2017 01:11
Could it be used to convert a string value to a numeric value?
You might want to look at the operator precedence table?
And here is an interesting article about bitwise operators - just something to ponder, it might not be directly relevant to this usage / example.
Long Nguyen
@longnt80
Nov 08 2017 01:13
@Chrono79 @khaduch thanks :+1:
CamperBot
@camperbot
Nov 08 2017 01:13
longnt80 sends brownie points to @chrono79 and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 4598 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 3478 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Nov 08 2017 01:15

An interesting possible usage from this MDN link

In the section on Bitwise Logical operators:

The operands are converted to 32-bit integers and expressed by a series of bits (zeroes and ones). Numbers with more than 32 bits get their most significant bits discarded. For example, the following integer with more than 32 bits will be converted to a 32 bit integer:

So doing a bitwise or of a numeric value represented as greater than 32 bits with 0 will truncate the most significant bits, and pass the lower bits unchanged...
Ronique Ricketts
@RoniqueRicketts
Nov 08 2017 01:56
Hey guys on learnyounode how will can i read the file and then find all the new lines?
I have no clue
Moisés Man
@moigithub
Nov 08 2017 01:59
fs node module
newline is a \n
Ronique Ricketts
@RoniqueRicketts
Nov 08 2017 02:14
I am using fs but I like to check my data every step of the way
getting this error
fs.js:641
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
Dont worry i got the buffer :)
I wasn't passing the correct path. I checked the path and found my own error. I think I need a debugging stick to beat my own self when I find a simple mistake.
korzo
@korzo
Nov 08 2017 03:14
@Chrono79 lol
korzo
@korzo
Nov 08 2017 03:19
@Chrono79 yes, I use Vivaldi browser on older notebook and for testing. It's fast and not so resource hungry as Chrome.
As far as I can tell it's from original authors of Opera
SuperLyza
@lyzamatrix
Nov 08 2017 04:53
Hey guys, I have a question. What is the faster way and fun way to learn Javascript?
heroiczero
@heroiczero
Nov 08 2017 04:54
@lyzamatrix Keep practicing try codewars.com it is fun and there are different difficulties
@lyzamatrix apparently this is supposed to be fun too https://www.codingame.com/training
Lean Junio
@leanjunio
Nov 08 2017 04:56
Hey guys, is it possible to do something like this?
const cat = 'Garfield';
const dog = 'Oddie';

func(`${cat}`, sleep(cat));
func(`${dog}`, sleep(dog));

const sleep = (defaultArgument1, defaultArgument2, animal) => {
  // defaultArgument1 and defaultArgument2 will be used later
  console.log(`The ${animal} is asleep`)
}
heroiczero
@heroiczero
Nov 08 2017 04:59
@leanjunio you know you only have one parameter sleep(cat) but your function sleep has 3 parameters
Lean Junio
@leanjunio
Nov 08 2017 05:00
@heroiczero yeah, I know that
heroiczero
@heroiczero
Nov 08 2017 05:01
@leanjunio and animal is the 3rd parameter
Lean Junio
@leanjunio
Nov 08 2017 05:02
@heroiczero yeap, still aware of that as well. I just wanted to know if it’s possible to have that setup
heroiczero
@heroiczero
Nov 08 2017 05:03
@leanjunio are you using Node.js?
Lean Junio
@leanjunio
Nov 08 2017 05:03
yeap
heroiczero
@heroiczero
Nov 08 2017 05:06
@leanjunio does the console.log display what you want
Lean Junio
@leanjunio
Nov 08 2017 05:07
I’ll try that out, think I just found a workaround though, thanks @heroiczero
CamperBot
@camperbot
Nov 08 2017 05:07
leanjunio sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 2035 | @heroiczero |http://www.freecodecamp.com/heroiczero
Adam Faraj
@adamfaraj
Nov 08 2017 06:27
thoughts on this?
heroiczero
@heroiczero
Nov 08 2017 06:41
@adamfaraj nice job :+1: i like how you make at the set interval you call the new Date instead of just increment the seconds. The format is good and it does a nice log of your states :)
Iczac Icecold
@Iczac
Nov 08 2017 07:39
I am confused with what 'Wherefore art thou' ask me to do. Can someone please elaborate on that please thanks
Claudio Restifo
@Marmiz
Nov 08 2017 07:55
@Iczac You have to look inside each element of an array and see if it has the one matching the second argument of the function, if it does return them
Iczac Icecold
@Iczac
Nov 08 2017 07:58
@Marmiz '''whatIsInAName([{ "a": 1 }, { "a": 1 }, { "a": 1, "b": 2 }], { "a": 1 }) should return [{ "a": 1 }, { "a": 1 }, { "a": 1, "b": 2 }]'''
by this example.....I should return all the dictionary that has {"a":1}
CamperBot
@camperbot
Nov 08 2017 07:58
:bulb: to format code use backticks! ``` more info
Iczac Icecold
@Iczac
Nov 08 2017 07:59
@Marmiz whatIsInAName([{ "a": 1 }, { "a": 1 }, { "a": 1, "b": 2 }], { "a": 1 }) should return [{ "a": 1 }, { "a": 1 }, { "a": 1, "b": 2 }]
Claudio Restifo
@Marmiz
Nov 08 2017 08:01
@Iczac indeed, and all those objects has a:1 as key->value pairs
Iczac Icecold
@Iczac
Nov 08 2017 08:01
@Marmiz thanks...i will try
CamperBot
@camperbot
Nov 08 2017 08:01
iczac sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1096 | @marmiz |http://www.freecodecamp.com/marmiz
Claudio Restifo
@Marmiz
Nov 08 2017 08:02
gl :+1:
Tiago Correia
@tiagocorreiaalmeida
Nov 08 2017 09:01
@JLuboff good eye mate forgot that one, thanks
CamperBot
@camperbot
Nov 08 2017 09:01
tiagocorreiaalmeida sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2254 | @jluboff |http://www.freecodecamp.com/jluboff
Makopa
@makopa
Nov 08 2017 09:47
Good day anyone where is the channel for meteor framwork questions?
Garrus Napp
@GarrusNapp
Nov 08 2017 10:18
@makopa no such channel, try general help, but FCC doesn't teach meteor so not a lot of people will be familiar with it.
Christopher Brown
@ChrisBrownie55
Nov 08 2017 10:54
@lyzamatrix Personally, I'd have to say that the fastest, and most fun, way to learn JavaScript is to build things with it (whether that be algorithms, websites or apis). Also I'm not talking about those websites that have you learn by following instructions forever, I'm talking about doing your own projects that challenge your knowledge of the language and if you don't know how to do something then you can learn right there. As for algorithm challenges, the best ones would probably be http://codewars.com and http://hackerrank.com
Tejparn
@Tejparn
Nov 08 2017 12:46
hi guys
Blauelf
@Blauelf
Nov 08 2017 12:47
Hi @Tejparn
Tejparn
@Tejparn
Nov 08 2017 12:47
im in school right now, and my techer isnt here so me and the whole class could use some help
we got a game right, and we are supposed to make a score counter to it
can i post the code here?
im trying to do it with function drawScore() {
ctx.font = "16px Arial";
ctx.fillStyle = "#0095DD";
ctx.fillText("Score: "+score, 8, 20);
}
and "var score = 0;"
but i wont get the "score" text to show up in the game
whole code:

var canvas = null;
var c = null;
var timer = null;
var enemyTimer = null;
var score = 0;

window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function(callback){
window.setTimeout(callback, 1000 / 60);
};
})();

function boot() {
canvas = document.getElementById("spelplan");
canvas.addEventListener("mousemove", function(e) {
mouse.x = e.offsetX;
mouse.y = e.offsetY;
});
canvas.width = 1400;
canvas.height = 600;
c = canvas.getContext("2d");
c.font = "20px Verdana";
(function animloop(){
requestAnimFrame(animloop);
tick();
})();

enemyTimer = setInterval(function() {
    spawnEnemy();
}, 1000);

}
var game = {
player: {
x: 100,
y: 300,
xm: 0,
ym: 0
}
};

function tick() {
if(pressedKeys.indexOf(keys.up) != -1) {
game.player.ym -= 1;
}
if(pressedKeys.indexOf(keys.down) != -1) {
game.player.ym += 1;
}
if(pressedKeys.indexOf(keys.left) != -1) {
game.player.xm -= 1;
}
if(pressedKeys.indexOf(keys.right) != -1) {
game.player.xm += 1;
}
game.player.xm = 0.9;
game.player.ym
= 0.9;
if(game.player.x+game.player.xm < 21) {
game.player.xm = -game.player.xm;
}
if(game.player.x+game.player.xm > 1400-21) {
game.player.xm = -game.player.xm;
}
if(game.player.y+game.player.ym < 21) {
game.player.ym = -game.player.ym;
}
if(game.player.y+game.player.ym > 600-21) {
game.player.ym = -game.player.ym;
}
game.player.x += game.player.xm;
game.player.y += game.player.ym;
c.clearRect(0, 0, 1400, 600);
c.lineStyle = "#000";
c.lineWidth = 2;
c.beginPath();
c.arc(game.player.x, game.player.y, 20, 0, Math.PI2);
c.stroke();
c.beginPath();
c.moveTo(game.player.x, game.player.y);
var r = Math.atan2(mouse.x-game.player.x, mouse.y-game.player.y);
r = (-r)+(Math.PI/2);
var gun = {
x: Math.cos(r)
20,
y: Math.sin(r)*20
};
c.lineTo(game.player.x+(gun.x), game.player.y+(gun.y));
c.stroke();

c.lineWidth = 1;
for(var enemy in enemies) {
    enemies[enemy].move();
    c.beginPath();
    c.arc(enemies[enemy].x, enemies[enemy].y, enemies[enemy].size, 0, Math.PI*2);
    c.stroke();
}
for(var bulletIndex in bullets) {
    bullets[bulletIndex].x += bullets[bulletIndex].xm;
    bullets[bulletIndex].y += bullets[bulletIndex].ym;
    for(var enemy in enemies) {
        if(distance(enemies[enemy].x, enemies[enemy].y, bullets[bulletIndex].x, bullets[bulletIndex].y) < 5+enemies[enemy].size) {
            enemies[enemy].hp--;
            bullets.splice(bulletIndex, 1);
            continue;
        }
    }
    c.beginPath();
    c.arc(bullets[bulletIndex].x, bullets[bulletIndex].y, 5, 0, Math.PI*2);
    c.stroke();
}
for(var bulletIndex in bullets) {
    if(isOutside(bullets[bulletIndex].x, bullets[bulletIndex].y, 5)) {
        bullets.splice(bulletIndex, 1);
    }
}
for(var enemy in enemies) {
    if((enemies[enemy].x < -10) || (enemies[enemy].hp <= 0)) {
        enemies.splice(enemy, 1);
    }
}

}

var bullets = [];
function fire() {
var r = Math.atan2(mouse.x-game.player.x, mouse.y-game.player.y);
r = (-r)+(Math.PI/2);
bullets.push({
x: game.player.x,
y: game.player.y,
xm: Math.cos(r)20,
ym: Math.sin(r)
20
});
}
function isOutside(x, y, radie) {
if(x < -radie) {
return true;
} else if(x > 1400+radie) {
return true;
} else if(y < -radie) {
return true;
} else if(y > 600+radie) {
return true;
} else {
return false;
}
}

var enemyTypes = [
{
size: 20,
speed: 2,
hp: 1,
movement: function() {
this.x -= enemyTypes[this.type].speed;
}
}
];

var enemies = [];
function spawnEnemy() {
enemies.push({
x: 1400+10,
y: enemyTypes[0].size+(Math.random()(600-(enemyTypes[0].size2))),
xm: 0,
ym: 0,
type: 0,
size: enemyTypes[0].size,
hp: enemyTypes[0].hp,
move: enemyTypes[0].movement
});
}

function distance(x1, y1, x2, y2) {
var a = x1-x2;
var b = y1-y2;
return Math.sqrt(aa + bb);
}

var mouse = {
x: 0,
y: 0
};
var keys = {
up: 87,
down: 83,
left: 65,
right: 68
};
var pressedKeys = [];
window.addEventListener("keydown", function(e) {
if(pressedKeys.indexOf(e.keyCode) == -1) {
pressedKeys

Blauelf
@Blauelf
Nov 08 2017 12:56

@Tejparn To format code here on chat put it between lines of backticks:
```js
var answer = 42;
```
gives

var answer = 42;

But really, don't dump such large code blocks on chat, but use some hosting service like github gists or pastebin, or a codepen or jsbin or whatever where appropriate.

About the problem - I have never used canvas. You do call drawScore and have ensured it's running (for example by logging something from the function), right?

Garrus Napp
@GarrusNapp
Nov 08 2017 12:58
@Tejparn you need to call that function each tick
after everything else was drawn
Tejparn
@Tejparn
Nov 08 2017 13:08

@Blauelf oh okey, thanks!

no i have not, i simply found on the internet that i could do it this way, im not so good at coiding

CamperBot
@camperbot
Nov 08 2017 13:08
tejparn sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4647 | @blauelf |http://www.freecodecamp.com/blauelf
Tejparn
@Tejparn
Nov 08 2017 13:09
@GarrusNapp how do i do that?
Garrus Napp
@GarrusNapp
Nov 08 2017 13:11
@Tejparn inside function tick(), just where it ends
call your drawScore()
Tejparn
@Tejparn
Nov 08 2017 13:12
how do i "call" it?
Blauelf
@Blauelf
Nov 08 2017 13:27
You call or invoke a function by writing its name and placing a pair of parentheses after, in this case without passing any arguments.
Rohit Yadav
@rohyadav
Nov 08 2017 13:29
anyone help me out why i am getting this error
please follow this snippet
Uncaught ReferenceError: addAnother is not defined
at window.onload ((index):56)
???
anyone here??
Garrus Napp
@GarrusNapp
Nov 08 2017 13:33
@rohyadav let me see if can help
Rohit Yadav
@rohyadav
Nov 08 2017 13:35
@GarrusNapp thanks man :)
CamperBot
@camperbot
Nov 08 2017 13:35
rohyadav sends brownie points to @garrusnapp :sparkles: :thumbsup: :sparkles:
:cookie: 852 | @garrusnapp |http://www.freecodecamp.com/garrusnapp
Stephen James
@sjames1958gm
Nov 08 2017 13:36
@rohyadav This is because jsfiddle wraps the javascript in a event handler and this takes your functions out of globals scope
Rohit Yadav
@rohyadav
Nov 08 2017 13:38
ok so what i do now how .. can you share updated code
@sjames1958gm
Garrus Napp
@GarrusNapp
Nov 08 2017 13:39
@rohyadav document.getElementsByTagName('button')[0].addEventListener('click', addAnother) this maybe
no need for onClick in such case
Stephen James
@sjames1958gm
Nov 08 2017 13:39
@rohyadav Use javascript to refer to the DOM as shown above by @GarrusNapp
My preference would be querySelector but the same is accomplished.
document.querySelector("#button").addEventListener('click', addAnother)
Rohit Yadav
@rohyadav
Nov 08 2017 13:43
@GarrusNapp yes, thanks man it worked and i updated the jsfiddle
CamperBot
@camperbot
Nov 08 2017 13:43
rohyadav sends brownie points to @garrusnapp :sparkles: :thumbsup: :sparkles:
api offline
Rohit Yadav
@rohyadav
Nov 08 2017 13:43
@sjames1958gm thanks for you time and help :)
CamperBot
@camperbot
Nov 08 2017 13:43
rohyadav sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8683 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 08 2017 13:44
@rohyadav you're welcome
Rohit Yadav
@rohyadav
Nov 08 2017 13:47
@sjames1958gm and @GarrusNapp one weired things happening can you suggest me best approch in javascrip tfor that
when you click on upto 6 list item you can see the output in console but after adding the item not seeing
Stephen James
@sjames1958gm
Nov 08 2017 13:48
@rohyadav Do you want to append the textNode to the li or the ul?
Garrus Napp
@GarrusNapp
Nov 08 2017 13:49
@rohyadav first, adding element doesn't work as you want, you create <li></li> and text node with item X after that
Rohit Yadav
@rohyadav
Nov 08 2017 13:49
li
Garrus Napp
@GarrusNapp
Nov 08 2017 13:49
instead of <li>itemX</li>
@rohyadav that is why when you click your created list you get List item was clicked!
without nr
Stephen James
@sjames1958gm
Nov 08 2017 13:51
@rohyadav
  1. you are appending the text node to the ul not the li
  2. you are not adding an id to your new li so your console.log has no id to output
  li.id = "post-" + listLength;

  li.appendChild(nextNode);
Rohit Yadav
@rohyadav
Nov 08 2017 13:52
@sjames1958gm even if i add https://jsfiddle.net/rohyadav/v0rfecf7/3/
when i click on list 7 that newly created
nothing log in console
and if i click 6 that already in the dom that worked
Stephen James
@sjames1958gm
Nov 08 2017 13:53
@rohyadav console.log("List item ", e.target.id.replace("post-", ""), " was clicked!");
your console.log is using the id of the list item, but your new list item has no id
@rohyadav You don't even need to create the text node
  li.id = "post-" + listLength;
  li.textContent = "Item " + listLength;
Rohit Yadav
@rohyadav
Nov 08 2017 13:55
yes if even no id for now .. atleast when i click in any newly created list item that time loggin in console
ok
can you fork and update and share with me jsfiddle
Tiago Correia
@tiagocorreiaalmeida
Nov 08 2017 14:01
:wave:
Rohit Yadav
@rohyadav
Nov 08 2017 14:06
what is it? @tiagocorreiaalmeida
Tiago Correia
@tiagocorreiaalmeida
Nov 08 2017 14:10
its supposed to show the stock of companies daily
abraham anak agung
@padunk
Nov 08 2017 14:10
@tiagocorreiaalmeida nice, looks like yahoo stocks, you could add more here.
but kind of trouble getting stock code :smile:
Rohit Yadav
@rohyadav
Nov 08 2017 14:14
@tiagocorreiaalmeida is there any feature to convert currency
like INR
for indian currency
so i can see like 20.00 INR
like so
Stephen James
@sjames1958gm
Nov 08 2017 14:18

@rohyadav Just replace

  var nextNode = document.createTextNode("Item " + listLength)
    ul.appendChild(nextNode)

with

  li.id = "post-" + listLength;
  li.textContent = "Item " + listLength;
Tiago Correia
@tiagocorreiaalmeida
Nov 08 2017 14:20
@rohyadav that would force me to move the data displayed on the chart and if that was really necessary would force me to do it to all theexistent coins no? :D and not only 1 more I think
Rohit Yadav
@rohyadav
Nov 08 2017 14:22
@tiagocorreiaalmeida yes, i would love to
can you check this i have updated littele bit
Stephen James
@sjames1958gm
Nov 08 2017 14:25
@rohyadav You are using the items id to console.log
console.log("List item ", e.target.id.replace("post-", ""), " was clicked!");
but you are not setting an id into the new li
li.id = "post-" + listLength; this sets an id on the added item
Rohit Yadav
@rohyadav
Nov 08 2017 14:25
@sjames1958gm
yes
now worked
Stephen James
@sjames1958gm
Nov 08 2017 14:25
@rohyadav :+1:
Rohit Yadav
@rohyadav
Nov 08 2017 14:25
thanks you so much
:+1:
@sjames1958gm :+1:
Stephen James
@sjames1958gm
Nov 08 2017 14:26
you're welcome
Rohit Yadav
@rohyadav
Nov 08 2017 14:30
@sjames1958gm
one more weired thing happening
when you run the jsfiddle
and then click on list time nothing loging in the console
but when add item then you click in any list item that work
Stephen James
@sjames1958gm
Nov 08 2017 14:33
@rohyadav Move this function document.getElementById("parent-list").addEventListener("click", function(e) { ...});
out of your addAnother function so that it runs at start up not only after your first add
Rohit Yadav
@rohyadav
Nov 08 2017 14:34
@sjames1958gm yes right
:)
dyon3334
@dyon3334
Nov 08 2017 15:48
a object is an array where you can set the names for the indexes or a array is a object without names and only a index ?
Diego Mayer
@Chrono79
Nov 08 2017 15:54
@dyon3334 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
arrays are objects
var arr = [];
var obj = {};

console.log(arr instanceof Object); //true
console.log(obj instanceof Array); //false
Spyrantis Theodoros
@thodorisanta
Nov 08 2017 15:57

why in my JS line 98 is not working? like if i use simonMoves[0] it works but not if i put simonMoves[index] in it :/

https://codepen.io/oshikurou/pen/vWGoee?editors=0011

Diego Mayer
@Chrono79
Nov 08 2017 16:00
@thodorisanta scope problems?
Markus Kiili
@Masd925
Nov 08 2017 16:01
@dyon3334 Array elements are actually stored on properties with numeric keys like "0" etc.
Jason Luboff
@JLuboff
Nov 08 2017 16:12
@Chrono79 @Masd925 Morning
Spyrantis Theodoros
@thodorisanta
Nov 08 2017 16:25
@Chrono79 saddly no. i dont know what the problem
Diego Mayer
@Chrono79
Nov 08 2017 16:42
:wave:
Jason Luboff
@JLuboff
Nov 08 2017 16:45
What up?
Christopher McCormack
@cmccormack
Nov 08 2017 16:48
gm :wave:
Jason Luboff
@JLuboff
Nov 08 2017 16:48
Morning
Christopher McCormack
@cmccormack
Nov 08 2017 16:48
time to get in there and update your random quote generators so you can tweet 280 characters!
Jason Luboff
@JLuboff
Nov 08 2017 16:49
It's a good thing I never actually made mine adhere to that :joy:
Although I do need to update mine to use my API
Christopher McCormack
@cmccormack
Nov 08 2017 16:49
haha
I just checked mine and it looks like the twitter widget api may not have been updated with the new character limit yet
Jason Luboff
@JLuboff
Nov 08 2017 16:51
I need to move all my projects over to glitch. I moved my portfolio..but haven't moved the rest of my front end projects. Problem is all my images are broken now since photobucket stopped allowing hotlinking
Christopher McCormack
@cmccormack
Nov 08 2017 16:52
Why glitch? Just because it's free and easy?
Jason Luboff
@JLuboff
Nov 08 2017 16:53
Ya, and I can have my portfolio and front end projects all be one site
and I can host images on there without any issue
Alex
@alexandrupintilei
Nov 08 2017 16:55
What is wrong? :( https://jsfiddle.net/rngxjsx3/
Blauelf
@Blauelf
Nov 08 2017 16:59
For example, functions and variables share the same namespace, so should not have the same name. Not sure how jsfiddle integrates its JavaScript tab, though.
Christopher McCormack
@cmccormack
Nov 08 2017 17:03
@alexandrupintilei many of your variable names are incorrect. Also plus isn't defined before use. Try adding this at top of your html:
<script>

function plus(){
  var minus = document.getElementById('check2');
  var inmultire = document.getElementById('check3');
  var Impartire = document.getElementById('check4');
  var newValue = 0;
  var textP = document.getElementById('text');
  var plus = document.getElementById('check1');
  var n1 = parseFloat(document.getElementById('num1').value);
  var n2 = parseFloat(document.getElementById('num2').value);
  newValue = n1+n2;
  textP.innerHTML="x=" + newValue;
}

</script>
Blauelf
@Blauelf
Nov 08 2017 17:10

jsfiddle packs this stuff into its own scope, using window.onload. So instead of

<input type="checkbox" name="check" id="check1" onClick="plus()">Adunare<br>

and

debugger;
var plus = document.getElementById('check1');
var minus = document.getElementById('check2');
var inmultire = document.getElementById('check3');
var Impartire = document.getElementById('check4');
var newValue = 0;
var textP = document.getElementById('text');

function plus(){
var n1 = parseFloat(document.getElementById('num1').value);
var n1 = parseFloat(document.getElementById('num2').value);
newValue = n1+n2;
textP.innerHTML="x=" + newVal;
};

try

<input type="checkbox" name="check" id="check1">Adunare<br>

and

var plusCheck = document.getElementById('check1');
var minusCheck = document.getElementById('check2');
var inmultireCheck = document.getElementById('check3');
var ImpartireCheck = document.getElementById('check4');
var newValue = 0;
var textP = document.getElementById('text');

plusCheck.addEventListener("click", plus); // this is equivalent to the onclick, but in a scope that knows plus function

function plus(){
  var n1 = parseFloat(document.getElementById('num1').value);
  var n2 = parseFloat(document.getElementById('num2').value);
  var newValue = n1+n2;
  textP.innerHTML="x=" + newValue;
};
Alex
@alexandrupintilei
Nov 08 2017 17:10
@Blauelf @cmccormack thx
CamperBot
@camperbot
Nov 08 2017 17:10
alexandrupintilei sends brownie points to @blauelf and @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1265 | @cmccormack |http://www.freecodecamp.com/cmccormack
:star2: 4648 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Nov 08 2017 17:11
Not sure why you would want multiple choice for the checkboxes, divide-multiply? Subtract-divide-add? :D
Christopher McCormack
@cmccormack
Nov 08 2017 17:11
It's a stew of code :)
throw everything together
Jason Luboff
@JLuboff
Nov 08 2017 17:12
Add a pinch of salt and pepper
Blauelf
@Blauelf
Nov 08 2017 17:13
I'd add some lemon juice. Often helps.
Christopher McCormack
@cmccormack
Nov 08 2017 17:13
Now i'm hungry
Jason Luboff
@JLuboff
Nov 08 2017 17:15
Hello hungry
Alex
@alexandrupintilei
Nov 08 2017 17:16
@Blauelf yes.just for practice
Christopher McCormack
@cmccormack
Nov 08 2017 17:16
Jason Luboff
@JLuboff
Nov 08 2017 17:16
:joy:
Bryan Reese
@breese8009
Nov 08 2017 17:22
@JLuboff yoooo remember i was tryin to do react w passport?
that was a mistake
wasnt able to do it, got passport working with a basic MEN stack app
but Okta is best for auth with react
moral of the story
Kaz Baig
@kbaig
Nov 08 2017 17:23
@breese8009 were you trying to implement passport on the front end
?
Bryan Reese
@breese8009
Nov 08 2017 17:23
dont try passport w react
@kbaig i tried
lol
an failed
Kaz Baig
@kbaig
Nov 08 2017 17:24
Can't say I'm surprised :D
Bryan Reese
@breese8009
Nov 08 2017 17:24
I got it working on the back end
easily
best bet for auth when using react
Christopher McCormack
@cmccormack
Nov 08 2017 17:28
@breese8009 Are you using React with node backend?
Jason Luboff
@JLuboff
Nov 08 2017 17:36
@breese8009 bookmarked for when I get into that realm. Thanks
CamperBot
@camperbot
Nov 08 2017 17:36
jluboff sends brownie points to @breese8009 :sparkles: :thumbsup: :sparkles:
:cookie: 927 | @breese8009 |http://www.freecodecamp.com/breese8009
Tiago Correia
@tiagocorreiaalmeida
Nov 08 2017 17:38
https://tiagocorreia-marketstocks.glitch.me @cmccormack according to what you mentioned yesterday or missing anything?
Christopher McCormack
@cmccormack
Nov 08 2017 17:38
@breese8009 this is a frontend solution only - if you want to use react with passport you would need to setup some backend routing for login, then you could use passport
@tiagocorreiaalmeida looks really nice - there is some slight buggyness where it tries to fill the area between two points on the graph.
Christopher McCormack
@cmccormack
Nov 08 2017 17:43
@tiagocorreiaalmeida after removing some stocks the graph bugged out completely and wouldn't show any stock
@tiagocorreiaalmeida and I'd still recommend putting the stock symbol input above the graph so if you're on a smaller screen you don't miss it.
Markus Kiili
@Masd925
Nov 08 2017 17:56
@JLuboff Hello.
Jason Luboff
@JLuboff
Nov 08 2017 18:03
@Masd925 How's the free diving going>
Bryan Reese
@breese8009
Nov 08 2017 18:08
@cmccormack Yea I went through trying to do that, but its didnt really work out well
Markus Kiili
@Masd925
Nov 08 2017 18:10
@JLuboff Fine. I did a clean 6 minutes breath hold some time ago. With something like that I should have a chance for a medal in spring national championships. Haven't really had a chance to train length diving this fall but now possible again. Possible that I also do that in the nationals if I improve somewhat.
Jason Luboff
@JLuboff
Nov 08 2017 18:11
@Masd925 Nice! Wishing you the best of luck when that comes around
Tiago Correia
@tiagocorreiaalmeida
Nov 08 2017 18:25
The input one yeah tested on mobile and makes sense having it above the othera errors you mentioned cantbseem to spot them hum, if you could make the same steps and print it, big thanks @cmccormack
CamperBot
@camperbot
Nov 08 2017 18:25
tiagocorreiaalmeida sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1266 | @cmccormack |http://www.freecodecamp.com/cmccormack
Nehemiah Kivelevitz
@NehemiahK
Nov 08 2017 19:46
Hey. Did you guys do the advanced algorithm scripting? Would you recommend doing it?
Darren
@DarrenfJ
Nov 08 2017 19:49
@NehemiahK i find algorithms a good way to expand the mind, and learn the logic of how to take things apart and sort and rearrange them.. in some ways that's the basis of dealing with data
me and some others who are done most/all of the fCC ones have moved over to other sites like codewars and hackerrank that are mostly just algo type challenges.. for fun and the opportunity to keep the skills fresh
jhobotuck
@jhobotuck
Nov 08 2017 20:13

I'm working on the random quote generator and intergrating Javascript into my code for the first time. Despite modelling my code off the example can't the button click to replace the text in the target div. Any ideas?

https://codepen.io/jhobotuck/pen/bWvzZB

Moisés Man
@moigithub
Nov 08 2017 20:21
@jhobotuck open ur browser devtools (F12 key on most browsers)
check on console tab
jhobotuck
@jhobotuck
Nov 08 2017 20:24
69 errors log in the console... not sure what do from here.
Says "$ is not defined" in like 20 of the errors.
Jason Luboff
@JLuboff
Nov 08 2017 20:30
@jhobotuck You need to include jquery. Click the gear next to JS and add jquery as an external library
Ronique Ricketts
@RoniqueRicketts
Nov 08 2017 20:32
Lol I got an offer from a guy at work today to make him a clock that shows the days of the week but the week should start on Thursday. He need this for a printer. Can I use Electron to make this?
Dylan
@dhcodes
Nov 08 2017 20:34
@moigithub you have a handle of async/await?
Ronique Ricketts
@RoniqueRicketts
Nov 08 2017 20:35
In space of 30m I got 2 development offers to make mobile and desktop app. hahaha
Dylan
@dhcodes
Nov 08 2017 20:36
nice @RoniqueRicketts
Ronique Ricketts
@RoniqueRicketts
Nov 08 2017 20:36
@dhcodes any ideas how to make that desktop app that shows a week counter?
Dylan
@dhcodes
Nov 08 2017 20:37
electron would work
pretty much that or react native if you plan to use js
Ronique Ricketts
@RoniqueRicketts
Nov 08 2017 20:38
I plan to use js I don't know react native. I know a little reactjs but not react native.
So Electronjs makes plain exe files?
Ronique Ricketts
@RoniqueRicketts
Nov 08 2017 20:43
@dhcodes thanks who hoo!!!!!
CamperBot
@camperbot
Nov 08 2017 20:43
roniquericketts sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1857 | @dhcodes |http://www.freecodecamp.com/dhcodes
Ronique Ricketts
@RoniqueRicketts
Nov 08 2017 20:43
nerd mode activate!!!!!!!!!!
Dylan
@dhcodes
Nov 08 2017 20:45
lol good luck
Ronique Ricketts
@RoniqueRicketts
Nov 08 2017 20:46
thanks. Gonna check out how to build this timer
jhobotuck
@jhobotuck
Nov 08 2017 20:46
@JLuboff Thanks dude. Knew it was going to be something simple.
CamperBot
@camperbot
Nov 08 2017 20:46
jhobotuck sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 2256 | @jluboff |http://www.freecodecamp.com/jluboff
Conor Murphy
@cmurphy580
Nov 08 2017 21:57
Can anyone tell me why this scroll doesn't start at the first div and allow me to scroll all the way through?
korzo
@korzo
Nov 08 2017 22:22
@cmurphy580 because of display: inline-flex; on .project-wrap