These are chat archives for FreeCodeCamp/HelpJavaScript

20th
Aug 2017
FlashHero
@FlashHero
Aug 20 2017 00:10
nodejs question how do you access the user's email in the file that has the mongoose schema
Peter Weinberg
@no-stack-dub-sack
Aug 20 2017 00:53
anyone around to answer a quick question? Doesn't require any particular coding expertise, though it is a coding question, more of a sanity check to make sure I'm not crazy :scream:
Ruchika Sharma
@ruchika90
Aug 20 2017 00:55
@Manish-Giri thx I passed the challenge
CamperBot
@camperbot
Aug 20 2017 00:55
ruchika90 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6441 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ken Haduch
@khaduch
Aug 20 2017 01:49
@no-stack-dub-sack - you can ask and see if we can answer... ;)
Peter Weinberg
@no-stack-dub-sack
Aug 20 2017 01:57
@khaduch Thanks! I already got it though. Kinda anyway... I at least figured out where I was going wrong
CamperBot
@camperbot
Aug 20 2017 01:57
no-stack-dub-sack sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3221 | @khaduch |http://www.freecodecamp.com/khaduch
Peter Weinberg
@no-stack-dub-sack
Aug 20 2017 01:58
Misinterpreting leetcode instructions (which are terrible by the way)
Ken Haduch
@khaduch
Aug 20 2017 01:58
@no-stack-dub-sack - okay, great! I've never heard of leetcode - that looks interesting.
marcus dylan johnson
@mdjohns
Aug 20 2017 03:32
Trying to work out my thought process on the Title Case algorithm challenge (take a string and capitalize the first letter of each word). I know that I have to str.toLowerCase().split(‘ ‘). But after that I’m a little fuzzy. The hints say use string.prototype.replace() but MDN is confusing the hell out of me. Use RegEx to turn the first lowercase letter following a whitespace to uppercase?
I feel like I’m gravitating to RegEx too much and that might not be the solution
Manish Giri
@Manish-Giri
Aug 20 2017 04:02
@djohnson501 try to think in terms of a loop..
marcus dylan johnson
@mdjohns
Aug 20 2017 04:03
@Manish-Giri in combination with replace? like a for loop to iterate through the array?
Manish Giri
@Manish-Giri
Aug 20 2017 04:04
if this is your sentence - "hello world" -
  1. split it into an array -
  2. you grab the first word - hello - turn h into uppercase, combine it with the rest of the letters (h + ello) and put this title cased word back in it's place in the array
  3. grab the next word - world - uppercase w and combine with the rest - W + orld, put it back
  4. repeat for all the words in the array
  5. join the array into a string
@djohnson501 here's some pseudocode
Adnan Karšić
@adokce
Aug 20 2017 04:06
hey guys
someone there to give me hint?

function rot13(str) {
    var fn = function(val){
      var newVal = 0;
      newVal = (val<77) ? val+13 : val-13;
      return newVal;

    };
    var newStr = str.split();
    var blaStr = newStr.map(function(x){
      return String.fromCharCode(fn(x.charCodeAt(0)));
    }).join();
  return blaStr;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
the output is just one character
it should be whole string
it's something regarding .map i suppose
Manish Giri
@Manish-Giri
Aug 20 2017 04:09
@adokce .join();
usually takes a parameter that says how to join
like .split()
Adnan Karšić
@adokce
Aug 20 2017 04:11
@Manish-Giri it's not working
i tried adding "" as parameters
and other stuff
no change
Manish Giri
@Manish-Giri
Aug 20 2017 04:14
@adokce var newStr = str.split();
split on space here
Adnan Karšić
@adokce
Aug 20 2017 04:18
it seems to help
@Manish-Giri thanks
CamperBot
@camperbot
Aug 20 2017 04:18
adokce sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6444 | @manish-giri |http://www.freecodecamp.com/manish-giri
marcus dylan johnson
@mdjohns
Aug 20 2017 04:30
@Manish-Giri
function titleCase(str) {
  var splitStr = str.toLowerCase().split(' ');
  for(var i = 0; i < splitStr.length; i++){
      return splitStr[i].charAt().toUpperCase();
  }
}

console.log(titleCase("I'm a little tea pot"));
Still trying. This is only returning the first letter, but seems to be capitalizing as needed. On the right track?
Manish Giri
@Manish-Giri
Aug 20 2017 04:32
yes
need to fix a couple of things
First - return terminates the function right away, so here - return splitStr[i].charAt().toUpperCase(); - you never get past i = 0 iteration

if this is your sentence - "hello world" -

  1. split it into an array -
  2. you grab the first word - hello - turn h into uppercase, combine it with the rest of the letters (h + ello) and put this title cased word back in it's place in the array
  3. grab the next word - world - uppercase w and combine with the rest - W + orld, put it back
  4. repeat for all the words in the array
  5. join the array into a string

in here, you only return after step 5, not before

marcus dylan johnson
@mdjohns
Aug 20 2017 04:35
Gotcha. So the for loop should end with splitStr.join(“ “);
But I need to figure out what goes in between haha
Ogundele Olumide
@Lumexralph
Aug 20 2017 04:36
@Manish-Giri sggggggm :imp:
Ogundele Olumide
@Lumexralph
Aug 20 2017 04:48
@Manish-Giri messaged you
intcreate
@intcreate
Aug 20 2017 05:11

Why is the element not changing to display: block?

var box = document.getElementsByClassName("12")[0].style.display ="block";

When I console.log(box) // block
It says block.

intcreate
@intcreate
Aug 20 2017 05:20
oh its because I cannot use numbers as classname
Does anyone know how can i use a number as a class name?
Ayush Bahuguna
@relentless-coder
Aug 20 2017 05:24
@intcreate id and class cannot start with a number
Roxroy
@roxroy
Aug 20 2017 05:24
@intcreate , you can use the description of the number,
.one {color: blue;} .two {color: red;}
in your html use class="one" or class="two" to apply the specific class.
@intcreate , Basically, a name must begin with an underscore (_), a hyphen (-), or a letter(a–z), followed by any number of hyphens, underscores, letters, or numbers.
Ayush Bahuguna
@relentless-coder
Aug 20 2017 05:26
@djohnson501 you need to replace each array element eg, hello with H + ello
@djohnson501 so what you can do is splitStr[i] = splitStr[i].split('')[0].toUpperCase() + splitStr[i].substr(1)
glitz20
@glitz20
Aug 20 2017 05:33
hey guys anyone who can look at my glitch project and let me know why configure.js is not working? https://glitch.com/edit/#!/grave-sushi?path=server/configure.js:1:0
Ayush Bahuguna
@relentless-coder
Aug 20 2017 05:34
@djohnson501 what I did here is that first I pulled out the first letter of the str, converted it to uppercase then joined it with the rest of the string with the help of substr method giving it the index of 1 which means starting from the next letter from the start
Eric Hasegawa
@EricHasegawa
Aug 20 2017 05:35
@EricHasegawa
https://codepen.io/erichasegawa/pen/brdYKd
Can anyone tell me why my onload function doesn't hide the 2 temp. buttons?
Ayush Bahuguna
@relentless-coder
Aug 20 2017 05:36
@EricHasegawa typo my friend. your function is hidebuttons not hideButtons
@EricHasegawa you could have easily figured it out if you've checked your console
Eric Hasegawa
@EricHasegawa
Aug 20 2017 05:38
@relentless-coder I always forget to do that, thanks though
CamperBot
@camperbot
Aug 20 2017 05:38
erichasegawa sends brownie points to @relentless-coder :sparkles: :thumbsup: :sparkles:
:cookie: 372 | @relentless-coder |http://www.freecodecamp.com/relentless-coder
Ayush Bahuguna
@relentless-coder
Aug 20 2017 05:40
@sabin20 could you explain more? What about it?
glitz20
@glitz20
Aug 20 2017 05:42
@relentless-coder so my configure.js file is not working, which is a part of server.
Ayush Bahuguna
@relentless-coder
Aug 20 2017 05:45
@sabin20 did you try running it? I am not familiar with glitch's environment. You need to tell what isn't working, what are the errors.
glitz20
@glitz20
Aug 20 2017 05:47
yeah, so it is basically part of server, it is not accepting connect middleware maybe
Ayush Bahuguna
@relentless-coder
Aug 20 2017 05:48
@sabin20 are you sure about app.Router?
glitz20
@glitz20
Aug 20 2017 05:48
@relentless-coder yeah everything else is fine. It has to do with connect
Ayush Bahuguna
@relentless-coder
Aug 20 2017 05:49
but how could app.Router be fine? It's undefined
or let me check again
intcreate
@intcreate
Aug 20 2017 05:52
so far am I doing this right? I am adding event listener to all buttons
       var button = document.getElementsByTagName('button');
       button.forEach(function(button) {
         button.addEventListener('')  
       })
Rohit Yadav
@rohyadav
Aug 20 2017 05:57
how do i add balance in this objects inside of array
{
  "clients": [
    {
  "firstName": "xxx",
  "lastName": "yyy",
  "gender": "Male",
  "balance": "100.00",
  "email": "xxx@gmail.com",
  "phone": "+1-78555 55555",
  "address": "Room-8, 886 street,"
},
     {
  "firstName": "oka",
  "lastName": "achi",
  "gender": "Male",
  "balance": "200.00",
  "email": "oka@gmail.com",
  "phone": "+1-78555 55555",
  "address": "Room-16, 886 street"
}
  ]
}
in es6
Ayush Bahuguna
@relentless-coder
Aug 20 2017 05:57
@sabin20 Router is a callable function on the express object, when you create an application with express() just creates an application. You still need to call the Router separately as a method on express object to use it
Rohit Yadav
@rohyadav
Aug 20 2017 05:59
getTotalOwed () {
    let total = 0;
    for (let i = 0; i < this.c_clients.length; i++) {
       total += parseFloat(this.c_clients[i].balance);
        console.log(this.c_clients[i].balance);
    }
}
    this.totalOwed = total;
    console.log(this.totalOwed);
  }
i tried but not getting
Ayush Bahuguna
@relentless-coder
Aug 20 2017 06:00
@sabin20 app.router would have worked in the previous versions, but it is deprecated in express 4.0
@intcreate what is the event?
glitz20
@glitz20
Aug 20 2017 06:02
@relentless-coder ok got it. Do you have any free resources on latest express and mongoDB?
Ayush Bahuguna
@relentless-coder
Aug 20 2017 06:03
@sabin20 I find their official docs to be sufficient, for advanced stuff, you'd have to consider books or online courses
@sabin20 how do you test your code on glitch?
glitz20
@glitz20
Aug 20 2017 06:04
I look at console and try to figure it out
I am also new to it
Ayush Bahuguna
@relentless-coder
Aug 20 2017 06:05
you should use your local text editor and run your code. I am pretty sure that you'd have got the error on your node console, if you'd have run this code. Because I got the deprecation error for app.router
also, it is fun to console.log(express) amd console.log(express()) to check what is happening, and it's not scary.
@sabin20
Bashir Harrell
@bookofbash
Aug 20 2017 06:06
I am on intermediate algorithm scripting, Wow these are so much harder
Does anyone know of a good primer, to get my mind more flexible? It is hard to see where to study.
Ayush Bahuguna
@relentless-coder
Aug 20 2017 06:07
@sabin20 I think glitch does let you run your code.
@bookofbash what is a primer?
Bashir Harrell
@bookofbash
Aug 20 2017 06:08
Something to get me warmed up
Ayush Bahuguna
@relentless-coder
Aug 20 2017 06:08
codewars
@bookofbash
Bashir Harrell
@bookofbash
Aug 20 2017 06:08
Good, idea
@relentless-coder I feel like im all out of it now. Maybe it is supposed to be this hard though
Ayush Bahuguna
@relentless-coder
Aug 20 2017 06:10
sometimes taking a break and staying away from it helps.
@bookofbash
Praful-cs
@Praful-cs
Aug 20 2017 07:08
How to stop ongoing song in Howler js??
WickedDogg
@WickedDogg
Aug 20 2017 07:37
Leetcode
Brett Burtson
@bburtson
Aug 20 2017 07:37
Any body need help?
LiciniusRex
@hashtagyolo1
Aug 20 2017 07:50
yes
I can't work out why this doesn't work
var answer = [];
function rot13(str) { // LBH QVQ VG!
  for (var i = 0; i < str.length ; i++){
    if (str[i].charCodeAt() < 65 || str[i].charCodeAt() > 90){
      answer.push(String.fromCharCode((str[i].charCodeAt())));  
    } else if (str[i].charCodeAt() > 77 && str[i].charCodeAt() <92){
    answer.push(String.fromCharCode((str[i].charCodeAt() - 13)));
  } else if (str[i].charCodeAt() < 78 && str[i].charCodeAt() > 65){
             answer.push(String.fromCharCode((str[i].charCodeAt() + 13)));
             }

}     var almostThere = answer.toString();
return almostThere.replace(/,/g, '');
}
// Change the inputs below to test
rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.");
It returns the correct answer, but FCC is saying it's wrong. Not sure what I'm missing
Ghulam Shabir
@ghulamshabir
Aug 20 2017 07:52
@hashtagyolo1 answer array is global which confuses fcc, make it local
Brett Burtson
@bburtson
Aug 20 2017 07:53
@hashtagyolo1 if your still hung up give me the challenge name il check it out
LiciniusRex
@hashtagyolo1
Aug 20 2017 07:54
thanks @ghulamshabir , not sure how to rejig so it works now though
CamperBot
@camperbot
Aug 20 2017 07:54
hashtagyolo1 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1928 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Aug 20 2017 07:54
@hashtagyolo1 :smile:
Brett Burtson
@bburtson
Aug 20 2017 07:54
Nice keep rockin man.
a little disheartening, when something like that happens but.. its all worth it right?
LiciniusRex
@hashtagyolo1
Aug 20 2017 08:02
Somewhay annoying to be honest. I have the answer but FCC decides my code formatted hot it likes it. At least I know for the future now
beginner algorithms done though. Huge thanks to all the people here that have helped me
Ghulam Shabir
@ghulamshabir
Aug 20 2017 08:05
@hashtagyolo1 fcc calls your function multiple times and global variables retain previous state hence problems in final output, it's good programming practice to prefer local variables over globles, you are forced to do it by fcc though unintentionaly
LiciniusRex
@hashtagyolo1
Aug 20 2017 08:07
@ghulamshabir I'll bear it in mind for future. If it's best practice it's good for me to be forced to learn it now so it becomes second nature
I suppose the idea is that you should be calling function rather than global variables
functions*
Ghulam Shabir
@ghulamshabir
Aug 20 2017 08:09
you can edit your messages within 10 minutes by clicking three dots near time at right side of your message
or pressing up arrow for last message
LiciniusRex
@hashtagyolo1
Aug 20 2017 08:15
I did not know that, thanks @ghulamshabir
CamperBot
@camperbot
Aug 20 2017 08:15
hashtagyolo1 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:warning: hashtagyolo1 already gave ghulamshabir points
Rohit Yadav
@rohyadav
Aug 20 2017 08:53
{
  "clients": [
    {
      "firstName": "Rohit",
      "lastName": "Yadav",
      "gender": "Male",
      "balance": "100.00",
      "email": "rohityadav@gmail.com",
      "phone": "+91-78555 55555",
      "address": "Room-8, 886 street, Gurgaon, harayana - 122002"
    },
    {
      "firstName": "Inder",
      "lastName": "Mahiwal",
      "gender": "Male",
      "balance": "200.00",
      "email": "indermahi@gmail.com",
      "phone": "+91-78555 55555",
      "address": "Room-16, 886 street, Gurgaon, harayana - 122002"
    }
  ]
}
how do i access property balance
?
Morchid Chellali
@Morched23MJ
Aug 20 2017 08:54
I want to empty a calculator output field after the user presses any button after pressing the = button, I have a string 'operation' that collects the clicks of the buttons, after that I use eval(). Any idea how to empty the output after the press of any button, after the user gets the result of the previous operation? I tried this, but doesn't work properly:
$('#output h2').empty().append(eval(operation.replace('=','')));
  operation = '';
Brett Burtson
@bburtson
Aug 20 2017 08:54
```var clientObject =
Morchid Chellali
@Morched23MJ
Aug 20 2017 08:54
Eh, not that. This:
if (operation == '') {
    $('button').one('click', clear);
  }
Jim Tryon
@jimtryon
Aug 20 2017 08:55
@Morched23MJ I would call .empty() on the element you want to clear
Morchid Chellali
@Morched23MJ
Aug 20 2017 08:55
I did that, but I don't want just that
Brett Burtson
@bburtson
Aug 20 2017 08:55
var clientObject  = fromsomewhere;

clientObject["clients"][0]["balance"]
Rohit Yadav
@rohyadav
Aug 20 2017 08:55
@bburtson can you plz help me out
Morchid Chellali
@Morched23MJ
Aug 20 2017 08:56
After I press = to get a result of an operation, then, once I want to do another operation, means I click on a button, I want to clear directly, I don't want the user to click on clear every time he wants to perform an operation.
Brett Burtson
@bburtson
Aug 20 2017 08:56
@rohyadav I can try
Rohit Yadav
@rohyadav
Aug 20 2017 08:56
@bburtson yeah .. thanks
CamperBot
@camperbot
Aug 20 2017 08:56
rohyadav sends brownie points to @bburtson :sparkles: :thumbsup: :sparkles:
:cookie: 301 | @bburtson |http://www.freecodecamp.com/bburtson
Brett Burtson
@bburtson
Aug 20 2017 08:59
sorry I'm flip flopping channels
@rohyadav whatsup what you got going on partner
Rohit Yadav
@rohyadav
Aug 20 2017 09:00
@bburtson i did not get it?
heroiczero
@heroiczero
Aug 20 2017 09:00
@Morched23MJ could i see your codepen for your calculator
Brett Burtson
@bburtson
Aug 20 2017 09:04
@rohyadav sorry I'm here somone had me watch a wordpress video
heroiczero
@heroiczero
Aug 20 2017 09:04
@Morched23MJ you can keep on adding operators like "+,*,/" like +++++ it should only accept + once and . once in a number
Brett Burtson
@bburtson
Aug 20 2017 09:05
@rohyadav It looks like you are working with a JSON file that contains an array of client objects what are you trying to accomplish
Morchid Chellali
@Morched23MJ
Aug 20 2017 09:05
I'm looking to implement that later, for now you know what I want? @heroiczero
Rohit Yadav
@rohyadav
Aug 20 2017 09:05
@bburtson i am trying to add balance
like in thsi json have balance property i want to be add balance
Brett Burtson
@bburtson
Aug 20 2017 09:06
@rohyadav add To the balance?
Rohit Yadav
@rohyadav
Aug 20 2017 09:06
yes
Brett Burtson
@bburtson
Aug 20 2017 09:06
okay there are 2 clients
Rohit Yadav
@rohyadav
Aug 20 2017 09:06
but even i am not able to access the property even
Brett Burtson
@bburtson
Aug 20 2017 09:07
From where are you attempting to access it?
Rohit Yadav
@rohyadav
Aug 20 2017 09:07
actully i am working in angular with json firebase
Brett Burtson
@bburtson
Aug 20 2017 09:07
okay
I'm assuming this is an angular cli project?
Angular 4 with TS support?
Rohit Yadav
@rohyadav
Aug 20 2017 09:08
getTotalOwed () {
    let total = 0;
    for (let i = 0; i < this.c_clients.length; i++) {
       total += parseFloat(this.c_clients[i].balance);
        console.log(this.c_clients[i].balance);
    }
}
    this.totalOwed = total;
    console.log(this.totalOwed);
  }
yes
your are right
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:08
@rohyadav if you are working with an api, then you must understand that data in api is received on data property so for you it would be data.clients[0].balance
Rohit Yadav
@rohyadav
Aug 20 2017 09:09
accessing from firebase
Brett Burtson
@bburtson
Aug 20 2017 09:10
I'm not familiar with firebase other than it is an identity based frame work with database support
but it seems pretty straight forward to get JSON data into your process
send me s screenshot of your project directory
Rohit Yadav
@rohyadav
Aug 20 2017 09:11
ok
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:11
@rohyadav
$http.get(/somAPi)
               .then((data)=>{ // here data is the response which contains stuff like data, headers, etc
                  let responseBody = data.data
                 total +=  responseBody.clients[0].balance; //or loop through the data
})
Brett Burtson
@bburtson
Aug 20 2017 09:11
there you go
do a console.dir(data) on your data abject and look at your clients
Rohit Yadav
@rohyadav
Aug 20 2017 09:12
@relentless-coder but here the problem is i am not able to access even object property using forloop
Brett Burtson
@bburtson
Aug 20 2017 09:12
is this in the same component
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:12
@rohyadav what is the error?
Rohit Yadav
@rohyadav
Aug 20 2017 09:13
12121212.png
undefined
and here above i have json arry object
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:14
@rohyadav and your code?
Rohit Yadav
@rohyadav
Aug 20 2017 09:15
import { Component, OnInit } from '@angular/core';
import { ClientService } from './../../services/client.service';
import { Client } from './../../models/Client';

@Component({
  selector: 'app-clients',
  templateUrl: './clients.component.html',
  styleUrls: ['./clients.component.css']
})
export class ClientsComponent implements OnInit {
  c_clients: any[];
  totalOwed: number;

  constructor(
    public c_clientService: ClientService
  ) { }

  ngOnInit() {
    // Now when this compornent initialize we wanna fetch clients through getClient method from client.servie.ts
    this.c_clientService.getClients().subscribe(clnts => {
      this.c_clients = clnts
      console.log(this.c_clients);
      this.getTotalOwed();
    })
  }

  getTotalOwed () {
    let total = 0;
    for (let i = 0; i < this.c_clients.length; i++) {
        total += parseFloat(this.c_clients[i].balance);
        console.log(this.totalOwed);
    }
    this.totalOwed = total;
    console.log(this.totalOwed);
  }

}
getTotalOwed () {
    let total = 0;
    for (let i = 0; i < this.c_clients.length; i++) {
        total += parseFloat(this.c_clients[i].balance);
        console.log(this.totalOwed);
    }
    this.totalOwed = total;
    console.log(this.totalOwed);
  }
this is the method
getTotalOwed
{
  "clients": [
    {
      "firstName": "Rohit",
      "lastName": "Yadav",
      "gender": "Male",
      "balance": "100.00",
      "email": "rohityadav@gmail.com",
      "phone": "+91-78555 55555",
      "address": "Room-8, 886 street, Gurgaon, harayana - 122002"
    },
    {
      "firstName": "Inder",
      "lastName": "Mahiwal",
      "gender": "Male",
      "balance": "200.00",
      "email": "indermahi@gmail.com",
      "phone": "+91-78555 55555",
      "address": "Room-16, 886 street, Gurgaon, harayana - 122002"
    }
  ]
}
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:16
you forgot to to access clients property first
Rohit Yadav
@rohyadav
Aug 20 2017 09:16
this is json
Brett Burtson
@bburtson
Aug 20 2017 09:16
let me see your service
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:16
this.c_clients[i].clients[i].balance
@rohyadav
Brett Burtson
@bburtson
Aug 20 2017 09:16
I think you need an observable
Rohit Yadav
@rohyadav
Aug 20 2017 09:18
@relentless-coder got error
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:18
@rohyadav if in this.c_clients = clnts clnts is the response json then you first need to access the clients property
Rohit Yadav
@rohyadav
Aug 20 2017 09:18
@bburtson yes i have it
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:18
@rohyadav what is it
heroiczero
@heroiczero
Aug 20 2017 09:19
@Morched23MJ P when press =, you can make a globalvar equal=true; then if(equal) when you click on a number you empty() or ""
Rohit Yadav
@rohyadav
Aug 20 2017 09:19
getTotalOwed () {
    let total = 0;
    for (let i = 0; i < this.c_clients.length; i++) {
        total += parseFloat(this.c_clients[i].clients[i].balance);
        console.log(this.totalOwed);
    }
    this.totalOwed = total;
    console.log(this.totalOwed);
  }
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:19
@rohyadav what is the error
Rohit Yadav
@rohyadav
Aug 20 2017 09:20
aq1.png
Brett Burtson
@bburtson
Aug 20 2017 09:20
//import observable from rxjs....
getClients(): Promise<Client[]> {
  return this.http.get("someapi")
             .toPromise()
             .then(response => response.json().data as Client[])
             .catch(this.handleError);
}
does this make sense?
you are returning a promise
Rohit Yadav
@rohyadav
Aug 20 2017 09:21
client.service.ts
Brett Burtson
@bburtson
Aug 20 2017 09:21
you cant just get at the data
Rohit Yadav
@rohyadav
Aug 20 2017 09:21
import { Injectable } from '@angular/core';
import { AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';
import { Observable } from 'rxjs/Rx';
// Import interface Client
import { Client } from '../models/Client'

@Injectable()
export class ClientService {
  flo_clients: FirebaseListObservable <any[]>;
  foo_client: FirebaseObjectObservable <any>

  constructor(
    // we need to injected dependency into the constructor
     public afd: AngularFireDatabase
  ) { // fetch the clients from the database
      this.flo_clients = this.afd.list('/clients') as FirebaseListObservable <Client[]>;
  }

  // So here we return whatever we fetch from firebase
  getClients () {
    return this.flo_clients;
  }

}
Brett Burtson
@bburtson
Aug 20 2017 09:21
until its retreieved
Rohit Yadav
@rohyadav
Aug 20 2017 09:22
@relentless-coder see the error
above
Brett Burtson
@bburtson
Aug 20 2017 09:22
okay
paste your business logic again
Rohit Yadav
@rohyadav
Aug 20 2017 09:23
getTotalOwed () {
    let total = 0;
    for (let i = 0; i < this.c_clients.length; i++) {
        total += parseFloat(this.c_clients[i].balance);
        console.log(this.totalOwed);
    }
    this.totalOwed = total;
    console.log(this.totalOwed);
  }
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:23
@bburtson he is doing it right, he calls the function once the promise has returned
Brett Burtson
@bburtson
Aug 20 2017 09:23
yeah i see
this.c_clients is your service right
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:24
it's the array
Rohit Yadav
@rohyadav
Aug 20 2017 09:24
121212.png
i want to be add balance total
in the ui
Brett Burtson
@bburtson
Aug 20 2017 09:25
var data = this.c_clients.getClients();
then loop data
for (let client of data){
//do something?
}
where are you calling getClients()
in the ctor?
Rohit Yadav
@rohyadav
Aug 20 2017 09:27
in ngOninit
Brett Burtson
@bburtson
Aug 20 2017 09:27
ok
let me look
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:27
@rohyadav could you log this.c_clients inside the getTotalOwed function?
Rohit Yadav
@rohyadav
Aug 20 2017 09:27
ngOnInit() {
    // Now when this compornent initialize we wanna fetch clients through getClient method from client.servie.ts
    this.c_clientService.getClients().subscribe(clnts => {
      this.c_clients = clnts
      console.log(this.c_clients);
      this.getTotalOwed();
    })
  }
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:27
@rohyadav I want to check the data when that function is called
Rohit Yadav
@rohyadav
Aug 20 2017 09:29
12121212.png
i logged @relentless-coder see
koder3
@koder3
Aug 20 2017 09:30
hey guys
Rohit Yadav
@rohyadav
Aug 20 2017 09:31
Untitled.png
Brett Burtson
@bburtson
Aug 20 2017 09:31
you call to as Clients in your service implementation suggests that you have already extracted your data
Ayush Bahuguna
@relentless-coder
Aug 20 2017 09:31
@rohyadav is your code somewhere on codepen or where we can take a look at it?
Brett Burtson
@bburtson
Aug 20 2017 09:31
have you tried console.dir(myService.getCLients());
You have a concrete list of clients
koder3
@koder3
Aug 20 2017 09:32
https://codepen.io/koder3/pen/rjBoxz why doesnt anything load ?
Rohit Yadav
@rohyadav
Aug 20 2017 09:32
yes on github you can see tat code
Brett Burtson
@bburtson
Aug 20 2017 09:32
better yet push it to git and ill clone it
Rohit Yadav
@rohyadav
Aug 20 2017 09:32
can i share the url of github
Brett Burtson
@bburtson
Aug 20 2017 09:32
yes
Rohit Yadav
@rohyadav
Aug 20 2017 09:32
ok jus giv me a sc
Brett Burtson
@bburtson
Aug 20 2017 09:32
ill clone your repo real fast it would be much easier
you can push it dirty too i don't care
if you don't have gitignore
heroiczero
@heroiczero
Aug 20 2017 09:35
@koder3 need Jquery in your settings->javascript
@bburtson
Brett Burtson
@bburtson
Aug 20 2017 09:36
ok
ty
cloning
Rohit Yadav
@rohyadav
Aug 20 2017 09:38
@bburtson thanks man for helping
CamperBot
@camperbot
Aug 20 2017 09:38
rohyadav sends brownie points to @bburtson :sparkles: :thumbsup: :sparkles:
:warning: rohyadav already gave bburtson points
Brett Burtson
@bburtson
Aug 20 2017 09:38
No problem ill do my best
installing dependancies ..
Rohit Yadav
@rohyadav
Aug 20 2017 09:41
ng serve
if you have already installed global angular cli
Brett Burtson
@bburtson
Aug 20 2017 09:41
ye
Rohit Yadav
@rohyadav
Aug 20 2017 09:41
yes
Brett Burtson
@bburtson
Aug 20 2017 09:41
firbasee insatall
Rohit Yadav
@rohyadav
Aug 20 2017 09:43
npm install
Brett Burtson
@bburtson
Aug 20 2017 09:44
sec my cli is 1 behind
Rohit Yadav
@rohyadav
Aug 20 2017 09:45
just need to install npm install in the directory
Brett Burtson
@bburtson
Aug 20 2017 09:46
My ng cli is not up to date on this computer
Rohit Yadav
@rohyadav
Aug 20 2017 09:46
no need to install firebase
Brett Burtson
@bburtson
Aug 20 2017 09:46
1.1.1
u guys are 1.2.7
sec
Rohit Yadav
@rohyadav
Aug 20 2017 09:46
giv me sec
Brett Burtson
@bburtson
Aug 20 2017 09:48
image.png
image.png
webpack config
?
Rohit Yadav
@rohyadav
Aug 20 2017 09:53
yes

npm install bootstrap@4.0.0-beta tether jquery --save
npm install popper.js --save

<script src="https://unpkg.com/popper.js"></script>

this is aso need to install
Brett Burtson
@bburtson
Aug 20 2017 09:54
kk ty
Rohit Yadav
@rohyadav
Aug 20 2017 09:54
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "client-panel"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.css",
        "../node_modules/font-awesome/css/font-awesome.min.css",
        "../node_modules/bootstrap/dist/css/bootstrap.min.css"
      ],
      "scripts": [
        "../node_modules/jquery/dist/jquery.min.js",
        "../node_modules/tether/dist/js/tether.min.js",
        "../node_modules/proper/dist/js/proper.js",
        "../node_modules/bootstrap/dist/js/bootstrap.min.js"
      ],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}
this is my angular-cli.json
file
koder3
@koder3
Aug 20 2017 09:56
@heroiczero thanks a lot hehe
CamperBot
@camperbot
Aug 20 2017 09:56
koder3 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1630 | @heroiczero |http://www.freecodecamp.com/heroiczero
Rohit Yadav
@rohyadav
Aug 20 2017 10:00
@bburtson remove
"../node_modules/proper/dist/js/proper.js",
this file from angular-cli.json
Brett Burtson
@bburtson
Aug 20 2017 10:00
remove crom ng cli config?
Rohit Yadav
@rohyadav
Aug 20 2017 10:00
and uncomment src file from index.html
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/tether/dist/js/tether.min.js",
"../node_modules/proper/dist/js/proper.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
],
here from the angular-cli.json
file
remove proper.js
Brett Burtson
@bburtson
Aug 20 2017 10:01
k
Rohit Yadav
@rohyadav
Aug 20 2017 10:01
and uncomment from index.html
LiciniusRex
@hashtagyolo1
Aug 20 2017 10:02
howdy folks. Was hoping someone could tell me why onload doesn't seem to working.
https://codepen.io/LiciniusRex/pen/NvYrNR?editors=1011
Long Nguyen
@longnt80
Aug 20 2017 10:04
@hashtagyolo1 try putting it in the body tag instead
LiciniusRex
@hashtagyolo1
Aug 20 2017 10:05
hahaha, thanks @longnt80 works perfecrtly now
CamperBot
@camperbot
Aug 20 2017 10:05
hashtagyolo1 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 513 | @longnt80 |http://www.freecodecamp.com/longnt80
Brett Burtson
@bburtson
Aug 20 2017 10:05
lol were getting there
hang in there
LiciniusRex
@hashtagyolo1
Aug 20 2017 10:06
I'm surprised how easy I found the rest of this one so far. I've obviously taken in more than I had realised.
Long Nguyen
@longnt80
Aug 20 2017 10:07
@hashtagyolo1 but you haven't done anything related to API, json?
LiciniusRex
@hashtagyolo1
Aug 20 2017 10:09
Just about to do the twitter bit now. We'll see if I'm still smiling then :)
Long Nguyen
@longnt80
Aug 20 2017 10:10
@hashtagyolo1 do you have a version where you load the quotes from an actual API provider?
Brett Burtson
@bburtson
Aug 20 2017 10:10
image.png
i don't know boys
Rohit Yadav
@rohyadav
Aug 20 2017 10:12
i think you node packege is older version
that is why is comming
Brett Burtson
@bburtson
Aug 20 2017 10:12
npm start built all modules but still gave me the same webpack error
k
sec
Rohit Yadav
@rohyadav
Aug 20 2017 10:12
you need to upgrade node aswell npm
mine is
λ node -v
v8.2.0
λ npm -v
5.0.3
LiciniusRex
@hashtagyolo1
Aug 20 2017 10:13
@longnt80 no, not seen anywhere I could get them
Brett Burtson
@bburtson
Aug 20 2017 10:13
3.1 lol
Rohit Yadav
@rohyadav
Aug 20 2017 10:13
yes you need to upgrade
Brett Burtson
@bburtson
Aug 20 2017 10:14
I'm on it
i just wanted to see some clients guys
lol
Long Nguyen
@longnt80
Aug 20 2017 10:16
@hashtagyolo1 https://quotesondesign.com/api-v4-0/
the point of these projects is for you to get familiar with using API services
Brett Burtson
@bburtson
Aug 20 2017 10:16
I see
You guys working together
I'm going to restart pc 1 sec
be quick
ssd!
LiciniusRex
@hashtagyolo1
Aug 20 2017 10:17
no cyberpunk quotes for me then :(
Long Nguyen
@longnt80
Aug 20 2017 10:17
@hashtagyolo1 :D yes
@hashtagyolo1 here's a peak at the javascript code just to load a simple data from API: https://codepen.io/longnt80/pen/zwZrgZ?editors=0010
koder3
@koder3
Aug 20 2017 10:21
hi
why does my button not load up anything in this codepen https://codepen.io/koder3/pen/rjBoxz
Brett Burtson
@bburtson
Aug 20 2017 10:22
still getting errors and npm update still shows 3.1
you guys use NVM?
are you on linux env?
Rohit Yadav
@rohyadav
Aug 20 2017 10:23
guys anyone help me multiple file upload with preview using pure javascript
Long Nguyen
@longnt80
Aug 20 2017 10:23
@koder3 your url is not https so it's not allowed in codepen
http://rest.learncode.academy/api/johnbob/friends
Here's the error in console:
Mixed Content: The page at 'https://codepen.io/koder3/full/rjBoxz/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://rest.learncode.academy/api/johnbob/friends'. This request has been blocked; the content must be served over HTTPS.
Rohit Yadav
@rohyadav
Aug 20 2017 10:24
@Darkoyd
koder3
@koder3
Aug 20 2017 10:25
@longnt80 oh, any workaround for that or do i have to use another site?
LiciniusRex
@hashtagyolo1
Aug 20 2017 10:25
thanks @longnt80
CamperBot
@camperbot
Aug 20 2017 10:25
hashtagyolo1 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:warning: hashtagyolo1 already gave longnt80 points
Rohit Yadav
@rohyadav
Aug 20 2017 10:25
@bburtson you need to open cli with Admin
npm i -g npm-upgrade
Long Nguyen
@longnt80
Aug 20 2017 10:26
@koder3 if your url supports https then you can change to https by adding the s
if not, you need to find another API service
@hashtagyolo1 np
Rohit Yadav
@rohyadav
Aug 20 2017 10:26
guys anyone help me multiple file upload with preview using pure javascript
Brett Burtson
@bburtson
Aug 20 2017 10:27
@rohyadav what are your angular version and node versions again
koder3
@koder3
Aug 20 2017 10:28
@longnt80 thanks
CamperBot
@camperbot
Aug 20 2017 10:28
:cookie: 514 | @longnt80 |http://www.freecodecamp.com/longnt80
koder3 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
Brett Burtson
@bburtson
Aug 20 2017 10:29
image.png
Thayyeb salim
@Thayyebsalim
Aug 20 2017 10:29
I'm having trouble with this. Can someone lend me a hand
https://www.codewars.com/kata/word-values/train/javascript
Nazar
@IsaakNazar
Aug 20 2017 10:30
I cant use splice method instead add. Why? help pls
function myFunction() {
    var x = document.getElementById("mySelect");
    var c = document.createElement("option");
    c.text = "Kiwi";
    x.options.add(c, 1);
}
Rohit Yadav
@rohyadav
Aug 20 2017 10:31
@bburtson mine is
λ node -v
v8.2.0
λ npm -v
5.0.3
Brett Burtson
@bburtson
Aug 20 2017 10:32
@rohyadav ohhh okay u went for the big gunz
k installing
image.png
Rohit Yadav
@rohyadav
Aug 20 2017 10:35
@bburtson is there any idea about how do i multiple file upload with preview using pure javascript
Brett Burtson
@bburtson
Aug 20 2017 10:35
after ill reclone your repo
Abhinav Mishra
@abhinav-m
Aug 20 2017 10:35
Hi
Brett Burtson
@bburtson
Aug 20 2017 10:35
Multiple file upload?
give me some context
Rohit Yadav
@rohyadav
Aug 20 2017 10:35
woow @TheBreeze92 installed
Abhinav Mishra
@abhinav-m
Aug 20 2017 10:36
I was doing react and higher order components
const HOC = (InnerComponent) => class extends React.Component {
  render(){
    return(
      <InnerComponent
      {...this.props}
      />
    )
  }
}
Brett Burtson
@bburtson
Aug 20 2017 10:36
@rohyadav multiple file updload... to ?
Abhinav Mishra
@abhinav-m
Aug 20 2017 10:36
Is this similar to a function expression
using an unnamed class
'anonymous class'
Rohit Yadav
@rohyadav
Aug 20 2017 10:37

@bburtson
I want to Build a simple file uploader which can be used by other applications as a plugin or module. The uploader should have following features:

Configurable upload URL and param name. Show live preview on the browser if the file is an image. Customize file extensions to be allowed. For example: [‘image/png’, ‘image/jpg’] Ability to send extra data when uploading the file. For example Sending user_id with each file. Please note:

Make sure the code is written using pure JavaScript and do not make use of any 3rd party libraries

@bburtson no not in this project .. this is different its just pure in javascript based here look at the scenario we have
Brett Burtson
@bburtson
Aug 20 2017 10:38
This sounds like an excercise to force you to learn how to "asynchronos" java script works
Rohit Yadav
@rohyadav
Aug 20 2017 10:39
ha ha ha kind
Thayyeb salim
@Thayyebsalim
Aug 20 2017 10:39
function wordValue(a) {
  a.map(function (word,index){
    word=word.replace(/\s/g,'').split('').map( function (letter){ 
      return letter.charCodeAt(0)-96;
      }).reduce( function (sum,index){
        return sum+index;
        },0)*(index+1);
  return word;
  });
}
This is returning undefined
if I change return to console it gives the desired answer.
https://www.codewars.com/kata/word-values/train/javascript
Brett Burtson
@bburtson
Aug 20 2017 10:40
@rohyadav my head goes to create a light weight service you can instantiate to service uploads as needed
@rohyadav use an observable to to show data progress excetera ...
korzo
@korzo
Aug 20 2017 10:41
@Thayyebsalim Because you return nothing from function
Brett Burtson
@bburtson
Aug 20 2017 10:41
@rohyadav configurable upload URL... what do you mean?
@rohyadav you can write a filestream to the browser asynchronosly
Thayyeb salim
@Thayyebsalim
Aug 20 2017 10:42
@korzo the .map isn't working so when i return the array it does not get changed
Brett Burtson
@bburtson
Aug 20 2017 10:42
@rohyadav typically images are rendered as recieved
Rohit Yadav
@rohyadav
Aug 20 2017 10:42
configurable uplaod url means
i did not get it
so we can store in localstorage
is this possible
?
Brett Burtson
@bburtson
Aug 20 2017 10:43
store the images?
as opposed to a database
?
Rohit Yadav
@rohyadav
Aug 20 2017 10:43
no no if not required then no need
i dont know i never tried
to upload the images and file
Brett Burtson
@bburtson
Aug 20 2017 10:44
"so we can store in localstorage"
what u mean
you want to provide a service
Rohit Yadav
@rohyadav
Aug 20 2017 10:45
yes if it required then otherwise its ok
Brett Burtson
@bburtson
Aug 20 2017 10:45
that allows you to upload binary large objects to a file server
Rohit Yadav
@rohyadav
Aug 20 2017 10:45
no no service
Brett Burtson
@bburtson
Aug 20 2017 10:45
and show you there upload status
okay
then what lol
Rohit Yadav
@rohyadav
Aug 20 2017 10:45
i dont even get it how will i execute i just got the doceument from the client
ha ha ha
Adit
@adittyagi
Aug 20 2017 10:46
Hey guys! Any advice before I start my random quote machine ?
Rohit Yadav
@rohyadav
Aug 20 2017 10:46
that is why? i need to help and want to know how we execute
and do based on the scenario provied
provided
Brett Burtson
@bburtson
Aug 20 2017 10:46
Start over
man im loast at uploading images
Rohit Yadav
@rohyadav
Aug 20 2017 10:47
:)
Brett Burtson
@bburtson
Aug 20 2017 10:47
lol
What now?
Rohit Yadav
@rohyadav
Aug 20 2017 10:48
will think .. i need to work on that
:)
Brett Burtson
@bburtson
Aug 20 2017 10:48
installing modules on a fresh clone of your repo
;)
Rohit Yadav
@rohyadav
Aug 20 2017 10:49
cool
Abhinav Mishra
@abhinav-m
Aug 20 2017 10:54
@Thayyebsalim
const wordValue = (a) =>
  a.map ( (v,i) =>  v.split('')
                          .reduce( (a,x) => a += x!==' ' ? 
                          x.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0) + 1 
                          : 0 , 0 ) * (i+1) )
@Thayyebsalim your approach seems to be similar
whats going wrong?
Brett Burtson
@bburtson
Aug 20 2017 10:57
@Thayyebsalim fs-extra?
this a module?
@rohyadav fs-extra
Abhinav Mishra
@abhinav-m
Aug 20 2017 10:58
@Thayyebsalim you need to handle the part where it says dont consider spaces
Brett Burtson
@bburtson
Aug 20 2017 10:59
@rohyadav is this another missing dependency? fs-extra
Rohit Yadav
@rohyadav
Aug 20 2017 10:59
fs-exta
no dont think so
screenshot show me
Brett Burtson
@bburtson
Aug 20 2017 11:00
cant serve without it im installing it lol
Rohit Yadav
@rohyadav
Aug 20 2017 11:00
ha ha for me .. never required
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:02
@Thayyebsalim
const wordValue = (a) =>
  a.map ( (v,i) =>  v.split('')
                          .reduce( (a,x) => a +( x!==' ' ? 
                          x.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0) + 1 
                          : 0 ), 0 ) * (i+1) )
i refactored a bit..
also why are you subtracting with 96?
aah.. i see nvm..
Brett Burtson
@bburtson
Aug 20 2017 11:08
@rohyadav i just keep getting prompted to install modules 1 by 1
okay
@rohyadav we are back where we were with those other extraneos dependacies you were telking to me about earlier
proper js
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:09
@Thayyebsalim not sure.. your solution seems to be correct
Rohit Yadav
@rohyadav
Aug 20 2017 11:11
yes
so just remove that properjs from the angular-cli.json
from the script array
and uncomment same file from the index.html
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:12
@Thayyebsalim my god its as simple as not returning anything from the function
Rohit Yadav
@rohyadav
Aug 20 2017 11:12
@bburtson
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:12
as @bburtson pointed out earlier
LOL
Rohit Yadav
@rohyadav
Aug 20 2017 11:13
lol :)
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:13
sorry not @bburtson
but @korzo
Rohit Yadav
@rohyadav
Aug 20 2017 11:14
ha ha ha
Long Nguyen
@longnt80
Aug 20 2017 11:14

@Thayyebsalim @abhinav-thinktank here's mine:
const wordValue = (a) => a.map( (v,i) => (i+1) * Array.prototype.reduce.call(a[i], (a,c) => a + ((c != ' ') ? (c.charCodeAt(0)-96) : 0) ,0) )

just for fun, I'm still learning

Brett Burtson
@bburtson
Aug 20 2017 11:14
@rohyadav ya
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:16
could just use v
instead of a[i]
@longnt80
Long Nguyen
@longnt80
Aug 20 2017 11:17
@abhinav-thinktank oh yeah, my bad
@abhinav-thinktank thanks
CamperBot
@camperbot
Aug 20 2017 11:17
longnt80 sends brownie points to @abhinav-thinktank :sparkles: :thumbsup: :sparkles:
:cookie: 511 | @abhinav-thinktank |http://www.freecodecamp.com/abhinav-thinktank
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:17
@longnt80 ty :+1:
not sure if its a good practice to treat the string as an array though..
i could be wrong
Long Nguyen
@longnt80
Aug 20 2017 11:19
@abhinav-thinktank I don't know either, maybe just for some special case
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:19
hmm
const wordValue = (a) =>
  a.map ( (v,i) =>  v.split('')
                          .reduce( (a,x) => a +( x!==' ' ? 
                          x.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0) + 1 
                          : 0 ), 0 ) * (i+1) )
i did it like this
gtg, thx for your solution :) @longnt80
CamperBot
@camperbot
Aug 20 2017 11:20
abhinav-thinktank sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 515 | @longnt80 |http://www.freecodecamp.com/longnt80
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:20
thanks @abhinav-thinktank @longnt80
CamperBot
@camperbot
Aug 20 2017 11:20
thayyebsalim sends brownie points to @abhinav-thinktank and @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 512 | @abhinav-thinktank |http://www.freecodecamp.com/abhinav-thinktank
:cookie: 516 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
Aug 20 2017 11:20
@abhinav-thinktank :+1:
also thanks to @Thayyebsalim , I guess
CamperBot
@camperbot
Aug 20 2017 11:20
longnt80 sends brownie points to @abhinav-thinktank and @thayyebsalim :sparkles: :thumbsup: :sparkles:
:warning: longnt80 already gave abhinav-thinktank points
:cookie: 321 | @thayyebsalim |http://www.freecodecamp.com/thayyebsalim
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:21
@Thayyebsalim ty
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:23
How long have you guys been coding @abhinav-thinktank @longnt80
Long Nguyen
@longnt80
Aug 20 2017 11:23
@Thayyebsalim 5 months
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:23
wow great
Long Nguyen
@longnt80
Aug 20 2017 11:24
don't let the ES6 syntax fools you
I'm still a novice
:D
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:24
but youre pretty good
do you do codewars?
Long Nguyen
@longnt80
Aug 20 2017 11:25
I've done some easy ones
@Thayyebsalim where are you on the FCC map?
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:26
on the intermediate algos
My algorithm side is a bit weak
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:27
@Thayyebsalim in js, about 2 months
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:27
Wow cool
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:27
im familiar with programming though.
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:27
I need to up my algorithm game
Long Nguyen
@longnt80
Aug 20 2017 11:27
keep doing it, you'll get better
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:27
principles are generally the same regards to different languages..
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:28
Thanks guys
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:29
@Thayyebsalim just a note
//index should be named as value here

reduce( function (sum,index){
        return sum+index;
        },0)*(index+1);
this naming threw me off a bit
should be (sum,value)
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:29
Oh ok
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:29
the second argument is the current value, not the index
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:30
Yeah
I just mixed up the naming
btw I still have no idea why my code is not working
Long Nguyen
@longnt80
Aug 20 2017 11:31
@Thayyebsalim copy your code again
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:31
function wordValue(a) {
  a.map(function (word,index){
    word=word.replace(/\s/g,'').split('').map( function (letter){ 
      return letter.charCodeAt(0)-96;
      }).reduce( function (sum,value){
        return sum+value;
        },0)*(index+1);
  return word;
  });
return a;
}
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:32
youre not returning dude!
a is still referencing the old array
add return in front of a.map ..
!
your solution is correct
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:32
omg
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:32
@Thayyebsalim
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:32
that was silly
Abhinav Mishra
@abhinav-m
Aug 20 2017 11:33
hehe.. i also analyzed every part of your solution before realizing it
happens..
Thayyeb salim
@Thayyebsalim
Aug 20 2017 11:33
I've been focusing so hard on the bottom end
XD
Thanks again @abhinav-thinktank @longnt80
CamperBot
@camperbot
Aug 20 2017 11:34
thayyebsalim sends brownie points to @abhinav-thinktank and @longnt80 :sparkles: :thumbsup: :sparkles:
:warning: thayyebsalim already gave abhinav-thinktank points
:warning: thayyebsalim already gave longnt80 points
Long Nguyen
@longnt80
Aug 20 2017 11:35
@Thayyebsalim no problem man
koder3
@koder3
Aug 20 2017 12:46
when using url in ajax is it important to mention method lang and format? if so why?
Ene Catalin
@EneCatalin
Aug 20 2017 12:58
format like in json ?
in that case yes, because it needs to know wtf it's looking at
Saif Ur Rahman
@saifsmailbox98
Aug 20 2017 12:59
Anyone here having a knowledge about cryptography using Xor?
Ene Catalin
@EneCatalin
Aug 20 2017 12:59
what do you mean by knowledge of cryptography ?
are you trying to make a bit cipher ?
I made one a long time ago if it counts
koder3
@koder3
Aug 20 2017 13:01
Ene Catalin
@EneCatalin
Aug 20 2017 13:02
@koder3 not sure but a very important tip
cache:false
add that :)
koder3
@koder3
Aug 20 2017 13:03
@EneCatalin thanks
CamperBot
@camperbot
Aug 20 2017 13:03
koder3 sends brownie points to @enecatalin :sparkles: :thumbsup: :sparkles:
:cookie: 442 | @enecatalin |http://www.freecodecamp.com/enecatalin
Ene Catalin
@EneCatalin
Aug 20 2017 13:03
add it in the ajax
it's so you can refresh the quote later on
with a new one
Jianhao Tan
@jaanhio
Aug 20 2017 13:04

hey all, i keep seeing this in react-redux tutorial examples.

import { Container } from 'semantic-ui-react’;

and

export default function createLogger({ getState })

what does the curly braces for { getState } and { Container } actually mean?

koder3
@koder3
Aug 20 2017 13:05
i still dont get any quote though...
Stephen James
@sjames1958gm
Aug 20 2017 13:06
@koder3
Add this to the request
dataType: "jsonp",
koder3
@koder3
Aug 20 2017 13:06
what part of it is the request?
Stephen James
@sjames1958gm
Aug 20 2017 13:07
Between the url and the success properties
@jaanhio The first is getting the Container property from the 'semantic-ui-react’ exports.
The second is getting the property getState from the object passed into createLogger
koder3
@koder3
Aug 20 2017 13:08
https://codepen.io/koder3/pen/rjBoxz the button gets shrinked why is this happening
Stephen James
@sjames1958gm
Aug 20 2017 13:09
Because you are changing the HTML to whatever comes back in the json -
Jianhao Tan
@jaanhio
Aug 20 2017 13:09
@sjames1958gm i see. whats the term for it? i thought it was template literals but realized its slightly different
Alaa H. Youssef
@alaahamdyy26
Aug 20 2017 13:09
hii
kumquatfelafel
@kumquatfelafel
Aug 20 2017 13:09
hey
Alaa H. Youssef
@alaahamdyy26
Aug 20 2017 13:09
pls check my new pen and let e know if there's any comment
Stephen James
@sjames1958gm
Aug 20 2017 13:10
@jaanhio destructuring
kumquatfelafel
@kumquatfelafel
Aug 20 2017 13:11
@alaahamdyy26 try and get it to work for when user hits enter too.
Stephen James
@sjames1958gm
Aug 20 2017 13:12
@alaahamdyy26 The styling is nice. When you hit enter in the search box, the page is refreshed
Alaa H. Youssef
@alaahamdyy26
Aug 20 2017 13:12
yes
Ene Catalin
@EneCatalin
Aug 20 2017 13:12
@alaahamdyy26 you forgot to add the random button ?
Alaa H. Youssef
@alaahamdyy26
Aug 20 2017 13:12
I want to make it work by pressing"enter"
and yes, forgot about the random button
:D
Thanks alot
Fernando
@lestairon
Aug 20 2017 13:13
@alaahamdyy26 It's good
But i'd add a z-index on the css
Jianhao Tan
@jaanhio
Aug 20 2017 13:13
@sjames1958gm thank you! 😊
CamperBot
@camperbot
Aug 20 2017 13:13
jaanhio sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8344 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Alaa H. Youssef
@alaahamdyy26
Aug 20 2017 13:13
@lestairon sorry but i dont know what's the z-index :$
will google this :D
thanks :)
Fernando
@lestairon
Aug 20 2017 13:16
When i put the cursor over the Wikipedia logo it gets more opaque than the text
Maybe you like it that way
But good job, looks great :)
Alaa H. Youssef
@alaahamdyy26
Aug 20 2017 13:18
@lestairon :clap: Thanks
CamperBot
@camperbot
Aug 20 2017 13:18
alaahamdyy26 sends brownie points to @lestairon :sparkles: :thumbsup: :sparkles:
:cookie: 243 | @lestairon |http://www.freecodecamp.com/lestairon
Ronique Ricketts
@RoniqueRicketts
Aug 20 2017 13:21
This message was deleted
Ene Catalin
@EneCatalin
Aug 20 2017 13:22
@koder3 got it fixed ?
koder3
@koder3
Aug 20 2017 13:24
@EneCatalin im quite lost atm hehe
i use the API from this page https://quotesondesign.com/api-v4-0/ and the url they give is http://quotesondesign.com/wp-json/posts?
that url doesnt work
https://forismatic.com/en/api/ does not tell me to use method lang and format
Ene Catalin
@EneCatalin
Aug 20 2017 13:27
I forgot wtf I did, made it ages ago
anyway, yeah that's the site most people use
Long Nguyen
@longnt80
Aug 20 2017 13:28
@koder3
http://quotesondesign.com/wp-json/posts? you need to add the filter
koder3
@koder3
Aug 20 2017 13:29
why is that important though @longnt80
Long Nguyen
@longnt80
Aug 20 2017 13:29
filter[orderby]=rand&filter[posts_per_page]=1
because that's how to load the API as they instructed you
For example, to grab a single, random post, use this URL:
http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1
koder3
@koder3
Aug 20 2017 13:32
why does this not work https://codepen.io/koder3/pen/rjBoxz
Jianhao Tan
@jaanhio
Aug 20 2017 13:33

@sjames1958gm sorry one more question!

import { reducer as formReducer } from 'redux-form’

what about this? what does “as” part mean?

koder3
@koder3
Aug 20 2017 13:33
@longnt80
Ene Catalin
@EneCatalin
Aug 20 2017 13:33
@koder3 you get a, brain fart, thing with []
an array :D
you pretty much get this yuuuuuuuuuuuuge array and need to select which element you want :)
Long Nguyen
@longnt80
Aug 20 2017 13:34
@koder3 you need to add s to http
Roxroy
@roxroy
Aug 20 2017 13:34
@koder3 , it does give you the information on the page.
http://api.forismatic.com/api/1.0/, Query parameters are passed using POST or GET (URL-encoded) method. The server return data format is set by the query parameter. The following response formats are supported: xml, json, jsonp, html,text. However, you would then have to know how to apply it with a fetch or ajax call.
Long Nguyen
@longnt80
Aug 20 2017 13:34
@koder3 so change the url to "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback="
Ene Catalin
@EneCatalin
Aug 20 2017 13:34
oh he also used the old url
just noticed
koder3
@koder3
Aug 20 2017 13:35
@longnt80 https://codepen.io/koder3/pen/rjBoxz i did, no difference though
Ene Catalin
@EneCatalin
Aug 20 2017 13:35
just use the url I gave you
works 100%
no idea why you changed it
Long Nguyen
@longnt80
Aug 20 2017 13:36
@koder3 let me see
Ene Catalin
@EneCatalin
Aug 20 2017 13:36
thing about apis is, you either understand the documentation and practice enough or you'll rip your hair out :P
Long Nguyen
@longnt80
Aug 20 2017 13:39
@EneCatalin not sure why you need to use jsonp though, their first exmaple should work just fine:
$.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(a) {
  $("body").append(a[0].content + "<p>— " + a[0].title + "</p>")
});
Ene Catalin
@EneCatalin
Aug 20 2017 13:40
no idea
btw is jsonp still insecure ?
Abhinav Mishra
@abhinav-m
Aug 20 2017 13:42
its considered insecure yes
Ene Catalin
@EneCatalin
Aug 20 2017 13:42
so it's better to use json ?
Abhinav Mishra
@abhinav-m
Aug 20 2017 13:43
what..
Ene Catalin
@EneCatalin
Aug 20 2017 13:43
I mean normal json
I am a newbie too so I don't really know the dif that much
Abhinav Mishra
@abhinav-m
Aug 20 2017 13:43
you are getting the response as json
wait.. ill give you a link
to understand about cors and jsonp
it explains the fundamentals really well.
Ene Catalin
@EneCatalin
Aug 20 2017 13:46
@abhinav-thinktank thanks
CamperBot
@camperbot
Aug 20 2017 13:46
enecatalin sends brownie points to @abhinav-thinktank :sparkles: :thumbsup: :sparkles:
:cookie: 515 | @abhinav-thinktank |http://www.freecodecamp.com/abhinav-thinktank
Abhinav Mishra
@abhinav-m
Aug 20 2017 13:46
go through it once
Ene Catalin
@EneCatalin
Aug 20 2017 13:46
oh got this one once, had no idea wtf Access-Control-Allow-Origin
dropped C# after that one :D
luccifer00
@luccifer00
Aug 20 2017 13:47
hi there! where can i find the id in twitch register?? i couldnt find...
Abhinav Mishra
@abhinav-m
Aug 20 2017 13:47
@EneCatalin yea, it bugged me alot when i was learning earlier
this article is good
luccifer00
@luccifer00
Aug 20 2017 13:48
i needed to the twitchTV api
Long Nguyen
@longnt80
Aug 20 2017 13:49

@luccifer00 use these urls:

https://wind-bow.glitch.me/twitch-api/users/<<account name>>
https://wind-bow.glitch.me/twitch-api/channels/<<account name>>
https://wind-bow.glitch.me/twitch-api/streams/<<account name>>>

no need to register for an ID

luccifer00
@luccifer00
Aug 20 2017 13:50
:+1: @longnt80
Abhinav Mishra
@abhinav-m
Aug 20 2017 13:53
I have a piece of code related to higher order components
rather long , but
const HOC = (InnerComponent) => class extends React.Component {
  constructor() {
    super();
    this.state = {count: 0}
  }

  update() {
    this.setState({count: this.state.count + 1})
  }

  componentWillMount() {
    console.log('HOC mounts '+ this.state.count);
  }
  //The above message prints twice, for both the components in App.
  render(){
    return(
      <InnerComponent
      {...this.props}
      {...this.state}
      update = {this.update.bind(this)}
      />
    )
  }
}

class App extends Component {
  render() {
    return (
      <div >
        <Button> button </Button>
        <hr/>
        <LabelHOC>label</LabelHOC>
      </div>
    );
  }
}

//Functional component, takes props as argument and returns a value.
const Button = HOC((props) => <button onClick={props.update}>{props.children} - {props.count}</button>)

//Class component.
class Label extends React.Component {
  //Will print once, when label mounts.
  componentWillMount() {
    console.log('label will mount')
  }

  render(){
    return(
    <label onMouseMove={this.props.update}>{this.props.children} {this.props.count}</label>)
  }
}

const LabelHOC = HOC(Label);
the label and buttons are being rendered properly,,
im wondering how the reconciliation works here
1 Button component is passed 'button' as a prop
2 This is a higher order component , thus props.children will refer to the value 'button'
3 The HOC itself has it's state passed to the inner component as a prop thus it renders the button with that state, also the label.
Is this correct?
Saif Ur Rahman
@saifsmailbox98
Aug 20 2017 14:05
Is it possible to decrypt a .ssl file with RSA PRIVATE KEY .pem file?
Stephen James
@sjames1958gm
Aug 20 2017 14:11
@abhinav-thinktank Sounds correct to me.
Abhinav Mishra
@abhinav-m
Aug 20 2017 14:12
@sjames1958gm thank you
CamperBot
@camperbot
Aug 20 2017 14:12
abhinav-thinktank sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8345 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Abhinav Mishra
@abhinav-m
Aug 20 2017 14:12
using spread operator on the object passes it's properties as props correct?
therefore props.children = 'button'
and props.count refers to the state.count
Stephen James
@sjames1958gm
Aug 20 2017 14:15
@abhinav-thinktank yes
Abhinav Mishra
@abhinav-m
Aug 20 2017 14:16
@sjames1958gm thank you, this one was tricky to understand
CamperBot
@camperbot
Aug 20 2017 14:16
abhinav-thinktank sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: abhinav-thinktank already gave sjames1958gm points
Abhinav Mishra
@abhinav-m
Aug 20 2017 14:16
are higher order components used alot?
Stephen James
@sjames1958gm
Aug 20 2017 14:16
I don't know
Abhinav Mishra
@abhinav-m
Aug 20 2017 14:16
should i be aiming to write more of higher order components for similar stuff
hmm
Stephen James
@sjames1958gm
Aug 20 2017 14:20
my opinion would be to watch for repeated patterns then see if they can be resolved to HOC
Abhinav Mishra
@abhinav-m
Aug 20 2017 14:21
hmm , ok @sjames1958gm thanks
CamperBot
@camperbot
Aug 20 2017 14:21
abhinav-thinktank sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: abhinav-thinktank already gave sjames1958gm points
WackThat .
@WackThatOriginal
Aug 20 2017 14:38
hello, i need help, im now doing the js front end development project of "Tic Tac Toe" game and i have a problem, in line 39 im calling the function tileUpdate() with the parameter 'targetIndex' every time that the user clicks on one of the cubes, and when im console logging the tiles variable is stays the same, it doesnt update, what to do?
https://codepen.io/WackThat/pen/rzJwjr?editors=1011
Markus Ivancsics
@ivancsicsmarkus
Aug 20 2017 14:40
Any crazy-js-expert online?
koder3
@koder3
Aug 20 2017 14:40
Markus Ivancsics
@ivancsicsmarkus
Aug 20 2017 14:45
@koder3
  • You should add getMessage id to you button.
  • Inside your callback, you should select the div.display, and set it’s innerHTML to the variable html
koder3
@koder3
Aug 20 2017 14:46
@ivancsicsmarkus thanks
CamperBot
@camperbot
Aug 20 2017 14:46
koder3 sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 648 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
koder3
@koder3
Aug 20 2017 14:49
https://codepen.io/koder3/pen/rjBoxz why do i keep getting the same quote each time i click the button?
WackThat .
@WackThatOriginal
Aug 20 2017 14:50
can someone help me? im now doing the js front end development project of "Tic Tac Toe" game and i have a problem, in line 39 im calling the function tileUpdate() with the parameter 'targetIndex' every time that the user clicks on one of the cubes, and when im console logging the tiles variable is stays the same, it doesnt update, what to do?
https://codepen.io/WackThat/pen/rzJwjr?editors=1011
Long Nguyen
@longnt80
Aug 20 2017 14:52
@martin50679 something to do with var clicked = $(event.target);
your tilesIndex is an empty string
Stephen James
@sjames1958gm
Aug 20 2017 14:53
@koder3 that goes back to cache: false property in your ajax
WackThat .
@WackThatOriginal
Aug 20 2017 14:54
@longnt80 why? all the cubes have value and clicked works on line 38
koder3
@koder3
Aug 20 2017 14:55
@sjames1958gm i have to add cache:false into my code?
Stephen James
@sjames1958gm
Aug 20 2017 14:55
@koder3 since you are using getJSON add this call before you getJSON call
$.ajaxSetup({
    // Disable caching of AJAX responses
    cache: false
});
Long Nguyen
@longnt80
Aug 20 2017 14:56
@martin50679 do console.log(tilesIndex); after line 38 and see for youself
koder3
@koder3
Aug 20 2017 14:56
@sjames1958gm hmm it works now. thanks. by the way what does cache:false do anyway what does caching AJAX responses mean, i dont understand
CamperBot
@camperbot
Aug 20 2017 14:56
koder3 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8347 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
WackThat .
@WackThatOriginal
Aug 20 2017 14:57
@longnt80 so what do i do?
Long Nguyen
@longnt80
Aug 20 2017 14:58
@martin50679 sorry I have to go, maybe someone can take a look
Stephen James
@sjames1958gm
Aug 20 2017 14:59
@martin50679 I think that .val() does not return the value prop/attribute, but the text content.
try
var targetIndex = $(event.target).attr("value");
WackThat .
@WackThatOriginal
Aug 20 2017 15:00
@sjames1958gm ohhh ty!
CamperBot
@camperbot
Aug 20 2017 15:00
martin50679 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8348 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Marc
@MWBauer
Aug 20 2017 15:08
this is the last of my code. what's wrong with it?
if (i === j);
return (true);
} else {
return (false);
}
it says expecting identifier, assignment, function.
Stephen James
@sjames1958gm
Aug 20 2017 15:10
@MWBauer extra ; at end of if line
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:10
@MWBauer
you could simplify it to
Marc
@MWBauer
Aug 20 2017 15:10
says it's unnecessary
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:10
return (i == j)
Marc
@MWBauer
Aug 20 2017 15:10
I'm working on palindromes.
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:10
:point_up: if(blah); is basically saying, "if blah, do nothing"
Marc
@MWBauer
Aug 20 2017 15:10
I need to compare and then report
Stephen James
@sjames1958gm
Aug 20 2017 15:11
That semicolon ends the if statement so the else is unexpected
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:11
; is causing an issue
Marc
@MWBauer
Aug 20 2017 15:12
the else is not well accepted
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:12
@ivancsicsmarkus not really an expert
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:12
Then next line, is return statement which runs unconditionally... followed by the else, which "can't find the if it's attached to" :p
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:12
@ivancsicsmarkus but can try answering your question
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:12
Because else has to come immediately after an if
Marc
@MWBauer
Aug 20 2017 15:13
well...I have the trues....but the falses aren't working.
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:13
@MWBauer post code
Marc
@MWBauer
Aug 20 2017 15:14
function palindrome(x) {
var lowerCase = x.toLowerCase();
//a variable that takes the string and makes it all lowercase//
var lcArray = Array.prototype.filter.call(lowerCase, function(ch) {
return "a" <= ch && ch <= "z" || "0" <= ch && ch <= "9";
});
//this .filter.call takes the string that is lc and makes an array of just the letters//
for (var i = 0; i <= lcArray.length; i++) {
for (var j = 0; j <= lowerCase.length; j++) {
if (i === j) {
return (true);
} else {
return (false);
}}
}}
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:14
@MWBauer if (i==j) just acts as a statement
it always returns true
thats why
Stephen James
@sjames1958gm
Aug 20 2017 15:15
@MWBauer you always return inside the for loop - so it can never loop.
you are comparing indexes not characters
you don't need to loops either
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:15
why are you nesting..
Stephen James
@sjames1958gm
Aug 20 2017 15:16
compare lcArray[i] to lcArray[lcArray.length - 1 - i]
Marc
@MWBauer
Aug 20 2017 15:16
Ya'll are asking questions that I'm not sure I can answer. According to the practices this is what seemed right.
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:16
@sjames1958gm on a seprate note ,
= Array.prototype.filter.call(lowerCase, function(ch) {
@MWBauer logically, you are using one loop inside the other, this is known as nested loops
Marc
@MWBauer
Aug 20 2017 15:17
that I knew
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:17
you are basically comparing each value in one loop to the other
you need to reverse a string and check if its the same when its reversed
Marc
@MWBauer
Aug 20 2017 15:18
right. My thought was to compare one array, then compare the other array, and if they are === absolutely equal then return true.
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:18
but they are the same..
if one array is [a,b,c,d] and the other is [x,y,z]
Marc
@MWBauer
Aug 20 2017 15:18
Ok. in restarting somewhere I must have cut out my reverse.
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:19
even if you reverse, it will be wrong
Marc
@MWBauer
Aug 20 2017 15:19
be back later
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:19
you will loop for every element in a and compare it to each element in the second array
Stephen James
@sjames1958gm
Aug 20 2017 15:19
@MWBauer You need to compare lcArray to the reverse of lcArray (lowerCase still has all the extra characters)
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:19
^
@sjames1958gm Array.prototype.filter.call(lowerCase, function(ch) {
is this a goodway to call filter on a string
i thought its not a best practice to treat it as an array
Stephen James
@sjames1958gm
Aug 20 2017 15:20
@abhinav-thinktank Sure.
Marc
@MWBauer
Aug 20 2017 15:21
Array specifies that we are working with arrays. prototype means...what? Filter is filter the array of ...? call does what? lowerCase is the string it's applied to. Function(ch) means?
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:22
@MWBauer Try running this. https://repl.it/KRBJ/2
koder3
@koder3
Aug 20 2017 15:22
https://jsfiddle.net/2tqja09e/2746/ why doesnt this work?
Stephen James
@sjames1958gm
Aug 20 2017 15:22
@MWBauer Array is the array global object, which has functions stored on it prototype property.
so [].filter and Array.prototype.filter reference the same function
.call allows you to call the function passing the "object" that the function gets called on.
Moisés Man
@moigithub
Aug 20 2017 15:24
@koder3 open devtools... check console tab...click the load buttton
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:26
@sjames1958gm so if i use it like that, does it get cooerced into the array ?
into an array*
Marc
@MWBauer
Aug 20 2017 15:27
Looking back, I'm taking a given string, and I'm removing the special characters and spaces then making it lowercase. Have I gotten that far properly?
koder3
@koder3
Aug 20 2017 15:27
@moigithub the url has to be in https... any workaround?
Huangzhen111
@Huangzhen111
Aug 20 2017 15:27
hello, need help ,is there a simple way?
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:27
@MWBauer yes
Marc
@MWBauer
Aug 20 2017 15:27
score.
Huangzhen111
@Huangzhen111
Aug 20 2017 15:27

function where(arr, num) {
arr = arr.sort(function (a, b){
return a-b;
});

for(var i=0;i<arr.length;i++){ if(num <= arr[i]) { return i;} else if(num>arr[arr.length-1]){
return arr.length;
}

}
}

where([40, 60], 30);

Marc
@MWBauer
Aug 20 2017 15:27
So now I need to make an array that is reversed.
Stephen James
@sjames1958gm
Aug 20 2017 15:27
@Huangzhen111 don't put all your code on one line - hard to read
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:28
Just gonna clean this up a bit.
function where(arr, num) {
   arr = arr.sort(function (a, b){
     return a-b;
   });

  for(var i=0;i<arr.length;i++){
    if(num <= arr[i]) {
      return i;
    } 
    else if(num>arr[arr.length-1]){
      return arr.length;
    }

  }
}

where([40, 60], 30);
Stephen James
@sjames1958gm
Aug 20 2017 15:28
@MWBauer recall the reverse a string challenge
Huangzhen111
@Huangzhen111
Aug 20 2017 15:28
zzz
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:29

@Huangzhen111 For future: if you write it in a code block, it makes it easier to read and allows you to do some formatting. To write it in a code block...
for one line :point_right: ` code goes here `
or for multiple lines :point_down:
```js
code goes here (important: keep backticks and code on a separate line)
```

Also, note that `≠ '
You can also edit your post if you make a mistake by clicking the … that appears when you hover your mouse over your comment

Moisés Man
@moigithub
Aug 20 2017 15:29
@koder3 u can do any of this....
  • find a service with https support...
  • use a https proxy
  • dont use https on fiddle
Marc
@MWBauer
Aug 20 2017 15:29
am I able to use: a.split('').reverse.join('') ?
Huangzhen111
@Huangzhen111
Aug 20 2017 15:30
qaq
Stephen James
@sjames1958gm
Aug 20 2017 15:30
@MWBauer Well you already have the array, so split is not needed
Marc
@MWBauer
Aug 20 2017 15:30
I remember someone saying that sometimes you can stack commands.
Abhinav Mishra
@abhinav-m
Aug 20 2017 15:30
@MWBauer you can..
but try to do it in a way that makes is simple to understand
for yourself at first
you can always refactor to a better solution later
Stephen James
@sjames1958gm
Aug 20 2017 15:31
@Huangzhen111 looks like it works
Huangzhen111
@Huangzhen111
Aug 20 2017 15:32
yeah
it can works
Marc
@MWBauer
Aug 20 2017 15:32
function reverseString(x) {
revArray.reverse().join("");
}
does that look like it should work?
accept that is has to be lowerCase, not x
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:33

@Huangzhen111 You could move this...

else if(num>arr[arr.length-1]){
   return arr.length;
}

to above the for loop and just make it an if statement. There's no need to check this condition more than once.

@MWBauer That reverseString function doesn't make sense. Is x an array or a string? And where is revArray coming from?
Huangzhen111
@Huangzhen111
Aug 20 2017 15:35
move it? it can't work
Marc
@MWBauer
Aug 20 2017 15:35
I'm making revArray, the reverse array. I'm using lowerCase, which is devoid of characters and lower case, and reversing it.
Stephen James
@sjames1958gm
Aug 20 2017 15:36
just revArray = lcArray.reverse().join('');
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:38
@Huangzhen111 https://repl.it/KRBJ/3 Seems to work fine on my end. What test case is it failing?
Huangzhen111
@Huangzhen111
Aug 20 2017 15:38
if num >arr[length-1],it can't work..
where([1,2,3],5)
Stephen James
@sjames1958gm
Aug 20 2017 15:39
@Huangzhen111 you don't need the else if at all
just return array.length after the loop
Huangzhen111
@Huangzhen111
Aug 20 2017 15:39
i see
thx
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:40
@Huangzhen111 nah. That test case works fine. Returns 3. 3 is the 4th index, which is where 5 would be.
WackThat .
@WackThatOriginal
Aug 20 2017 15:40
Why the wincheck function on line 65 doesn't work?
https://codepen.io/WackThat/pen/rzJwjr?editors=1010
Marc
@MWBauer
Aug 20 2017 15:41
The computer is cursing at me when I try to run this code.
I put it in the sandbox you gave me and it isn't pretty.
Huangzhen111
@Huangzhen111
Aug 20 2017 15:41
thx
Stephen James
@sjames1958gm
Aug 20 2017 15:41
@martin50679 you cannot compare arrays with === you will need to compare each value
Marc
@MWBauer
Aug 20 2017 15:41
function palindrome(x) {
var lowerCase = x.toLowerCase();
console.log(lowerCase);
//a variable that takes the string and makes it all lowercase//
var lcArray = Array.prototype.filter.call(lowerCase, function(ch) {
return "a" <= ch && ch <= "z" || "0" <= ch && ch <= "9";
});
console.log(lcArray);
var revArray;
revArray = lcArray.reverse().join("");
}
Stephen James
@sjames1958gm
Aug 20 2017 15:42
@MWBauer Now convert lcArray to a string (without reverse) and compare
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:42
@MWBauer join results in a string. I would consider renaming this variable to something like revStr or reverseStr
Marc
@MWBauer
Aug 20 2017 15:43
sure.
why isn't console.log displaying where I am.
?
what I'm doing?
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:44
@MWBauer FCC console is icky.
Marc
@MWBauer
Aug 20 2017 15:44
lol
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:44
if that's what you're trying to use...
Marc
@MWBauer
Aug 20 2017 15:44
great
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:45
You can open browser console (how to do this depends on browser) and will show what you were attempting to console.log, or can run code on a site like repl.it with a better console
Marc
@MWBauer
Aug 20 2017 15:47
wouldn't revStr = lcArray.join("") make a variable and then join lcArray
?
@kumquatfelafel even repl.it is disgusted with me.
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:48
post code.
Marc
@MWBauer
Aug 20 2017 15:48
talking about anonymous function and r.prototype.emit
function palindrome(x) {
var lowerCase = x.toLowerCase();
//a variable that takes the string and makes it all lowercase//
var lcArray = Array.prototype.filter.call(lowerCase, function(ch) {
return "a" <= ch && ch <= "z" || "0" <= ch && ch <= "9";
});
//this .filter.call takes the string that is lc and makes an array of just the letters//
var revArray;
function reverseString(lowerCase) {
revArray.reverse().join("");
}
revStr = lcArray.join("");
console.log(revStr);
first...
WackThat .
@WackThatOriginal
Aug 20 2017 15:51
@sjames1958gm how do i compare arrays?
Marc
@MWBauer
Aug 20 2017 15:51
I have revArray and I'm trying to assign to it the lowerCase string in reverse, then join it together.
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:51
@martin50679 compare values of individual cells one at a time.
If any of those values is not the same, then those arrays are different.
Marc
@MWBauer
Aug 20 2017 15:52
or reverse it, join it, assign it.
WackThat .
@WackThatOriginal
Aug 20 2017 15:52
@kumquatfelafel look my problem is at the last function, the winCheck() function
Stephen James
@sjames1958gm
Aug 20 2017 15:53
@martin50679 As I said you cannot compare arrays with === you have to compare the elements
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:54
also, not i < winCombinations.... i < winCombinations.length
WackThat .
@WackThatOriginal
Aug 20 2017 15:55
@kumquatfelafel yeah yeah my fault i was doing it too fast
Marc
@MWBauer
Aug 20 2017 15:56
@sjames1958gm the revArray = lcArray.reverse().join("") is going to take the lowercase and reverse it and join it and assign it, right?
that leaves me with a string that's been reversed and joined, right
?
so I will have the lowerCase string and then the revArray string which should be renamed to revStr.
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:58
@MWBauer that will leave you with a reversed lowercase string, yes, assuming that lcArray contains only lowercase characters.
Marc
@MWBauer
Aug 20 2017 15:58
wasn't that the point of the .filter.call?
kumquatfelafel
@kumquatfelafel
Aug 20 2017 15:59
@MWBauer I'm speaking in generalities. But yeah. Your filter call will take care of this ;)
Marc
@MWBauer
Aug 20 2017 15:59
great
thanks
So I have the 2 strings. Is this where I compare?
nature break
ok. i'm back.
Is it easier to compare 2 strings, assuming you can, or comparing 2 arrays, which I know I can.
?
Marc
@MWBauer
Aug 20 2017 16:09
did everyone leave?
Stephen James
@sjames1958gm
Aug 20 2017 16:23
@MWBauer strings you can do str1 === str2
arrays you have to compare every element separately
Marc
@MWBauer
Aug 20 2017 16:31
that's what I was just trying. I now have the false working but not the true. lol
please hold.
function palindrome(x) {
var lowerCase = x.toLowerCase();
//a variable that takes the string and makes it all lowercase//
var lcArray = Array.prototype.filter.call(lowerCase, function(ch) {
return "a" <= ch && ch <= "z" || "0" <= ch && ch <= "9";
});
//this .filter.call takes the string that is lc and makes an array of just the letters//
var revStr; //creates a new variable
function reverseString(lowerCase) {
revStr = lcArray.reverse().join("");
}
//this function takes the lcArray and reverses it, then joins it together into a string
if (revStr === lowerCase) {
return true;
} else {
return false;
}
}
Stephen James
@sjames1958gm
Aug 20 2017 16:35
o @MWBauer convert lcArray to a string - don't use lowerCase it is pre-filtered
Marc
@MWBauer
Aug 20 2017 16:36
lcStr = lcArray.join("")
Stephen James
@sjames1958gm
Aug 20 2017 16:36
@MWBauer yes now you have to strings made from lcArray (one reversed) now compare
Marc
@MWBauer
Aug 20 2017 16:37
ok. thanks
is my if loop right?
true is still not working.
Stephen James
@sjames1958gm
Aug 20 2017 16:39

@MWBauer you if statement (not a loop) is correct. Change:

var revStr; //creates a new variable
function reverseString(lowerCase) {
revStr = lcArray.reverse().join("");
}

to

var revStr = lcArray.reverse().join("");
Marc
@MWBauer
Aug 20 2017 16:40
you're saying that I don't need to declare a function, I just have make a variable and input commands
Stephen James
@sjames1958gm
Aug 20 2017 16:41
Correct - just assign the new variable to the reverse expression
Marc
@MWBauer
Aug 20 2017 16:42
the filter.call will go thru the string and find only the letters and numbers and return them, right?
Stephen James
@sjames1958gm
Aug 20 2017 16:42
correct
Marc
@MWBauer
Aug 20 2017 16:42
it reports what it finds to lcArray
so lcArray is an array of only letters and numbers that have already been lowercased.
Stephen James
@sjames1958gm
Aug 20 2017 16:42
Yes, the terminology would be assigns the return value to lcArray
correct
Marc
@MWBauer
Aug 20 2017 16:42
ok.
the revStr takes that array and reverses it then joins it together back into a string, right?
Morchid Chellali
@Morched23MJ
Aug 20 2017 16:43
What's the regex to use to split a string at the upper case characters, without deleting them?
Marc
@MWBauer
Aug 20 2017 16:44
del c:/**?
lol
then I made a new string, lcStr, that took the lcArray and joined it back together as a string of letters and numbers
does it matter that the lcArray in lcArray.join("") isn't blue, as tho it isn't referencing that variable?
Stephen James
@sjames1958gm
Aug 20 2017 16:46
yes to the first statement
Marc
@MWBauer
Aug 20 2017 16:46
yes to what?
Stephen James
@sjames1958gm
Aug 20 2017 16:47
To the first statement - not sure about the blue part
Morchid Chellali
@Morched23MJ
Aug 20 2017 16:47
Stephen, can you help meh with the RegExp? :l
Marc
@MWBauer
Aug 20 2017 16:47
it seems to me that the code changes color to show that things are happening.
when you create a function or var, it's orange.
Morchid Chellali
@Morched23MJ
Aug 20 2017 16:48
You're right
Marc
@MWBauer
Aug 20 2017 16:48
when you call a command it's green.
when you reference a var it's blue
Morchid Chellali
@Morched23MJ
Aug 20 2017 16:48
If the var.method; is in white color, check if the var name is correct
Marc
@MWBauer
Aug 20 2017 16:48
if it's white.....
Stephen James
@sjames1958gm
Aug 20 2017 16:48
@Morched23MJ I don't think you can split without losing the value you split on
Morchid Chellali
@Morched23MJ
Aug 20 2017 16:48
My goal is to seperate at the uppercase characters, what would you suggest?
Marc
@MWBauer
Aug 20 2017 16:49
could you use a find nth character?
Stephen James
@sjames1958gm
Aug 20 2017 16:49
@Morched23MJ You could replace upper case with space + uppercase then split on space
Morchid Chellali
@Morched23MJ
Aug 20 2017 16:50
Oh yeah, thanks, @sjames1958gm
CamperBot
@camperbot
Aug 20 2017 16:50
morched23mj sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8349 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Morchid Chellali
@Morched23MJ
Aug 20 2017 16:53
I did this replace(/[A-Z]/, ' ') but I have to add the matched character from the RegExp, how to do so?
Marc
@MWBauer
Aug 20 2017 16:54
it says a I have a return statement outside of function
Stephen James
@sjames1958gm
Aug 20 2017 16:54
@Morched23MJ You have to use grouping () to save the upper case letter
@MWBauer Count your } make sure you don't have an extra one before the returns
Marc
@MWBauer
Aug 20 2017 16:55
if (lcStr === revStr) {
return true;
Stephen James
@sjames1958gm
Aug 20 2017 16:55
replace(/([A-Z])/, ' $1 ')
Marc
@MWBauer
Aug 20 2017 16:55
} else {
return false;}
Stephen James
@sjames1958gm
Aug 20 2017 16:55
@MWBauer you may have missed deleting a } before the if (when you removed the function)
Marc
@MWBauer
Aug 20 2017 16:57
GREAT! now the trues are working and the false aren't. lol
what is going on?
function palindrome(x) {
var lowerCase = x.toLowerCase();
//a variable that takes the string and makes it all lowercase//
var lcArray = Array.prototype.filter.call(lowerCase, function(ch) {
return "a" <= ch && ch <= "z" || "0" <= ch && ch <= "9";
});
//this .filter.call takes the string that is lc and makes an array of just the letters//
var revStr = lcArray.reverse().join("");
//this makes a new variable, takes the lcArray and reverses it, then joins it together into a string
var lcStr = lcArray.join("");
if (lcStr === revStr) {
return true;
} else
return false;
}
Stephen James
@sjames1958gm
Aug 20 2017 16:59
@MWBauer Ah, one final thing to know - reverse() changes the array inplace
so reverse() changed lcArray
Move your second join before the first
Marc
@MWBauer
Aug 20 2017 16:59
AH!
thank you.
that's all it was. I wanna' look at that.
lcStr had to happen first so that I would have the array in it's proper order to make the string. then the revStr happens to reverse it and make a string. then I compared them.
Ok....so how do I send you monies?
lots of monies.
thank you.
every lesson passed is more ammo for the next.
Stephen James
@sjames1958gm
Aug 20 2017 17:04
@MWBauer :+1:
Marc
@MWBauer
Aug 20 2017 17:04
at the very least how can I give you these points that everyone is passing around?
Stephen James
@sjames1958gm
Aug 20 2017 17:04
You just click on my name so it shows up in your input and say thanks
Marc
@MWBauer
Aug 20 2017 17:04
@sjames1958gm thanks
Stephen James
@sjames1958gm
Aug 20 2017 17:05
That should have done it :)
Moisés Man
@moigithub
Aug 20 2017 17:05
cbot
CamperBot
@camperbot
Aug 20 2017 17:05
you called?
Elizabeth Paul
@Kowalatam
Aug 20 2017 17:06
lol, no more monies :).
Marc
@MWBauer
Aug 20 2017 17:06
will I see a report of points given?
Elizabeth Paul
@Kowalatam
Aug 20 2017 17:06
thanks @MWBauer
CamperBot
@camperbot
Aug 20 2017 17:06
kowalatam sends brownie points to @mwbauer :sparkles: :thumbsup: :sparkles:
:cookie: 214 | @mwbauer |http://www.freecodecamp.com/mwbauer
Elizabeth Paul
@Kowalatam
Aug 20 2017 17:06
mine worked :)
Marc
@MWBauer
Aug 20 2017 17:06
hmm....
Elizabeth Paul
@Kowalatam
Aug 20 2017 17:06
@sjames1958gm i guess u have too much :)
Marc
@MWBauer
Aug 20 2017 17:06
@sjames1958gm Thanks
CamperBot
@camperbot
Aug 20 2017 17:06
mwbauer sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8350 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Marc
@MWBauer
Aug 20 2017 17:07
maybe caps
?
Elizabeth Paul
@Kowalatam
Aug 20 2017 17:07
i don't think so ,.. dunno
Moisés Man
@moigithub
Aug 20 2017 17:08
u can use abreviations or other languages too.. (i think)
Marc
@MWBauer
Aug 20 2017 17:08
I'm just glad that I could do something.
Moisés Man
@moigithub
Aug 20 2017 17:08
@MWBauer thx
CamperBot
@camperbot
Aug 20 2017 17:08
moigithub sends brownie points to @mwbauer :sparkles: :thumbsup: :sparkles:
Marc
@MWBauer
Aug 20 2017 17:08
that seems like it took a lot out of me and poor Stephen.
CamperBot
@camperbot
Aug 20 2017 17:08
:cookie: 215 | @mwbauer |http://www.freecodecamp.com/mwbauer
Moisés Man
@moigithub
Aug 20 2017 17:08
@Kowalatam ty
CamperBot
@camperbot
Aug 20 2017 17:08
moigithub sends brownie points to @kowalatam :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @kowalatam |http://www.freecodecamp.com/kowalatam
Marc
@MWBauer
Aug 20 2017 17:08
lol
all the thanks work, huh @moigithub
CamperBot
@camperbot
Aug 20 2017 17:09
mwbauer sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3598 | @moigithub |http://www.freecodecamp.com/moigithub
Marc
@MWBauer
Aug 20 2017 17:09
and now we're gonna work on longest words
Elizabeth Paul
@Kowalatam
Aug 20 2017 17:09
@moigithub really... how about mine language.. let me try it wangiri lmao
lol, its language bias... if im using that word right :)
Marc
@MWBauer
Aug 20 2017 17:11
danke @moigithub
yes it is
Elizabeth Paul
@Kowalatam
Aug 20 2017 17:11
wait.. danke is Hausa right ?.. :)
Marc
@MWBauer
Aug 20 2017 17:12
Maybe I will crawl into a Jeffries tube and look into the subroutine and see if we can update the language recognition so that any language thank you can be used.
danke is German for thanks.
or thank you.
Moisés Man
@moigithub
Aug 20 2017 17:14

https://github.com/freeCodeCamp/camperbot/blob/4629d269841c275ba2dc9c8ca95022239059a8bb/data/rooms/RoomMessages.js#L49

regex: /^\@(?:(?:th(?:n[qx]|x)|t[xyq]|tn(?:[x]){0,2})|\w\s[.,]\sthankx{0,2}|thankx{0,2}(?:[uq]|y(?:ou)?)?)|grazie|arigato(?:[u]{0,1})|doumo|gracias?|spasibo|dhanyavaad(?:hamulu)?|o?brigad(?:o|a)|dziekuje|(?:re)?merci|multumesc|shukra?an|danke)\b/gi,

Marc
@MWBauer
Aug 20 2017 17:16
So...what are you trying to say? It's already supporting some but not all>
?
Moisés Man
@moigithub
Aug 20 2017 17:17
dunno.. is included on the source code.. soo should work :D
danke @sjames1958gm
Elizabeth Paul
@Kowalatam
Aug 20 2017 17:18

ahhh, thats where i heard that, i knew i knew it lol

danke is German for thanks.

lol, u are still trying lol
Takk @moigithub
Moisés Man
@moigithub
Aug 20 2017 17:19
(...probably that source is not on production)
...whatever :P.. back to watch animes
Lay
@L-AY
Aug 20 2017 17:42
Working on an Angular2 project:
Receiving the following error: "export 'InjectionToken' was not found in '@angular/core'
After researching online, looks like this is being caused due to not having the latest CLI installed. If I upgrade to the latest CLI mid project would this impact the project entirely?
Thayyeb salim
@Thayyebsalim
Aug 20 2017 18:00
Guys I'm stuck at the Diff Two Arrays
function diffArray(arr1, arr2) {
  arr1=arr1.concat(arr2);
  return arr1.filter(function (a){
    arr1.slice(a);
    return arr1.indexOf(a)<0;
  });
}
Stephen James
@sjames1958gm
Aug 20 2017 18:04
@Thayyebsalim What is your filter function trying to do? arr1.slice(a)
Thayyeb salim
@Thayyebsalim
Aug 20 2017 18:08
Yeah I need to take off and element and search if it's present in the concat array
@sjames1958gm
instead of the whole slice, indexOf thing
Thayyeb salim
@Thayyebsalim
Aug 20 2017 18:30
thanks @Margaret2
CamperBot
@camperbot
Aug 20 2017 18:30
thayyebsalim sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 2890 | @margaret2 |http://www.freecodecamp.com/margaret2
Thayyeb salim
@Thayyebsalim
Aug 20 2017 18:30
I'll try it
koder3
@koder3
Aug 20 2017 18:31
ive realised there are many ways of receiveing data from external sources. however whats more better to use $.getJSON or new XMLHttpRequest(); or using$.ajax
Margaret
@Margaret2
Aug 20 2017 18:34
probably fetch lol :laughing:
it's the new version of XMLHttpRequest
otherwise i would just use getJSON or ajax
ajax was always hard for me to understand :( :(
koder3
@koder3
Aug 20 2017 18:37
@Margaret2 hmm fetch is definitely cleaner thanks. ive just started ajax, only got a issue with URLs itself. haha
CamperBot
@camperbot
Aug 20 2017 18:37
koder3 sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 2891 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Aug 20 2017 18:37
:+1:
Rasmus Biehl
@RasBiehl
Aug 20 2017 19:19
var holder = ["Get busy living, or get busy dying - The Shawshank Redemption"]
var x = document.getElementById("citat");
x.innerHTML = holder.toString();
Why isn't this working?
Stephen James
@sjames1958gm
Aug 20 2017 19:19
@RasBiehl How is it not working? Any errors in the console?
Rasmus Biehl
@RasBiehl
Aug 20 2017 19:20
idk
Stephen James
@sjames1958gm
Aug 20 2017 19:20
I would set textContent - because you are just setting a string - but this should work
Rasmus Biehl
@RasBiehl
Aug 20 2017 19:21
textContent?
what's that?
Stephen James