« first day (3169 days earlier)      last day (2003 days later) » 

05:58
i did the search but all i could get was

either [Array Object] or [object Object]

where [01,2,4,5,6] is [Array Object]
and {a:"s"} is [object Object]

but what i have here is
[{a:"s"},{a:"b"}]
so it makes it the "array of objects or key value pair" this is where the condition is failing, because now

[01,2,4,5,6] is [Array Object] is true
[{a:"s"},{a:"b"}] is also [Array Object] is true
how can i know if object exists in array
and its just not plain array
How can I get Gmail mails between 2 dates using Google Apps script?
06:15
@ARr0w what is the problem?
you have an array there. You are checking its type... so you get "array"
@KarelG

well i handled the scenario like this now:

var isDataValid = false;
        if (Object.prototype.toString.call(obj.data) === "[object Array]") {
            if (obj.data.length > 0) {
                if (Object.prototype.toString.call(obj.data[0]) === "[object Object]") {
                    if (obj.data[0].hasOwnProperty('arg') && obj.data[0].hasOwnProperty('value')) {
                        isDataValid = true;
                    }
                }
            }
        }

        if (!isDataValid) {
is this good approach ?
erhm why are you checking for array if you only need an object with those 2 keys?
i need array of objects
i'm generating a chart
then you have to check each objects in it btw
best to do this
[0,1,2,3,4] = I want to throw error if user passes this
[] = or this
[{}] = or this
[{ otherParam: "other" }] = or this.

i specifically want user to pass this = [{args: "argument", value: "value"}.....] = true
06:28
function isValid(data) {
  if (!Array.isArray(data) {
    data = [data];
  }
  return data.every( ...check object... );
}
hmm okay
cool
nice handling.
like obj => Object.keys(obj).filter(key => key === 'args' || key === 'value' ).length === 2
or better, use reduce every
const requiredKeys = ['args', 'value'];
...
return data.every(obj, requiredKeys.every(reqKey => obj.hasOwnProperty(reqKey));
the ... is those other lines in that function
Is there any elegant way to handle react-router without hardcoding strings and working with params such as ':id' ? I am using typescript as well.
06:55
@KarelG jsfiddle.net/xved186f it still returning true if i am changing the Keynames
even this
     isDataValid = bc.every(one => one.hasOwnProperty('arg') === true && one.hasOwnProperty('value') === true);

is still returning true if i am changing the key names from the obj array
ok nvm, it works now :S
https://jsfiddle.net/xved186f/1/
this is what my code looks like now .

const requiredKeys = ['arg', 'value'];

        if (!Array.isArray(obj.data)) {
            obj.data = [obj.data];
        }

        if (obj.data.every(one => requiredKeys.every(reqKey => one.hasOwnProperty(reqKey)))) {
            throw "\nSelector:" + s +".\nParameter is Undefined or invalid data provided.\nData object Array [{arg: 'anyArgs', value: 'any Value' }...] expected.";
        }
thanks man <3
@omidnematollahi Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
07:12
@ARr0w you have to negate it btw
Hi can anyone please tell me, which one is more preferred way for handling logics in redux
1. Handling all API callings and everything in the redux action and passing data to the reducer
2. Handling all API calling and everything in the component and then pass the data to the redux action which in-turn call a reducer for updating the state?
08:10
@user7747472 The best one is to handle that in sagas. But if you are not using sagas you should do it in redux action.
@ShivaPandey Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
08:23
I am not using redux saga, so I think I should go with handling logics in the Action bar.
08:33
Guys, I am new to angular unit testing. Can someone take a look at this please?
https://stackoverflow.com/questions/56681338/angular-unit-testing-is-this-code-worth-unit-testing
 
1 hour later…
09:38
Hi, can anyone please tell me how to add a callback function to a redux action or anything as such so that when an action is completed i can do other things.

For example. I want to login in user with email and password, for that i called an action which handle that something like this
My action

export function loginUser(email,password) {
    axios.(headerWithData).then(response => {
        if(response.success){
            updateUserData(response.data);
            //And now i want to notify the component the action has been completed.
o.o
use await ?
wait for the response and let it return a value that you want to use in the component
if i use await it will not render or execute the remaining block of the code untill it get response right ? :3
10:01
true
hmm thats a problem then XD
 
1 hour later…
11:19
anyone has experience with MongoDB ?
please I have one quick question
!!welcome milemijatovic
@milemijatovic Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
Thank you
I need to pass search query parameters
I tried like this
```
    // Patient search condition, based on selected option from select dropdown
    function searchCondition() {
        if (criterionSearchCategory == 'undefined') {
            return { };
        } else if (criterionSearchCategory == 'age') {
            return { [criterionSearchCategory]: { [ageSearchCategory] : Number([searchInputValue]) }}
        } else {
            return { [criterionSearchCategory]: { $in: [ "/^" + searchInputValue + "/i" ]}}
        }
    }

    const patientQuery = Patient.find(searchCondition);
```

const criterionSearchCategory = req.query.kriterijumPretrage;
const ageSearchCategory = req.query.kriterijumGodina;
const searchInputValue = req.query.pojamPretrage;
```
I tried to pass the function in Patient.find(searchCondition)
Is that Mongoose?
but does not work
Yes , mongoose
11:27
Can you use $in with regex?
Also it needs to be an actual regex IIRC, not a string
const patientQuery = Patient.find({ age: { '$gt': 50 } });
So something like $in: [ new RegExp(searchInputValue, 'i') ]
@BenFortune If I manually pass the query param
this works
but when I pass the function, does not work
So your age block isn't working?
Yes , does not work
when I click on the Search button, all patients are fetched
condition is ignored
11:30
So I guess you have something like kriterijumPretrage=age&kriterijumGodina=$gt&pojamPretrage=40
Yes
```
const queryParams = `?pacijenataPoStranici=${patientsPerPage}&trenutnaStranica=${currentPage}&kriterijumPretrage=${criterionSearchCategory}&pojamPretrage=${searchInputValue}&kriterijumGodina=${ageSearchCategory}`;
        this.http
            .get<{ message: string, patients: any, maxPatients: number }>( BACKEND_URL + queryParams)
            // Execute map on every data that makes it through Observable stream
            .pipe(map((patientData) => {
```
I will repeat my question
If I have

` const patientQuery = Patient.find({ age: { '$gt': 50 } });`
this works good
but if I have this
` const patientQuery = Patient.find(searchCondition);`

does not work
searchCondition is a function
@MileMijatovic does it return an object that can be used?
does not return nothing I guess
because when I console.log
req.query
I dont see that query params anywhere
but when I pass the query params manually, I see query params correctly
11:53
anyone can help me ?
12:10
check the function itself ...
do you have some time for teamviewer please ?
I will send you my credentials
hello guys
can someone help me with currency pipe?
in angular
pozdrav Mile :)
Pozdrav
:D
imas li ti iskustva s ovim sto sam pitao ?
ovo je obican js?
Da
node.js
i Express framework
12:24
English in here fellas.
@MileMijatovic if the function is small, you can copy over it
12:41
Well hello, Mr. English
12:52
He does exist Neil!
Meet Johnny English.
I think he's fictional
sure he is lol
lol
When discussing @ViewChild decorator in angular - is this just a naming convention or does @ViewChild actually use the decorator pattern?

https://blog.angular-university.io/angular-viewchild/
13:21
Hmm can anyone explain to me why react.createState() and state hooks is a good idea? Doesn't using such hooks completely beat the idea of a functional component (in being non pure). And since it does so: what is the advantage of such a "stateful functional component" over class components?
hey i'm building a chrome extension with one of those calls
Events
onBeforeNavigate
onCommitted
onDOMContentLoaded
onCompleted
onErrorOccurred
onCreatedNavigationTarget
onReferenceFragmentUpdated
onTabReplaced
onHistoryStateUpdated
chrome.webNavigation.(((((EVENT))))).addListener(function() {
   alert("worked");
});
the problem is whenever i use any of them , the function fires multiple times
i basically need to send something bk to the server and return a respond from it once the page loads
I see the introduction as rather a step backwards: no longer can I notice if a component is stateful or pure by just looking at the definition. I now have to delve into the code to look for any place where potentially useState is used. (I recognize good coding practices should make the use clear, but if a bug happens we will have to consider "hmm maybe the practices aren't followed and that caused the bug").
 
1 hour later…
14:53
JS Man
15:09
/not-me
15:27
@paul23 i haven't looked into hooks at all... so i hate them
nice
 
2 hours later…
17:12
Generating a square based on a number entered. I have this:
function generateShape(num) {
  let shape = [];
  // create rows
  for (let i = 0; i < num; i++){
    // create columns
    for (let j = 0; j < num; j++){
      shape += "+";
    }
      shape += "\n";
  }
  return shape;
}

console.log(generateShape(3));
And it works in the console, but does not pass the test on codewars:
https://www.codewars.com/kata/build-a-square/train/javascript
And that is because it's adding \n to the final row. But I don't know how to get rid of the \n when it is the final row.
Oh, well I could just slice off the last \n...
function generateShape(num) {
  let shape = [];
  // create rows
  for (let i = 0; i < num; i++){
    // create columns
    for (let j = 0; j < num; j++){
      shape += "+";
    }
      shape += "\n";
  }
  shape = shape.slice(0, -1);
  return shape;
}
Yeah nvm that works : )
17:29
I have a question about tooling, do any of you have suggestions for automatically alphabetizing functions in a js file?
17:46
if they're object keys
user8729657
thats cool
18:10
export default {
    Tabs: {
        DOWNLOAD_TAB: 0,
        SETTINGS_TAB: 1,
        HISTORY_TAB: 2,
    }
}
is there a away to import the Tabs with object destructuring?
something like:
import {Tabs} from '../../enum.js';
21
Q: Destructuring a default export object

sfletcheCan I destructure a default export object on import? Given the following export syntax (export default) const foo = ... function bar() { ... } export default { foo, bar }; is the following import syntax valid JS? import { foo, bar } from './export-file'; I ask because it DOES work on my...

that answers it
18:30
heh, jquery
0
A: Reputation dropdown on mobile is broken

Brian NickelThis is fixed. I made some accessibility related improvements to the topbar (tabbing and screen readers) which involved moving where in the DOM we placed the topbar. To ensure control flowed from the button to the dialog it generated, the dialog needed to appear between the current and the next...

user1596138
@KevinB why tho
user1596138
I feel that generally speaking alphabetical sorting isn't beneficial for object keys.
i wasn't suggesting it was a good idea
user1596138
I group by relevance
user1596138
18:36
Oh yea I'm not saying you were
or useful etc
:p
user1596138
I'm just asking.
19:31
ew
loose equals
20:25
!!refresh
!!magic
(∩ ͡° ͜ʖ ͡°)⊃━☆゚. * ・ 。 ᵀᴴᴱ ᴳᴬᴹᴱ
$(location).attr('href',"2.php");
20:42
How do I split up react logic? My app.js is cluttered with lots of logic that should probably be separated.
one component per file
20:57
Yeah but isn't compontent and logic supposed to be split?
My components are one file each but all the logic is stuffed into app.js
If you're splitting components and logic, usually you'd have a container for each component which contain the logic
That article seems like it explains the container and component setup
Kevin doesn't seem to like it though
Or he's ew-ing about you having all your logic in one file lol
Or both ;)
21:04
^
A quick question - if I'm trying to find the letter in a string that appears the most....
My issue with the container idea is that since all my components need to access each other's states, I put all the states in the "closest common ancestor", which happens to be App.js. So each container cant have states, so it doesn't solve the issue.
^ This will create a frequency map. Now what is the best way to find the key with the highest value in that frequency map?
@HappyHands31 Please stop with your .split(""). Use Array.from
1 message moved to Trash can
@HappyHands31 Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. For posting large code blocks, use a paste site like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
21:07
function highest (string) {
  let frequencyMap = {};
  let array = string.split("");
  array.forEach((value, index) => {
    if (!frequencyMap[value]) {
      frequencyMap[value] = 0;
    }
    frequencyMap[value] += 1;
  });
  console.log(frequencyMap);
}
console.log(highest("helloWorld"));
@JBis okay that is good to know. It seems to always create an array of characters? Better to use .split(" ") if you want to create an array of words?
Could use some state management libraries or the built-in react one (that I forget the name of) if you're on react 16.8(?)
There are a couple of other ways I think as well
I wonder if its dumb to just write functions in separate files and then require()/import them in
Idk, following that solution I have:
function highest (string) {
  let frequencyMap = {};
  let maxKey = "";
  let array = Array.from(string);
  for (let i = 0; i < string.length; i++) {
    let character = string[i];
    console.log(character);
    if(!frequencyMap[character]){
     frequencyMap[character] = 0;
    }
    frequencyMap[character]++;
    if (maxKey == "" || frequencyMap[character] > frequencyMap[maxKey]) {
        maxKey = character;
    }
  }
}
console.log(highest("hello World"));
Gets me the frequency map, but the maxKey comparison isn't working...
21:23
-1
Q: Select by .attr quiz

GogaI want to create a simple quiz. Any word fits into the text field, and if the word is correct, a class is set that changes color. Spent a lot of time. Please help correct the error! var answer = $('span').attr('data-answer'); var submitted = $('input').val(); $('.submit').on('click', f...

@Cerbrus are you single?
One of my friends wants to know
21:36
This works
 function highest (string) {
  let array = Array.from(string);
  let frequencyMap = {};
  let highest = "";
  for (let i = 0; i < array.length; i++) {
    let character = array[i];
    if(!frequencyMap[character]){
     frequencyMap[character] = 0;
    }
    frequencyMap[character]++;
    if (highest == "" || frequencyMap[character] > frequencyMap[highest]) {
        highest = character;
    }
  }
  return highest;
}
console.log(highest("hello World"));
21:59
One of your friends? Now I’m curious how I’m the subject of one of your friends’ discussion, @BadgerCat
🛡

« first day (3169 days earlier)      last day (2003 days later) »