[Solved] Where did I make the mistake of changing my search filter? And how to fix it?

An example value of x[“planeTypeID.code”] is “B734”, of state.day “23-08-2019” => those are 2 different fields => you will get an empty array when you filter by x[“planeTypeID.code”].includes(state.day) ¯\_(ツ)_/¯ After debugging via comments, the most likely solution is: x[“planeTypeID.code”].toLowerCase().includes(action.search || state.search) I recommend to Get Started with Debugging JavaScript as a generic first step to … Read more

[Solved] JavaScript Arithmetic Operators…where are they?

They’re known as infix operators, and they’re inbuilt, and act like Function prototypes. It’s interesting to note that regular JavaScript doesn’t support things like exponentiation through infix operators, and you’re forced to resort to an extension of Math: console.log(Math.pow(7, 2)); Although ES6 fixes this: console.log(7 ** 2); Although you can’t create your own infix operators, … Read more

[Solved] Merge objects in an array if they have the same date

This is a good use case for reduce. const rawData = [ { date: ‘3/10/2019’, a: ‘123’, }, { date: ‘3/10/2019’, b: ‘456’, }, { date: ‘3/11/2019’, a: ‘789’, }, { date: ‘3/11/2019’, b: ‘012’, }, { date: ‘3/11/2019’, c: ‘345’, } ]; const groupByDate = array => array.reduce((results, item) => { const current = … Read more

[Solved] Pick data from array of objects and return new object

This really is a simple one liner via map and delete or map and ES6 destructuring as shown in the 2 examples bellow: var data = [{ “first”: “Linda”, “last”: “Donson”, “salary”: “4000USD” }, { “first”: “Mark”, “last”: “Sullivan”, “salary”: “3500USD” } ] console.log(data.map(x => delete(x.salary) && x)) Also if you are concerned about mutating … Read more

[Solved] Making new array and push there keys on that new array [closed]

You can use Object.keys() and .reduce() method: let data = {‘Achievement’: [“110”, “100”, “104”, “110”],’Emp Code’ : [“1000001”, “1000001”, “1000001”, “1000001”],’Product’ :[“Product A “, “Product B”, “Product A “, “Product B”],’Reportee Name’ :[“Harry”, “Harry”, “Peter”, “Peter”],’Target’ : [“116”, “94”, “105”, “114”],’percentage’: [“94.82758621”, “106.3829787”, “99.04761905”, “96.49122807”]}; let result = Object.keys(data) .reduce((a, c, i) => (a[i] = … Read more

[Solved] Logo on mobile view not centered [closed]

with this css your can align your logo to center: @media screen and (max-width: 767px) { .header-content-one .d-flex { display: flex; justify-content: center; } .header-content-one .d-flex a{ width: 100%; } } I’ve setted up a breakpoint to 767px (the code work only for smaller screen) change it to the measure you want. 1 solved Logo … Read more

[Solved] Sort out array of object using its value [duplicate]

Use String.localeCompare() with the numeric option to sort using possibility, but use – (minus) to get descending results. If the comparison returns 0 (equals), use localeCompare again to compare the names: const array = [{“name”:”fever”,”possibility”:”20%”},{“name”:”hiv”,”possibility”:”25%”},{“name”:”heart-attack”,”possibility”:”20%”},{“name”:”covid”,”possibility”:”40%”}] const result = array.sort((a, b) => -a.possibility.localeCompare(b.possibility, undefined, { numeric: true }) || a.name.localeCompare(b.name) ) console.log(result) solved Sort out array … Read more

[Solved] Javascript Mediasource play video and audio simultaneously?

if you need to play both of video and sound you need to create 2 source buffers . and as you said . you can play just one of them . so i guess you code is fine . so you need to create 2 buffers . like this my_media_source.addEventListener(“sourceopen”,function (){ var video_source_buffer = my_media_source.addSourceBuffer(video_mimeCodec); … Read more

[Solved] Why is set.timeout not working in this php while loop?

You cannot really use the setTimeout() function as you suggest… I guess this is roughly what you are looking for: echo <<< EOT <script type=”text/javascript”> setTimeout(function() { window.open(‘https://mywebsite/$link’, ‘_blank’); }, 1000); </script> EOT; Note: I just use the nowdoc notation since it is easier to read. Certainly it is possible to use a normal literal … Read more

[Solved] how to properly use recursive function to go through multiple nested objects

Change your data to this: $scope.subjectAreas = [{ name: “Area-1”, link: “dashboards.dashboard_1”, entities: [{ name: ‘entities’, entities: [{ name: “entity 1” }, { name: “entity 2” }] }, { name: ‘offerings’, entities: [{ name: “offering 1” }, { name: “offering 2” }] }] }, { name: “Area-2”, link: “dashboards.dashboard_1”, entities: [{ name: “entity 3” }], … Read more

[Solved] Javascript function declaration issue [duplicate]

this is the issue about the scope where the functions has been declared. if you run this code in browser it will work all fine, as both function and function expression are declared in global scope. but here in fiddle it’s failing as function expression has been assigned to a global variable ‘foo2’ so it’s … Read more