These are chat archives for FreeCodeCamp/HelpJavaScript

27th
Aug 2017
Fernando
@lestairon
Aug 27 2017 00:15

function mutation(arr) {
  arr =arr.map((L) => L.toLowerCase());
  return arr[0].split("").every((X) => arr[1].indexOf(X) !== -1);
}

mutation(["hello", "hello"]);
Not working :l
I mean, it works for some
Fernando
@lestairon
Aug 27 2017 00:22
Nvm, now it's working

function mutation(arr) {
  arr =arr.map((L) => L.toLowerCase());
  return arr[1].split("").every((X) => arr[0].indexOf(X) !== -1);
}

mutation(["hello", "hello"]);
Dante M Brown
@Vyceroy
Aug 27 2017 00:55
Is anyone able to help with me with some basic algorithm scripting ?
Stephen James
@sjames1958gm
Aug 27 2017 01:04
@Vyceroy Sure
Ginger
@GingerChew
Aug 27 2017 01:35
Hey all, I'm trying to add an array to this collection with a push function but I need to give it the key 'tracks' but I can't seem to get it to work
function updateRecords(id, prop, value) {
  var collectionCopy = JSON.parse(JSON.stringify(collection));
  for (var index in collectionCopy) {
    if (collectionCopy[index] == '5439') {
      collectionCopy.index.tracks = 'tracks';
      collectionCopy.index.tracks.push([]);
  // Ignore below this its not complete yet, I'm just trying to get a handle on the basics of object manipulation
    if (prop == index.tracks && typeof index.tracks != 'object'){
        var tracks = [];
        collectionCopy.push(tracks);

      } else if (prop == index['']) {

      }
    }
  }


  return collectionCopy;
}
Stephen James
@sjames1958gm
Aug 27 2017 01:39
@GingerChew Just assign the tracks property the empty array.
collection[id].tracks = []
You should be using id to access collection not loop over the collection
Ginger
@GingerChew
Aug 27 2017 01:43
okay, cool! thanks @sjames1958gm
CamperBot
@camperbot
Aug 27 2017 01:43
gingerchew sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8395 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ginger
@GingerChew
Aug 27 2017 01:47
so in the case that i'm working with, there is no tracks property, how do I do it in that case?
Moisés Man
@moigithub
Aug 27 2017 01:49
use hasOwnProperty method to check if have or not that property
Ginger
@GingerChew
Aug 27 2017 01:50
I know to do that, I'm not working on that part of it yet thoguh
I'm trying to just add to the id object a pair that is 'tracks':[]
Stephen James
@sjames1958gm
Aug 27 2017 01:59
@GingerChew As I recall you are suppose to work on collection not the copy
Then return the collection
Ginger
@GingerChew
Aug 27 2017 02:01
Yeah, you're right, its working for me now
Adzanny
@zanisis
Aug 27 2017 04:23

anyone know what is meant question?
Input

The first line is the number of test cases T.Each test case has three numbers A, B, K, each on their own line given in that order.

Output

For each test case, output one line of the form “Case C: X” (without the quotes), where C is the case number (starting from 1), and X is the number of integers between A and B, inclusive, that are divisible by K.

sample input
2 1 10 3 8 20 4

prakash chandra yadav
@prakashyadav008
Aug 27 2017 05:25
@prakashyadav008
hey can anyone help me out
https://codepen.io/prakashyadav008/pen/brjQOb
i cant see the background color in section1-1
Abhinav Mishra
@abhinav-m
Aug 27 2017 05:49
Im wondering how to make a cell stand out when it gets new life in my game of life
one way i am thinking of approaching this is checking if cells which are alive in this generation were alive previously
and assigning different css classes according to that
is this a valid approach?
Ken Haduch
@khaduch
Aug 27 2017 06:08
@abhinav-thinktank - you could certainly try that and see how it works - it sounds like an idea that should work?
Abhinav Mishra
@abhinav-m
Aug 27 2017 06:09
@khaduch i've not seen how it's done in the fcc's version
i guess ill give it a go and find out!
Ken Haduch
@khaduch
Aug 27 2017 06:12
@abhinav-thinktank - I haven't gotten this far. Perhaps using some CSS animation to change the color would be another thing to try?
Abhinav Mishra
@abhinav-m
Aug 27 2017 06:15
hmm
the thing im worried about is that im simulating new generations in 250 ms intervals or such
and not sure which technique would be appropriate to make highlight the new life
heroiczero
@heroiczero
Aug 27 2017 06:17
do you want to highlight a new life like turn it green before it becomes red?
Abhinav Mishra
@abhinav-m
Aug 27 2017 06:17
yeah
@heroiczero like in the fcc example its sort of a shade of pink before its red *
im guessing the old life which is alive is red and the new life which spawns is the pink one here
heroiczero
@heroiczero
Aug 27 2017 06:22
"Feel free to add cells while it's running. The cells in light red are younger, dark red are older. Enjoy! " thats what it says i mean probably has a timer to change colors like setInterval or something. similar to Podmoro clock
Abhinav Mishra
@abhinav-m
Aug 27 2017 06:24
hmm..
i dont think so .. because old life is technically the old cells which stay alive
there must be something being used to check which ones from the old cells are alive and which are new
the old ones alive are dark red, the new ones are light pink
Mai Thinh
@mthinh
Aug 27 2017 06:57
Im doing twitch api project, pls show me howw to request multiple api at the same yine
Do we need loop
Throubg the array of username
heroiczero
@heroiczero
Aug 27 2017 06:58
@mthinh you can either use forEach or loop through the array of users
Mai Thinh
@mthinh
Aug 27 2017 06:59
@heroiczero i did it, but i just use the first element of the array
heroiczero
@heroiczero
Aug 27 2017 07:00
@mthinh why not use all the elements of the array of users? confused
Mai Thinh
@mthinh
Aug 27 2017 07:00
opps sr
i mean
when i use for loop
it just request the first element of the array
```
$(document).ready(function(){
  var api='https://wind-bow.gomix.me/twitch-api/streams/user?callback=?';
  var usernameArr=["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];

  for(var i=0; i < usernameArr.length;i++){
   var j = i;
    api = api.replace('user',usernameArr[j]);
    $.getJSON(api,function(data){
    console.log(data);
  })
  }



})
here is my code, the json that I received is just the first element
heroiczero
@heroiczero
Aug 27 2017 07:02
@mthinh you need use let for let i=0 and let j=i; because you want to change for each loop
Mai Thinh
@mthinh
Aug 27 2017 07:05
yah but i didnt work
piteto
@piteto
Aug 27 2017 07:08
Can I use es6 in the challenges?
Mai Thinh
@mthinh
Aug 27 2017 07:08
@KirstaA yeah sure
piteto
@piteto
Aug 27 2017 07:09
Do I have to disable warnings in every challenge or is there a setting?
Mai Thinh
@mthinh
Aug 27 2017 07:20
its just a warning @KirstaA
if you understand how ES6, it's fine to use
*how ES6 works
Daiyf12
@Daiyf12
Aug 27 2017 07:30
blob
Why can't I pass this one?
Mai Thinh
@mthinh
Aug 27 2017 07:32
you can concat the string
like : myNoun + myVerb + ....
result = myNoun + myVerb + ....
Razvan Jackson
@RazvanJackson
Aug 27 2017 07:33
Does someone know why youtube search bar is not working?
It's loading 70% then nothing...
piteto
@piteto
Aug 27 2017 07:33
thanks @mthinh I'll just use es6
CamperBot
@camperbot
Aug 27 2017 07:33
kirstaa sends brownie points to @mthinh :sparkles: :thumbsup: :sparkles:
:cookie: 291 | @mthinh |http://www.freecodecamp.com/mthinh
piteto
@piteto
Aug 27 2017 07:34
@RazvanJackson Wrong room? I don't know if there's a youtube room on github
it's all Google, right?
Never mind, I should search before I speak :/ https://github.com/youtube
Daiyf12
@Daiyf12
Aug 27 2017 07:35
@mthinh I made it. Thank you very much.
CamperBot
@camperbot
Aug 27 2017 07:35
daiyf12 sends brownie points to @mthinh :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @mthinh |http://www.freecodecamp.com/mthinh
Mai Thinh
@mthinh
Aug 27 2017 07:39
@Daiyf12 youre welcome
Aimee
@bestAimee
Aug 27 2017 08:31
i push some address of pictures to array,then in js set <a></a> background
the wrong is 404
why?
Cengiz Gonen
@cetico
Aug 27 2017 08:41

const createBoard = function({width, height}) {

return Array(height).fill([]).map(row => row.concat( Array(width).fill( Math.round(Math.random()) ) ))

}

Trying to create an array of arrays of value 1 or 0. But each array has either [0,0,0,0,0,0] or [1,1,1,1,1,1] since fill isn't a callback. I need it random like [0, 1, 0, 0, 1] What would be an es6 way of creating an array of arrays of values 0 or 1?
const createBoard = function({width, height}) {


  return Array(height).fill([]).map(row => row.concat( Array(width).fill( Math.round(Math.random()) ) ))


}
createboard({width: 5, height: 10})
Abhinav Mishra
@abhinav-m
Aug 27 2017 08:47
@hyrosian
Array(10).fill(Array(20).fill(1))
Array(10) <- represents rows
the one inside represents the columns
to generate the sequence randomly, you could subtract 1 from some values in the inner array
something along the lines of
Array(height).fill(Array(width).fill(1).map( v =>  // make it random by subtracting 1 from some values))
@hyrosian is this what you meant?
Abhinav Mishra
@abhinav-m
Aug 27 2017 08:59
ohh now i understand the problem you're facing..
i guess you can still do it by filling the array and subtracting values from some values in the array randomly
Aimee
@bestAimee
Aug 27 2017 09:16
i push some address of pictures to array,then in js set <a></a> background
the wrong is 404
why?
korzo
@korzo
Aug 27 2017 09:17
@bestAimee Link to your codepen of post your code
Aimee
@bestAimee
Aug 27 2017 09:19
var thingImformation = {
"miphone":{
"小米6":["../images/小米手机/6.png.jpg",2499],
"小米Max2":["../images/小米手机/1.jpg",1699],
"小米5X":["../images/小米手机/2.jpg",1299],
"小米Note2":["../images/小米手机/5.jpg",2799],
"小米MIX":["../images/小米手机/4.jpg",3499],
"小米5s":["..images/小米手机/3.png",1999]
}
}
for(var i=0;i<iThingShow.length;i++){
iThingShow[i].onmouseover = function(){
iShowThing.innerHTML = '';
for(var arr in thingImformation.miphone){
var oLi1 = document.createElement('li');
oLi1.className = 'thing-pic';
var oA1 = document.createElement('a');
oA1.className = 'show-pic';
oA1.style.background = 'url('../images/1.jpg') no-repeat';
var oImg = document.createElement('img');
oImg.src = thingImformation.miphone[arr][0];
oA1.appendChild(oImg);
oLi1.appendChild(oA1);
var oA2 = document.createElement('a');
oA2.className = 'thing-name';
oA2.innerHTML = arr;
oLi1.appendChild(oA2);
var oI = document.createElement('i');
oI.className = 'things-price';
oI.innerHTML = thingImformation.miphone[arr][1];
oLi1.appendChild(oI);
iShowThing.appendChild(oLi1);
var oLi2 = document.createElement('li');
oLi2.className = 'longer-line';
iShowThing.appendChild(oLi2);
iShowThing.style.height = 0;
iShowThing.style.display = 'block';
move(iShowThing,{height:229});
        }
    }
}
image.png
image.png
image.png
korzo
@korzo
Aug 27 2017 09:26
@bestAimee Try to remove special characters from image path
@bestAimee Are your images in folder /images/小米手机 relative to your application's folder?
Cengiz Gonen
@cetico
Aug 27 2017 09:53
@abhinav-thinktank used this:
const createBoard = ({width, height}) => 
  Array.from({ length: height }, 
    () => Array.from({ length: width }, 
      () => Math.floor(Math.random() * 2)
    )
  );
Abhinav Mishra
@abhinav-m
Aug 27 2017 09:54
@hyrosian :+1:
the one i pasted above also worked with some tweaking
you're doing the game of life?
Cengiz Gonen
@cetico
Aug 27 2017 09:55
@abhinav-thinktank yes
Abhinav Mishra
@abhinav-m
Aug 27 2017 09:55
@hyrosian :+1: me too
almost done with it..
Vali
@valimikayilov
Aug 27 2017 10:02
@korzo Yeah I know it is incomplete, but how can I make the substr part to work properly (I mean how can I put the letters before vowel to the end ?).
finished the initial version of my game of life
Stephen James
@sjames1958gm
Aug 27 2017 10:09
@abhinav-thinktank :+1:
Abhinav Mishra
@abhinav-m
Aug 27 2017 10:10
@sjames1958gm :D
@sjames1958gm thanks for the help!
CamperBot
@camperbot
Aug 27 2017 10:10
abhinav-thinktank sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8396 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Abhinav Mishra
@abhinav-m
Aug 27 2017 10:10
i need to add changing the size of the matrix being used
Stephen James
@sjames1958gm
Aug 27 2017 10:10
@abhinav-thinktank looks good !
Abhinav Mishra
@abhinav-m
Aug 27 2017 10:10
@sjames1958gm ty!
CamperBot
@camperbot
Aug 27 2017 10:10
abhinav-thinktank sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: abhinav-thinktank already gave sjames1958gm points
korzo
@korzo
Aug 27 2017 10:11
@Geek-Killer What was the problem? I can't find your previous message
Adzanny
@zanisis
Aug 27 2017 10:14
@all how change character like gggg to "gggg" with regex?.
Stephen James
@sjames1958gm
Aug 27 2017 10:17
@zanisis You want to insert " into a string?
Adzanny
@zanisis
Aug 27 2017 10:18
@sjames1958gm yes
Stephen James
@sjames1958gm
Aug 27 2017 10:19
@zanisis str.replace(/(g{4})/g, '"$1"');
charles
@code9ja
Aug 27 2017 10:23
@korzo hi
I am back again with the same issue
Challenge 196 comparison-with-the-greater-than-operator
Adzanny
@zanisis
Aug 27 2017 10:27
@sjames1958gm how make it dinamic character length sometime five or six length?
Stephen James
@sjames1958gm
Aug 27 2017 10:27
@code9ja Show your code
charles
@code9ja
Aug 27 2017 10:28
@sjames1958gm ok

```function testGreaterThan(val) {
if (val > 10) { // Change this line
return "Over 10";
}

if (val > 100) { // Change this line
return "Over 100";
}

return "10 or Under";
}

// Change this value to test
testGreaterThan(150);

korzo
@korzo
Aug 27 2017 10:29
@code9ja You have to change order
charles
@code9ja
Aug 27 2017 10:29
I can't seem to pass the over 100's in the instruction
korzo
@korzo
Aug 27 2017 10:29

@code9ja

if (val > 100) { // Change this line
return "Over 100";

have to be first.

Stephen James
@sjames1958gm
Aug 27 2017 10:29
@code9ja So if val is > 100 is it also greater than 10?
charles
@code9ja
Aug 27 2017 10:30

like this ```function testGreaterThan(val) {
if (val > 100) { // Change this line
return "Over 100";
}

if (val > 10) { // Change this line
return "Over 10";
}

return "10 or Under";
}

// Change this value to test
testGreaterThan(150);

Stephen James
@sjames1958gm
Aug 27 2017 10:30
@code9ja You need to order your tests so that the more specific ones are first.
korzo
@korzo
Aug 27 2017 10:30
@code9ja Yes
charles
@code9ja
Aug 27 2017 10:31
Yeeeeaah
but why did it take me so long
Thanks @sjames1958gm
CamperBot
@camperbot
Aug 27 2017 10:31
code9ja sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8397 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
charles
@code9ja
Aug 27 2017 10:32
Thanks @korzo
CamperBot
@camperbot
Aug 27 2017 10:32
code9ja sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 416 | @korzo |http://www.freecodecamp.com/korzo
Stephen James
@sjames1958gm
Aug 27 2017 10:33
@zanisis You can use a string and new RegExp.
var len = 4;
var char = 'g'
var regexS = (${char}{${len}});
var regex = new RexExp(regexS, 'g');
str.replace(regex, '"$1"');
charles
@code9ja
Aug 27 2017 10:33
I have been on this for the past 2 weeks. I have to confess I don't have the logic yet
Adzanny
@zanisis
Aug 27 2017 10:34
@sjames1958gm no i have conditional start with qoqoq,blabla,jejejej i need just select word without coma?.
Stephen James
@sjames1958gm
Aug 27 2017 10:35
@zanisis Maybe you can show example input and output?
Adzanny
@zanisis
Aug 27 2017 10:36
my input = qoqoq,blabla,jejejej
expected output to be = "qoqoq", "blabla", "jejejej"
Vasily Belolapotkov
@vbelolapotkov
Aug 27 2017 10:39
@zanisis I’d approach the task like this:
input.split(‘,’).map(function(str) { return ‘“‘+str+’"’ }).join(‘,’)
korzo
@korzo
Aug 27 2017 10:43
@abhinav-thinktank I clicked clear and then start and the game is gone :(
Adzanny
@zanisis
Aug 27 2017 10:44
@vbelolapotkov no i need find replace on atom with selected qoqoq,blabla,jejejej to be like this "qoqoq", "blabla", "jejejej" with regex
Vasily Belolapotkov
@vbelolapotkov
Aug 27 2017 10:46
@zanisis ah, sry
Adzanny
@zanisis
Aug 27 2017 10:52
@vbelolapotkov it's okay :smile: finaly solve with this ([a-z]+)
Vasily Belolapotkov
@vbelolapotkov
Aug 27 2017 10:53
@zanisis well done ;)
Mak Ki
@Makki419
Aug 27 2017 10:56
hello can anyone here explain me why we use loops with function in javascript
like do/while loops
Tiago Correia
@tiagocorreiaalmeida
Aug 27 2017 11:02
gm everyone
Tiago Correia
@tiagocorreiaalmeida
Aug 27 2017 11:07
image.png
what package can I install just to complete the concepts of this?
@sjames1958gm the work around cloud 9 is work localy right?
Will White
@willnwhite
Aug 27 2017 11:19
@Makki419 I can explain why we use loops. Can you give an example of what you mean by "with function"?
Mak Ki
@Makki419
Aug 27 2017 11:22
@willnwhite
@willnwhite this is the examplevar getToDaChoppa = function(){
// Write your do/while loop here!
do{
console.log("My string condition is " + myString + "!");
}while(myString);
};
myString= false;
getToDaChoppa();
Will White
@willnwhite
Aug 27 2017 11:36
@Makki419 There's no need for a loop there. I guess that's your question. Can you link me to the challenge?
Will White
@willnwhite
Aug 27 2017 11:42
@Makki419 You'd use a loop if you wanted to do that console.log more than once (instead of writing console.log... more than once).
Aimee
@bestAimee
Aug 27 2017 11:52
@korzo what is the specail characters? yes ,it is relative to my application's folder
image.png
koder3
@koder3
Aug 27 2017 12:07
anyone here who has used VScode? i cant seem to use xmlhttprequests to extract information using an API
the same code works in jsfiddle and codepen but in VScode none of the javascript runs
Abhinav Mishra
@abhinav-m
Aug 27 2017 12:09
@koder3 that doesn't appear to be a vscode issue
whats your code
i have made requests using vscode
koder3
@koder3
Aug 27 2017 12:10
ill send screenshots of the code i wrote in VS code is that fine?
Abhinav Mishra
@abhinav-m
Aug 27 2017 12:11
sure.. or you could paste the request code if you want
koder3
@koder3
Aug 27 2017 12:11
image.png
image.png
this is the same code i wrote in this codepen and im getting the results that i expect https://codepen.io/koder3/full/rzKoev/
this is the rest of the js code
image.png
Abhinav Mishra
@abhinav-m
Aug 27 2017 12:14
@koder3 did you try debugging on your local system
your code seems to be correct
heroiczero
@heroiczero
Aug 27 2017 12:14
@koder3 you usually include <link> in the <head> just good practice
Abhinav Mishra
@abhinav-m
Aug 27 2017 12:15
@koder3 script href=?
lol
its script src=
isnt it
Mak Ki
@Makki419
Aug 27 2017 12:16
@willnwhite yes i know the uses of loops but that was just an example the question was why/when we use function with loops in javascript
koder3
@koder3
Aug 27 2017 12:17
@abhinav-thinktank OH WOW! it works now, nice find!!!
Abhinav Mishra
@abhinav-m
Aug 27 2017 12:17
haha, silly mistake, i also make these and then wonder what happened
:\
koder3
@koder3
Aug 27 2017 12:18
@heroiczero oh yeah thanks i meant to do that but i copy pasted the html code from codepen directly into the <body> of the vscode version
CamperBot
@camperbot
Aug 27 2017 12:18
koder3 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1660 | @heroiczero |http://www.freecodecamp.com/heroiczero
koder3
@koder3
Aug 27 2017 12:18
@abhinav-thinktank thanks!!
ive never used script src or linking to a external css file due to the fact i only work on codepen and jsfiddle
Abhinav Mishra
@abhinav-m
Aug 27 2017 12:22
@koder3 aah, i dont recommend that at all
use an ide!
codepen does too much for you
not sure about fiddle
you can always paste the code later onto a pen
koder3
@koder3
Aug 27 2017 12:23
absolutely
Abhinav Mishra
@abhinav-m
Aug 27 2017 12:24
@koder3 :+1:
Abhinav Mishra
@abhinav-m
Aug 27 2017 12:33
Im wondering if i should dive into d3..
is it really popular?
I want to undertand from a market perspective
Will White
@willnwhite
Aug 27 2017 12:40
@Makki419 I can't think of a good example off the top of my head.
Ahmed raza
@Raza403
Aug 27 2017 12:42
Hi I need help for my "Wikipedia viewer", I am trying to get json from wikipedia open search but I am not receiving JSON, Can't figureout whats the problem, Need some help please https://codepen.io/raza403/pen/mMGqML
Tiago Correia
@tiagocorreiaalmeida
Aug 27 2017 12:50
@Raza403 I think the problem is with the link
https://en.wikipedia.org/w/api.php?action=opensearch&search=" + searchTerm + "&format=json&callback=?
try this
change searchteam
for the value you need to search
koder3
@koder3
Aug 27 2017 12:58
is anybody here familiar with handlebars.js
Vasily Belolapotkov
@vbelolapotkov
Aug 27 2017 12:59
@koder3 I have some experience
@koder3 what’s your question?
koder3
@koder3
Aug 27 2017 13:01
@vbelolapotkov what does this mean {{{body}}}
@Raza403 your action is wrong i think
@Raza403 id use query as an action
action in the url i mean
Vasily Belolapotkov
@vbelolapotkov
Aug 27 2017 13:04

@koder3 there is a difference between {{ and {{{. {{ counts html as a string, {{{ - as html.
Here is the short example

<div>{{‘<p>Hello</p>’}}</div> wil render inside div <p>Hello</p> (as text)
{{{‘<p>Hello</p>’}}} wil render paragraph inside div with text Hello

koder3
@koder3
Aug 27 2017 13:04
OpenSearch and simply searching is different
Abhinav Mishra
@abhinav-m
Aug 27 2017 13:05
Somebody who has done the d3 section
koder3
@koder3
Aug 27 2017 13:05
@vbelolapotkov alright thanks, ill look more into it
CamperBot
@camperbot
Aug 27 2017 13:05
:cookie: 261 | @vbelolapotkov |http://www.freecodecamp.com/vbelolapotkov
koder3 sends brownie points to @vbelolapotkov :sparkles: :thumbsup: :sparkles:
Abhinav Mishra
@abhinav-m
Aug 27 2017 13:05
can you point me towards good resources to learn it
Marc
@MWBauer
Aug 27 2017 13:06
MOrning everyone!
Vasily Belolapotkov
@vbelolapotkov
Aug 27 2017 13:06
@koder3 thanks and welcome
CamperBot
@camperbot
Aug 27 2017 13:06
vbelolapotkov sends brownie points to @koder3 :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @koder3 |http://www.freecodecamp.com/koder3
Marc
@MWBauer
Aug 27 2017 13:07
I'm trying to use a regexp inside a replace method and I can't seem to get it to work.
Anyone have a moment to look and set me straight?
koder3
@koder3
Aug 27 2017 13:08
post your code
Marc
@MWBauer
Aug 27 2017 13:09
function titleCase(str) {
  var title = str.replace(/\^/g, function(str.toUpperCase()
  return title;
It's the uppercase part that's bothering me.
No matter how many ) I put in it keeps saying it's expecting one. THERE IS ONE!
there were 5 at one point.
lol
brb
back
Vasily Belolapotkov
@vbelolapotkov
Aug 27 2017 13:16
@MWBauer your code looks strange to me. Have you copied it correctly?
Marc
@MWBauer
Aug 27 2017 13:17
Yes. What doesn't make sense?
Moisés Man
@moigithub
Aug 27 2017 13:17
also brackets (square curly rounded angle) goes in pairs
if uhave 12 open ( u need to have 12 CLOSING )
Marc
@MWBauer
Aug 27 2017 13:17
I agree
I realize that one is missing,
Vasily Belolapotkov
@vbelolapotkov
Aug 27 2017 13:18
I’d say more than one is missing
Marc
@MWBauer
Aug 27 2017 13:18
My earlier statement is that I've had equal opening and closing and it doesn't matter.
Moisés Man
@moigithub
Aug 27 2017 13:18
function name () {...}
or anonymous function ( without name)
function () {...}
Marc
@MWBauer
Aug 27 2017 13:19
function titleCase(str) {
var title = str.replace(/\^/g, function(str.toUpperCase());
return title;
}
Better?
Vasily Belolapotkov
@vbelolapotkov
Aug 27 2017 13:20
function titleCase(str) {
var title = str.replace(/\^/g, function() { return str.toUpperCase()});
return title;
}
anyway It doesn’t look like doing what it have to do
Marc
@MWBauer
Aug 27 2017 13:21
My theory is this.
I want to initialize a var and have the regexp find the first character of each word and replace it with the capital version
If that's too much for one line, let me know.
If I've done it wrong.....(shrug) I guess I need to know.
which is why I'm here.
Marc
@MWBauer
Aug 27 2017 13:23
Yeah. Been there.
Vasily Belolapotkov
@vbelolapotkov
Aug 27 2017 13:23
@MWBauer your regex isn’t correct
Marc
@MWBauer
Aug 27 2017 13:23
what have I done wrong?
Moisés Man
@moigithub
Aug 27 2017 13:24
\^ means search for a character ^
Marc
@MWBauer
Aug 27 2017 13:24
I thought it said that's the beginning of a string.
Abhinav Mishra
@abhinav-m
Aug 27 2017 13:25
IS chart.js an alternative to d3?
which one is better?
Marc
@MWBauer
Aug 27 2017 13:25
excuse me, it says beginning.
Abhinav Mishra
@abhinav-m
Aug 27 2017 13:25
Can someone tell me if learning D3 is worth it as a skill to acquire
Moisés Man
@moigithub
Aug 27 2017 13:26
if u escape.. then it becomes literally a character
but it doesnt work alone..
u can use those links above to test ur regex @MWBauer
Marc
@MWBauer
Aug 27 2017 13:26
And so looking it over I don't know how to look for that.
korzo
@korzo
Aug 27 2017 13:26
@MWBauer \Is escaping character
^ is start of the string
\^ is literal ^
Marc
@MWBauer
Aug 27 2017 13:26
if you take the \ out then it caps everything.
not just the first character
Moisés Man
@moigithub
Aug 27 2017 13:27
/ ^1/ :point_left: means start with 1
Vasily Belolapotkov
@vbelolapotkov
Aug 27 2017 13:27
@MWBauer here is the correct replacement
str.replace(/\b./g, function(substr) { return substr.toUpperCase()});
\b. matches first letter of the word
Marc
@MWBauer
Aug 27 2017 13:28
thank you.
Why b. ?
Vasily Belolapotkov
@vbelolapotkov
Aug 27 2017 13:30
\b is just a word boundary
Stephen James
@sjames1958gm
Aug 27 2017 13:30
@MWBauer \b
Matches a word boundary. This is the position where a word character is not followed or preceded by another word-character, such as between a letter and a space. Note that a matched word boundary is not included in the match. In other words, the length of a matched word boundary is zero.
Vasily Belolapotkov
@vbelolapotkov
Aug 27 2017 13:30
. - any charachter
Marc
@MWBauer
Aug 27 2017 13:39
The I and M in I'm are both capped. How do I not cap the M?
Moisés Man
@moigithub
Aug 27 2017 13:42
cuz the ' (apostrophe) its non a-z character.... it takes m as another word
change ur regex dont use \b
Marc
@MWBauer
Aug 27 2017 13:42
I'm looking on Regexr
Stephen James
@sjames1958gm
Aug 27 2017 13:42
@MWBauer that is a problem with \b you really just want to match start or space followed by letter.
Matej Bošnjak
@mbosnjak01
Aug 27 2017 13:43
Hi people. So ... as I am beggining to learn Angular, just got a quick question. As data binding goes through html ng- attributes or {{}} inside html element ... would it still be a good Javascript practice if I assign that, let's say ng-bind, through element.setAttribute() in plain js?
Pethaf
@Pethaf
Aug 27 2017 13:45
Isn't that violating the Angular framework?
Matej Bošnjak
@mbosnjak01
Aug 27 2017 13:45
I have no idea
I am just starting with angualr so I'm asking ...
Marc
@MWBauer
Aug 27 2017 13:46
Is there a way to do whitespace +1?
Moisés Man
@moigithub
Aug 27 2017 13:46
\s :point_left: spaces
Marc
@MWBauer
Aug 27 2017 13:48
Yes. \s does whitespace. But I don't want the whitespace. I tried a \s+1 and it didn't work.
Is there a different way?
Moisés Man
@moigithub
Aug 27 2017 13:48
remove that +1
Amit Patel
@AmitP88
Aug 27 2017 13:48
hey guys, I'm trying to setup React-Bootstrap on my codepen but it's not working (I keep getting "FormControl is not defined" in the console). What am I doing wrong? https://codepen.io/AmitP88/pen/VzBNqZ
Moisés Man
@moigithub
Aug 27 2017 13:48
+ have a meaning on regex (from 1 to more characters)
1 its literally a character 1
sooo \s+1 means ... at least 1 space or more.. followed by 1 @MWBauer
Stephen James
@sjames1958gm
Aug 27 2017 13:49
@AmitP88 Where are you defining FormControl ?
Marc
@MWBauer
Aug 27 2017 13:50
and \s is a space. How do I get to the character after a space?
Amit Patel
@AmitP88
Aug 27 2017 13:51
@sjames1958gm within my Input component
Stephen James
@sjames1958gm
Aug 27 2017 13:52
@AmitP88 No, that is where you are referencing it, not defining it
Moisés Man
@moigithub
Aug 27 2017 13:52
u can use a dot
. :point_left: means any character on regex @MWBauer
:point_up: August 27, 2017 8:30 AM <---
Stephen James
@sjames1958gm
Aug 27 2017 13:53
@MWBauer You might be able to shorten this.
"this is i'm".replace(/((^ )[a-z]/g, function(m) { return m.toUpperCase() })
Amit Patel
@AmitP88
Aug 27 2017 13:53
@sjames1958gm oh I see, I have to make a component named FormControl? I was following the documentation here: https://react-bootstrap.github.io/components.html#forms and I thought we just had to use the tag for that
Stephen James
@sjames1958gm
Aug 27 2017 13:54
@AmitP88 There might be one that you can import, but not by default
Moisés Man
@moigithub
Aug 27 2017 13:54
missing an OR operator (^| )
n have extra (
Abhinav Mishra
@abhinav-m
Aug 27 2017 13:55
@sjames1958gm have you worked using d3?
Amit Patel
@AmitP88
Aug 27 2017 13:55
@sjames1958gm ah I see. I was thinking of that, but I wasn't sure I still had to import it since I added the source on codepens' settings
Stephen James
@sjames1958gm
Aug 27 2017 13:56
@AmitP88 There maybe something special for FormControl
Amit Patel
@AmitP88
Aug 27 2017 13:56
@sjames1958gm I remember on another project I tried to import react and reactDOM after adding the sources in settings, but someone told me here that since I already added it in settings, that I didnt need to import them. I figure the same principle appled to React-Bootstrap
Stephen James
@sjames1958gm
Aug 27 2017 13:57
@AmitP88 That should be enough, if FormControl is defined there
Amit Patel
@AmitP88
Aug 27 2017 13:57
@sjames1958gm hmmm, looks like I need a controlID on FormGroup. and <ControlLabel>
Stephen James
@sjames1958gm
Aug 27 2017 13:57
@abhinav-thinktank Only to do a couple of the projects
Abhinav Mishra
@abhinav-m
Aug 27 2017 13:57
hmm.. Is it a good skill to acquire?
Moisés Man
@moigithub
Aug 27 2017 13:57
if u working on ur own environment u need to import everything @AmitP88
Stephen James
@sjames1958gm
Aug 27 2017 13:57
@abhinav-thinktank I don't really know
Abhinav Mishra
@abhinav-m
Aug 27 2017 13:58
hmm
i guess ill go through it..
Amit Patel
@AmitP88
Aug 27 2017 13:59
@moigithub I tried that before on another project, importing react and reactDOM after adding those resources in Settings, but it wasn't working. After a guy told me to remove the imports and that they weren't needed since it was already added to settings, it worked. I figured same applied here for react-bootstrap
@moigithub I'll try it though, one sec
Marc
@MWBauer
Aug 27 2017 14:00
@sjames1958gm in your regex you use ^ with a space after. was that on purpose? What does the space do?
Moisés Man
@moigithub
Aug 27 2017 14:00
..probably u are/was on codepen ? @AmitP88 (u mentioning Settings)
Amit Patel
@AmitP88
Aug 27 2017 14:00
@moigithub yeah.
@moigithub yeah, turns out I did have to import it. weird, since I didn't have to import react or reactDOM
Stephen James
@sjames1958gm
Aug 27 2017 14:02
@MWBauer lost the | when I editted it this should be it - match start ^ or space followed by a letter
/(^| )[a-z]/g
Marc
@MWBauer
Aug 27 2017 14:04
Ok. THank you. that worked.
In this challenge they also have as test the first letter lower and everything else capped, so I need to build another statement that reverses this, right?
not so much reverse as just find the first and cap and find the rest and lower.
Maybe run the .toLowerCase that we used a couple of lessons ago and then run the same part that I have now. Maybe not even make a second statement but just start the code with the .toLowerCase and then everything is shrunk and then the first is capped.
Because I am getting better!!!!
Thank you for your help.
Marc
@MWBauer
Aug 27 2017 14:10
Movingon(afterIMakeNotes).roar
Amit Patel
@AmitP88
Aug 27 2017 14:19
hey guys, in ReactJS, why is it that someone uses class extends React.Component and another uses class extends Component? or someone uses export default (component name) vs ReactDOM.render(<component name>, document.getElementById(id))? Sorry, I know it's a dumb question, but whenever I look at coding examples, I always see these variations and wonder why and if one is preferred over the other
Abhinav Mishra
@abhinav-m
Aug 27 2017 14:20
@AmitP88 see the import statement for your first query
for your second query see whats written in the class where the export is used
it will have ReactDOM.render (...) inside.
Amit Patel
@AmitP88
Aug 27 2017 14:22
@abhinav-thinktank sorry, I'm a little confused.
Abhinav Mishra
@abhinav-m
Aug 27 2017 14:22
when you use extends Component
see how React is being imported at the top of that js file
compare it with when you use extends React.Component
Amit Patel
@AmitP88
Aug 27 2017 14:23
oh ok, so when you're importing React on top, you only need to write extends Component and not React.Component?
Abhinav Mishra
@abhinav-m
Aug 27 2017 14:23
no..
when you import {Component} from React
you can use it directly
Marc
@MWBauer
Aug 27 2017 14:24
thanks @sjames1958gm
CamperBot
@camperbot
Aug 27 2017 14:24
mwbauer sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8398 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Abhinav Mishra
@abhinav-m
Aug 27 2017 14:24
otherwise, you will be using import React from 'react' and referencing the module's member as React.Component
this is a question for others..
when we do import {abc} from xyz
are we destructuring the returned object?
Amit Patel
@AmitP88
Aug 27 2017 14:27
i'm not sure. Ugh, I'm lost =( sorry
Amit Patel
@AmitP88
Aug 27 2017 14:27
I'm not that familiar with destructuring
Abhinav Mishra
@abhinav-m
Aug 27 2017 14:28
aah thats fine, was asking others
Amit Patel
@AmitP88
Aug 27 2017 14:28
oh ok
Abhinav Mishra
@abhinav-m
Aug 27 2017 14:28
go through that link for more info
Amit Patel
@AmitP88
Aug 27 2017 14:30
ok. I mean, I understand how importing and exporting works for the components we create, but when it comes to importing other tools with React, I guess I find it confusing when something doesnt work
maybe I should ditch codepen for React projects and just use Sublime Text + Git
especially if I want this on GitHub
Abhinav Mishra
@abhinav-m
Aug 27 2017 14:31
yes... you should ditch codepen for everything other than showing your projects once they're done..
i dont recommend it for actually developing things...
Amit Patel
@AmitP88
Aug 27 2017 14:32
ah ok. yeah, I only started using codepen when I started FCC. When I was doing Udacity we had to show our projects on GitHub. I'll go back to that
Abhinav Mishra
@abhinav-m
Aug 27 2017 14:32
yeah, use an ide and github if you want
Amit Patel
@AmitP88
Aug 27 2017 14:33
@abhinav-thinktank for sure. I need to get used to using the terminal with react anyways. thanks for your help :) I really appreciate it
CamperBot
@camperbot
Aug 27 2017 14:33
amitp88 sends brownie points to @abhinav-thinktank :sparkles: :thumbsup: :sparkles:
:cookie: 532 | @abhinav-thinktank |http://www.freecodecamp.com/abhinav-thinktank
Abhinav Mishra
@abhinav-m
Aug 27 2017 14:33
@AmitP88 :+1:
Stephen James
@sjames1958gm
Aug 27 2017 14:45
@AmitP88 use create react app
Amit Patel
@AmitP88
Aug 27 2017 14:56
@sjames1958gm will do :)
FlashHero
@FlashHero
Aug 27 2017 15:03
what is rebase in git
Stephen James
@sjames1958gm
Aug 27 2017 15:17
@FlashHero The base is the point where the current repository was checked out.
rebase changes that to a new point, often to the new HEAD.
Rimi.
@Codevotee
Aug 27 2017 15:22

can someone tell me why when I do this:

document.getElementsByTagName("tr")[i].innerHTML = "<a class='pageLinks' target='_blank'>" + "<td>" + tdContent + "</td>" + "</a>";

my <a></a> element is closing before the <td> element begins despite that I placed the td tags inside the a element?
image.png

charles
@code9ja
Aug 27 2017 15:41
Hi guys
I am on my challenge 201
comparisons-with-the-logical-or-operator
But I can't figure out my error

my code```function testLogicalOr(val) {
// Only change code below this line

{
return "Outside";
}

if (val < 20 || val > 10) {
return "Outside";
}

// Only change code above this line
return "Inside";
}

// Change this value to test
testLogicalOr(15);```

Stephen James
@sjames1958gm
Aug 27 2017 15:46
@code9ja You need an if before that first return or it will just return Outside always.
Also, what makes a number "Outside", think about it in English first.
Roxroy
@roxroy
Aug 27 2017 15:47
@code9ja , for the outside you are checkin the ends
if (val < 20 || val > 10) its should be greater then 20 OR less then 10. Just flip it and do the inverse to get the correct answer
charles
@code9ja
Aug 27 2017 15:54
@sjames1958gm and @roxroy ok let me try
Tiago Correia
@tiagocorreiaalmeida
Aug 27 2017 16:11
@sjames1958gm give your time just to look into something if its ok? still the same thing from last week was way a few days
will paste the part that bugs me :D
image.png
image.png
now the code so you maybe can help me out
function sequence(statement) {

   // if statement is equal to false then generate a new color and push it to the array otherwise just play the existent sequence and dont create a new color
    if (statement !== true) {
        $(".row-button div").css("pointer-events", "none");
        entrys.push(colors[(Math.floor(Math.random() * 4))]);
    }


    var audio = $("." + entrys[0] + "audio")[0];
    $("." + entrys[0] + "").css("Opacity", "1");
    index = 1;
   console.log(entrys[0]);
    function sound() {
        //if the entrys.length is bigger than one play the second sound and call audio.play to run the function again after it ended
        if (index < entrys.length) {
            $("." + entrys[index] + "").css("Opacity", "1");
            audio = $("." + entrys[index] + "audio")[0];
            audio.play();
            index++;
            console.log(entrys);
          console.log("entrys.length="+entrys.length+" and index = "+index);
        } else {
          console.log("got into else");
          //else return the board to normal state so the user can play
          audio.removeEventListener('ended', sound, false);  
          $(".row-button div").css("Opacity", "0.80");
          $(".row-button div").css("pointer-events", "auto");
        }
    }
    audio.addEventListener('ended', sound);
    audio.play();
}
I call this function everytime I get a sequence right somehow when the first color and second are different it doesnt execut the else statememnt but if all the colors are like blue 20 times it will work the 20 times
its strange
have been on this for a while stoping me from endidng the project, its like the 5 I bother you tbh, sorry
Keon Samuel
@keonsam
Aug 27 2017 16:16
who knows angular 4?
Marc
@MWBauer
Aug 27 2017 16:20
If there are 4 elements in each of 4 arrays that make up 1 big array, I just need one nested For loop to iterate thru them all, right?
Keon Samuel
@keonsam
Aug 27 2017 16:22
use forEach
Marc
@MWBauer
Aug 27 2017 16:24
forEach (i=0... ?
Keon Samuel
@keonsam
Aug 27 2017 16:24
array.forEach(()=>{});
Marc
@MWBauer
Aug 27 2017 16:25
thanks @keonsam
CamperBot
@camperbot
Aug 27 2017 16:25
mwbauer sends brownie points to @keonsam :sparkles: :thumbsup: :sparkles:
:cookie: 413 | @keonsam |http://www.freecodecamp.com/keonsam
charles
@code9ja
Aug 27 2017 16:28
@sjames1958gm my code is still not passing. where should I write the if before the return

```function testLogicalOr(val) {
// Only change code below this line

if (val) {
return "Outside";
}

if (val < 10 || val > 20) {
return "Outside";
}

// Only change code above this line
return "Inside";
}

// Change this value to test
testLogicalOr(15);```

Marc
@MWBauer
Aug 27 2017 16:40
arr.forEach(function callback(currentValue, index, array) {
    //your iterator
}[, thisArg]);
Stephen James
@sjames1958gm
Aug 27 2017 16:40
if (val) will be true for any value not zero -
The instuctions say combine the two ifs into one
So there should only be one if
When you have troubles re-read the instructions again and again so you are not missing something
Keon Samuel
@keonsam
Aug 27 2017 16:40
first if
Marc
@MWBauer
Aug 27 2017 16:41
In trying to set this up, do we use the same setup as a For loop. i = 0, i < arr.length, big //myarray
Stephen James
@sjames1958gm
Aug 27 2017 16:43
@tiagocorreiaalmeida You never move the "ended" listener to the new element.
inside the if before the audio =
audio.removeEventListener('ended', sound, false);
then after the audio =
audio.addEventListener('ended', sound);
Keon Samuel
@keonsam
Aug 27 2017 16:43
the callback will equal a next array value
Tiago Correia
@tiagocorreiaalmeida
Aug 27 2017 16:44
  if (index < entrys.length) {
            $("." + entrys[index] + "").css("Opacity", "1");
            audio.removeEventListener('ended', sound, false);
            audio = $("." + entrys[index] + "audio")[0];
            audio.play();
            audio.addEventListener('ended', sound);
            index++;
            console.log(entrys);
          console.log("entrys.length="+entrys.length+" and index = "+index);
        }
like this mate?
or I got it wrong
charles
@code9ja
Aug 27 2017 16:45
CAn any one help
Stephen James
@sjames1958gm
Aug 27 2017 16:45
Yes, maybe move the addEventListener above the play() not sure it matters
Keon Samuel
@keonsam
Aug 27 2017 16:45
looks good
your first if will always end the function.
Stephen James
@sjames1958gm
Aug 27 2017 16:46
@code9ja I posted above
11:40
if (val) will be true for any value not zero -
The instuctions say combine the two ifs into one
So there should only be one if
When you have troubles re-read the instructions again and again so you are not missing something
Tiago Correia
@tiagocorreiaalmeida
Aug 27 2017 16:47
@sjames1958gm thanks man arrrrrr fianlly
CamperBot
@camperbot
Aug 27 2017 16:47
tiagocorreiaalmeida sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8399 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
charles
@code9ja
Aug 27 2017 16:47
@sjames1958gm oh really I will check
@sjames1958gm but you say I need an if before the return outside
Marc
@MWBauer
Aug 27 2017 16:50
@sjames1958gm I started my forEach loop:
big.forEach(function(big) {
big is my array
Stephen James
@sjames1958gm
Aug 27 2017 16:51
@code9ja I didn't realize the challenge said combine the two ifs, I had to go re-read the challenge.
Marc
@MWBauer
Aug 27 2017 16:51
how do I catch the iterations? big[i]?
charles
@code9ja
Aug 27 2017 16:51
@sjames1958gm oh ok
Stephen James
@sjames1958gm
Aug 27 2017 16:51
@MWBauer THe first parameter to the function will be each element of big in turn
charles
@code9ja
Aug 27 2017 16:51
but I am still not passing the inside
Stephen James
@sjames1958gm
Aug 27 2017 16:52
@code9ja You should have one if
if (val < 10 || val > 20) {
charles
@code9ja
Aug 27 2017 16:54
@sjames1958gm that returns outside
Marc
@MWBauer
Aug 27 2017 16:57
function largestOfFour(arr) {
  var big = 0;
  arr.forEach(function(arr) {

  }  
  } return big;
Is that the correct way to start the forEach?
big is a variable to allow comparisons
Stephen James
@sjames1958gm
Aug 27 2017 16:57
@MWBauer arr.forEach(function(elem) {});
charles
@code9ja
Aug 27 2017 16:59

```function testLogicalOr(val) {
// Only change code below this line

{
return "Outside";
}

if (val < 10 || val > 20) {
return "Outside";
}

// Only change code above this line
return "Inside";
}

// Change this value to test
testLogicalOr(15);```

Marc
@MWBauer
Aug 27 2017 17:00
var items = ['item1', 'item2', 'item3'];
var copy = [];

items.forEach(function(item){
  copy.push(item)
});
Moisés Man
@moigithub
Aug 27 2017 17:00
ur code ALWAYS returning "Outside"
cuz thats the first statement it find /execute
@code9ja
Marc
@MWBauer
Aug 27 2017 17:01
In this example, it takes the items array and puts it in a forEach loop, using a function that references item?
Moisés Man
@moigithub
Aug 27 2017 17:02
forEach "picks" EACH element one by one.. and pass it to the inner function @MWBauer
Marc
@MWBauer
Aug 27 2017 17:02
Right. That's what I understand. I'm just trying to figure out the syntax.
item is the item in the array, the element?
Moisés Man
@moigithub
Aug 27 2017 17:02
yep
Marc
@MWBauer
Aug 27 2017 17:03
Ok, so if there are only numbers, how do I reference the numbers?
Moisés Man
@moigithub
Aug 27 2017 17:03
same way
Marc
@MWBauer
Aug 27 2017 17:03
arr.forEach(function(20) { ??
wouldn't it just work on each 20 it comes across?
Moisés Man
@moigithub
Aug 27 2017 17:04
var items = [11, 22, 333];

items.forEach( function (aNumber) {
    // do something with aNumber
});
whatever varaible name u use inside the inner function.. refer to a single ELEMENT on the array
charles
@code9ja
Aug 27 2017 17:05
@moigithub now its just returning inside. How do I pass all
Moisés Man
@moigithub
Aug 27 2017 17:08
what code u have now ??
from ur code above u should remove the first return instruction ONLY @code9ja
function testLogicalOr(val) {

{
return "Outside";  /////////////////////////////REMOVE THIS
}
if (val < 10 || val > 20) {
return "Outside";
}

return "Inside";
}

testLogicalOr(15);
charles
@code9ja
Aug 27 2017 17:10
@moigithub let me try
Marc
@MWBauer
Aug 27 2017 17:10
that first return is going to stop the whole code.
charles
@code9ja
Aug 27 2017 17:13
@moigithub not working
Stephen James
@sjames1958gm
Aug 27 2017 17:16
@code9ja - this is all the code in your function
if (val < 10 || val > 20) {
return "Outside";
}

return "Inside";
charles
@code9ja
Aug 27 2017 17:18

```if (val < 10 || val > 20) {
return "Outside";
}

// Only change code above this line
return "inside";```

same here didn't take me thru
Stephen James
@sjames1958gm
Aug 27 2017 17:19

@code9ja

function testLogicalOr(val) {
if (val < 10 || val > 20) {
return "Outside";
}

return "Inside";
}

this passes

charles
@code9ja
Aug 27 2017 17:20
@sjames1958gm isn't that the same thing I've got
Guderian Raborg
@hypercuber
Aug 27 2017 17:22
Why does the pointLight doesnt work when I move cube at (0, 0, 0)?
https://codepen.io/hypercuber/pen/XaPwjy
Tiago Correia
@tiagocorreiaalmeida
Aug 27 2017 17:25
@sjames1958gm how do I pm someone who is offline right now?
charles
@code9ja
Aug 27 2017 17:26
Please someone advice me, I am on challenge 201 and I feel like I don't know anything in front end is there any building project I can use to hone my skills
Stephen James
@sjames1958gm
Aug 27 2017 17:27
@code9ja I guess I copied it from here to there.
@code9ja Maybe get on codewars to get practice with code and algorithms
charles
@code9ja
Aug 27 2017 17:28
@sjames1958gm what about building projects
any advice
Stephen James
@sjames1958gm
Aug 27 2017 17:29
@code9ja There are projects in the Map, have you done the portfolio?
charles
@code9ja
Aug 27 2017 17:31
@sjames1958gm I couldn't start the portfolio. I felt I need to practice more challenges to be able to handle it
Stephen James
@sjames1958gm
Aug 27 2017 17:32
@code9ja The early projects don't require javascript.
@hypercuber I think you are moving the cube, either over the point light or behind it.
Guderian Raborg
@hypercuber
Aug 27 2017 17:48
@sjames1958gm Let me check. Also, PerspectiveCamera is set from 0.1 to 3000 so I might need to change that too. Thanks anyways.
CamperBot
@camperbot
Aug 27 2017 17:48
hypercuber sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8400 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Guderian Raborg
@hypercuber
Aug 27 2017 18:08
I still havent figure it out...
Keon Samuel
@keonsam
Aug 27 2017 18:16
@sjames1958gm should I learn angular 4 or is it a waste of time?
Gustavo Azevedo
@gustavoaz7
Aug 27 2017 18:32
I'm working on my Quote Machine and I'm facing a problem on my AJAX request
This is the API i'm aiming for API
(the key in the URL is for testing, just to match the website exemple)
var btn = document.getElementById("btn"); btn.addEventListener("click", function(){ var myRequest = new XMLHttpRequest(); myRequest.open("GET", "http://api.forismatic.com/api/1.0/method=getQuote&key=457653&format=xml&lang=en"); console.log(myRequest) myRequest.onload = function() { var myData = JSON.parse(myRequest.responseText);
The console.log shows that I am not getting the response I was supposed to.
What am I missing here ?
Just for better visualization
var btn = document.getElementById("btn");
btn.addEventListener("click", function(){
  var myRequest = new XMLHttpRequest();
  myRequest.open("GET", "http://api.forismatic.com/api/1.0/method=getQuote&key=457653&format=xml&lang=en");
  console.log(myRequest)
  myRequest.onload = function() {
    var myData = JSON.parse(myRequest.responseText);
Christopher McCormack
@cmccormack
Aug 27 2017 18:37
@gustavoaz7 what response are you getting?
and why not use json as your format instead of xml?
Gustavo Azevedo
@gustavoaz7
Aug 27 2017 18:40
None.
I have an 'empty' XMLHttpRequest object. Just like I would if I have consoled.log after creating the object
It's xml for now just to match the website example
Christopher McCormack
@cmccormack
Aug 27 2017 18:43
you're trying to log the XMLHttpRequest try logging in onload
Also I think you need to send at one point, but haven't used XMLHttpRequest much as there are much simpler ways to do it now
Stephen James
@sjames1958gm
Aug 27 2017 18:45
@keonsam depends on your goals. It is probably not a complete waste of time because they are using some more modern techniques such as observables.
Gustavo Azevedo
@gustavoaz7
Aug 27 2017 18:57
@cmccormack onload returns null . And I do send it later. I just focused on a different part of the code here
Christopher McCormack
@cmccormack
Aug 27 2017 19:00
@gustavoaz7 you would do it within your onload callback
Are you getting that far, where you can see a logged message in your onload callback?
FlashHero
@FlashHero
Aug 27 2017 19:09
@sjames1958gm ok thanks
CamperBot
@camperbot
Aug 27 2017 19:09
flashhero sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8401 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Tiago Correia
@tiagocorreiaalmeida
Aug 27 2017 19:10
@sjames1958gm you used c9 on backend?
Bryan Reese
@breese8009
Aug 27 2017 19:13
https://codepen.io/brJitsu85/pen/RZYzZx how do i get the audio to play? says play() isnt defined but it is...
Gustavo Azevedo
@gustavoaz7
Aug 27 2017 19:14
@cmccormack Nothing is logged when called from within the onload callback
Christopher McCormack
@cmccormack
Aug 27 2017 19:15
@breese8009 i don't see an audio element or id in your html
Bryan Reese
@breese8009
Aug 27 2017 19:16
@cmccormack its appended in JS
Gustavo Azevedo
@gustavoaz7
Aug 27 2017 19:16
@breese8009 you are probably overwritting javascript engine play() function
Bryan Reese
@breese8009
Aug 27 2017 19:16
    $('#results').append(`
                    <h2>${el.artists[0].name}</h2>
                    <h5>${el.name}</h5>
                    <img class="artistImg" src="${el.album.images[0].url}">
                <input type="button" value="PLAY"  onclick="() => {play()}">
                    <audio id="audio" src="${el.preview_url}" ></audio>
                    `);
Christopher McCormack
@cmccormack
Aug 27 2017 19:16
@gustavoaz7 so if you aren't getting that far you need to troubleshoot what issue is preventing it from loading
@breese8009 you appear to be trying to play something before you've even created it
ah nevermind, you should really fix your spacing
Try moving your play function outside your ajax call
Christopher McCormack
@cmccormack
Aug 27 2017 19:22
@gustavoaz7 play function should be different than the play method attached to the audio element but it never hurts to use different naming
Morchid Chellali
@Morched23MJ
Aug 27 2017 19:32
I want to fix position of the two h1 in my Pomodoro project, because when the timer starts they keep moving, and thus the icon between them moves too. I set position to absolute but they collapse when the screen gets smaller.
Here is the pen: https://codepen.io/Morched23MJ/pen/PKeQYQ
I know I could use media queries to fix it when the screen gets smaller, but I would see if there is a better way to do it.
Bryan Reese
@breese8009
Aug 27 2017 19:51
@cmccormack i had to move it out side everything an at the very bottom of the JS..... but now its playing the same song :(
Tiago Correia
@tiagocorreiaalmeida
Aug 27 2017 21:07
@icharlie2 I based a bit on your pen to build my simon game board hope its ok was getting confused about the design thing if not let me know will change it by board I mena only the big circle and 4 colors position
Charlie Pham
@icharlie2
Aug 27 2017 21:13
@tiagocorreiaalmeida Mine was based off the example they gave so no worries
Manuel
@manny45
Aug 27 2017 21:23
if (val < 10 || val > 20) {
    return "Outside";
  }

  // Only change code above this line
  return "Inside";
}
what's wrong
Tiago Correia
@tiagocorreiaalmeida
Aug 27 2017 21:23
@icharlie2 are you ok with css?
Elizabeth Paul
@Kowalatam
Aug 27 2017 21:27
@manny45 what are u trying to achieve ? if 11 should return inside and 4 return outside ?
Manuel
@manny45
Aug 27 2017 21:28
Combine the two if statements into one statement which returns "Outside" if val is not between 10 and 20, inclusive. Otherwise, return "Inside".
@Kowalatam
Elizabeth Paul
@Kowalatam
Aug 27 2017 21:36
@manny45 its in a function right ?. cus if so.. it works .. except if i don't understand what u mean
@manny45 u want 10 to be outside ?
Tai Jones
@taiJones00
Aug 27 2017 21:40

function convertToRoman(num) {
if (num.length == 2)
{
num = "hi";

}

return num;
}

convertToRoman(36);

Why doesn't this return "hi"?
eeflores
@eeflores
Aug 27 2017 21:45
num.length assumes that num is an array
or string
you could convertToRoman("36") and it would give you the behaviour you're looking for
Elizabeth Paul
@Kowalatam
Aug 27 2017 21:46

if yes .. use <= >=

@manny45 u want 10 to be outside ?

@manny45
Tai Jones
@taiJones00
Aug 27 2017 21:47
Okay so .length doesn't apply to numbers
eeflores
@eeflores
Aug 27 2017 21:48
@taiJones00 yep that's correct
I think
Tai Jones
@taiJones00
Aug 27 2017 21:48
Seems that way. Thank you @eeflores
CamperBot
@camperbot
Aug 27 2017 21:48
taijones00 sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star2: 1013 | @eeflores |http://www.freecodecamp.com/eeflores
Charlie Pham
@icharlie2
Aug 27 2017 22:18
@tiagocorreiaalmeida yes why
Sarah F-K
@sfarnsworthkum
Aug 27 2017 22:35

hey y'all - best approach for adding commas to integers

addCommas(123456789) // "123,456,789"

without using .toLocaleString? I'm having issues with it cutting off the number of integers after the decimal. thanks in advance!

Margaret
@Margaret2
Aug 27 2017 22:36
@sfarnsworthkum why can't you just do .toString ?
Sarah F-K
@sfarnsworthkum
Aug 27 2017 22:38
@Margaret2 i could do that, I guess I'm just blanking on the best approach to add a comma after three ints
slice it?
Margaret
@Margaret2
Aug 27 2017 22:39
mdn says you can set the minimum number of sign. digits or the minimum number of digits after the decimal, maybe that would solve your issue
Sarah F-K
@sfarnsworthkum
Aug 27 2017 22:40
oh that should do it- thanks @Margaret2
CamperBot
@camperbot
Aug 27 2017 22:40
sfarnsworthkum sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 2899 | @margaret2 |http://www.freecodecamp.com/margaret2
Sarah F-K
@sfarnsworthkum
Aug 27 2017 22:42
sweet!