Below is my JSON object in which I want to remove the groupType from the group that dosen't have trips.ie.,trips.length===0.And also want to remove the entire client object if all the trips array is empty for that particular client object..
let fruitsArray= [
{
"fruit": {
"id": 1,
"name": "Mango"
},
"group": [
{
"groupType": {
"id": 1,
"name": "A"
},
"trips": []
},
{
"groupType": {
"id": 2,
"name": "B"
},
"trips": []
},
{
"groupType": {
"id": 3,
"name": "C"
},
"trips": []
},
{
"groupType": {
"id": 4,
"name": "D"
},
"trips": []
}
]
},
{
"fruit": {
"id": 1,
"name": "Apple"
},
"group": [
{
"groupType": {
"id": 1,
"name": "A"
},
"trips": []
},
{
"groupType": {
"id": 2,
"name": "B"
},
"trips": [
{
"trip": {
"id": 62,
"deliverySlotId": 900000000000001
}
}
]
},
{
"groupType": {
"id": 3,
"name": "C"
},
"trips": []
},
{
"groupType": {
"id": 4,
"name": "D"
},
"trips": []
}
]
},
{
"fruit": {
"id": 95,
"name": "Banana"
},
"group": [
{
"groupType": {
"id": 4,
"name": "A1"
},
"trips": [
{
"trip": {
"id": 62,
"deliverySlotId": 900000000000001
}
},
{
"trip": {
"id": 63,
"deliverySlotId": 900000000000001
}
},
{
"trip": {
"id": 65,
"deliverySlotId": 900000000000001,
"orderId": 22
}
}
]
}
]
}
]
The code that I have tried returns all the elements with 0 groupType..
let finalArray = fruitsArray.map((group) => {
return group.group.filter((trip) => {
return trip.trips.length > 0;
})
})
You can use map combined with filter.
Alternatively you can also use the reduce method.
I wrote both examples beneath.
let fruitsArray= [
{
"fruit": {
"id": 1,
"name": "Mango"
},
"group": [
{
"groupType": {
"id": 1,
"name": "A"
},
"trips": []
},
{
"groupType": {
"id": 2,
"name": "B"
},
"trips": []
},
{
"groupType": {
"id": 3,
"name": "C"
},
"trips": []
},
{
"groupType": {
"id": 4,
"name": "D"
},
"trips": []
}
]
},
{
"fruit": {
"id": 1,
"name": "Apple"
},
"group": [
{
"groupType": {
"id": 1,
"name": "A"
},
"trips": []
},
{
"groupType": {
"id": 2,
"name": "B"
},
"trips": [
{
"trip": {
"id": 62,
"deliverySlotId": 900000000000001
}
}
]
},
{
"groupType": {
"id": 3,
"name": "C"
},
"trips": []
},
{
"groupType": {
"id": 4,
"name": "D"
},
"trips": []
}
]
},
{
"fruit": {
"id": 95,
"name": "Banana"
},
"group": [
{
"groupType": {
"id": 4,
"name": "A1"
},
"trips": [
{
"trip": {
"id": 62,
"deliverySlotId": 900000000000001
}
},
{
"trip": {
"id": 63,
"deliverySlotId": 900000000000001
}
},
{
"trip": {
"id": 65,
"deliverySlotId": 900000000000001,
"orderId": 22
}
}
]
}
]
}
];
var filteredFruits = fruitsArray.map((fruit) => {
fruit.group = fruit.group.filter((group) => group.trips.length);
return fruit;
}).filter((fruit) => fruit.group.length);
console.log(filteredFruits);
// alternative example with reduce
var reducedFruits = fruitsArray.reduce((prev, next) => {
next.group = next.group.filter((group) => group.trips.length);
return next.group.length ? prev.concat([next]) : prev;
}, []);
console.log(reducedFruits);
var fruitsArray= [
{
"fruit": {
"id": 1,
"name": "Mango"
},
"group": [
{
"groupType": {
"id": 1,
"name": "A"
},
"trips": []
},
{
"groupType": {
"id": 2,
"name": "B"
},
"trips": []
},
{
"groupType": {
"id": 3,
"name": "C"
},
"trips": []
},
{
"groupType": {
"id": 4,
"name": "D"
},
"trips": []
}
]
},
{
"fruit": {
"id": 1,
"name": "Apple"
},
"group": [
{
"groupType": {
"id": 1,
"name": "A"
},
"trips": []
},
{
"groupType": {
"id": 2,
"name": "B"
},
"trips": [
{
"trip": {
"id": 62,
"deliverySlotId": 900000000000001
}
}
]
},
{
"groupType": {
"id": 3,
"name": "C"
},
"trips": []
},
{
"groupType": {
"id": 4,
"name": "D"
},
"trips": []
}
]
},
{
"fruit": {
"id": 95,
"name": "Banana"
},
"group": [
{
"groupType": {
"id": 4,
"name": "A1"
},
"trips": [
{
"trip": {
"id": 62,
"deliverySlotId": 900000000000001
}
},
{
"trip": {
"id": 63,
"deliverySlotId": 900000000000001
}
},
{
"trip": {
"id": 65,
"deliverySlotId": 900000000000001,
"orderId": 22
}
}
]
}
]
}
]
for(var i=0;i<fruitsArray.length;i++){
var currentFruit = fruitsArray[i];
var currentFruitGroups = currentFruit.group;
var foundTrip =false;
for(var j=0;j<currentFruitGroups.length;j++){
var currentTrips = currentFruitGroups[j].trips;
if(!currentTrips.length){
currentFruitGroups.splice(j,1);
j--;
}else{
foundTrip = true;
}
}
if(!foundTrip){
fruitsArray.splice(i,1);
i--;
}
}
console.log(fruitsArray);
https://jsfiddle.net/485ue5zs/1/
let finalArray = fruitsArray.reduce((p, n) => {
const gt = n.group.filter(g => g.trips.length);
return gt.length ? p.concat({fruit: n.fruit, group: gt}) : p;
}, []);
Related
How to find name using id. means iterate object. create a function const searchName =()=>{}
suppose if pass 3 in function so I'd want to show .... what the name of user like this
const data = [{
"service": [
"BUSINESS",
"LEGAL",
"FINANCE",
"ADVERTISEMENT"
],
"service1": [
{ "id": 1, "name": "a" },
{ "id": 2, "name": "b" },
{ "id": 3, "name": "c" },
{ "id": 4, "name": "d" },
],
"service2": [
{ "id": 5, "name": "e" },
{ "id": 6, "name": "f" },
{ "id": 7, "name": "g" },
{ "id": 8, "name": "h" },
],
"service3": [
{ "id": 9, "name": "i" },
{ "id": 10, "name": "j" },
{ "id": 11, "name": "k" },
{ "id": 12, "name": "l" },
],
"service4": [
{ "id": 13, "name": "m" },
{ "id": 14, "name": "n" },
{ "id": 15, "name": "o" },
{ "id": 16, "name": "p" },
],
}
]
suppose user pass 3 so I want to return { "id": 3, "name": "c" } like this.
I'm trying to iterate this and find the name of the user by id but I didn't understand this iteration so I need your help.
check this code.... Enter any id number
const data = [{
"service": [
"BUSINESS",
"LEGAL",
"FINANCE",
"ADVERTISEMENT"
],
"service1": [
{ "id": 1, "name": "a" },
{ "id": 2, "name": "b" },
{ "id": 3, "name": "c" },
{ "id": 4, "name": "d" },
],
"service2": [
{ "id": 5, "name": "e" },
{ "id": 6, "name": "f" },
{ "id": 7, "name": "g" },
{ "id": 8, "name": "h" },
],
"service3": [
{ "id": 9, "name": "i" },
{ "id": 10, "name": "j" },
{ "id": 11, "name": "k" },
{ "id": 12, "name": "l" },
],
"service4": [
{ "id": 13, "name": "m" },
{ "id": 14, "name": "n" },
{ "id": 15, "name": "o" },
{ "id": 16, "name": "p" },
],
}]
var itemobj = ''
const searchName =(val)=>{
console.log('searchname')
data.map((item)=>{
let obj = Object.keys(item)
obj.map((data)=>{
let inrdata = item[data]
inrdata.map((initem)=>{
let lastdata = initem.id===val?itemobj=initem:null
})
})
})
}
searchName(3)
console.log(itemobj)
function searchName(id) {
let result = null;
for (const [key, value] of Object.entries(data)) {
if (key === "service") continue
result = value.filter(obj => {
return obj.id === id
})
if (result) break
}
return result ? result[0] : null
}
I iterate through keys, I just skip "service" one since it's not revelant.
Then, I filter the "serviceN" array, it will return an array of object (only one if found, empty array if not found).
If it's found, we stop iterating.
Then we return either the first (and logically only element) or null if not found
You could use a combination of flat and find to get get the user by id
function searchName(id) {
return data
.flatMap((item) => Object.values(item))
.flat()
.find((user) => user.id === id);
}
const result = searchName(3); // { id: 3, name: 'c' } | undefined
I'm developing an application and have added new items to my array: type and description.
array = [
{
"id": 1,
"description": "item1",
"date": {
"id": 1,
"name": "202001"
},
"item": {
"id": 1,
"name": "I1"
},
"type": {
"id": 1,
"name": "type1"
},
"price": 100
},
{
"id": 2,
"description": "item1",
"date": {
"id": 2,
"name": "202002"
},
"item": {
"id": 1,
"name": "I1"
},
"type": {
"id": 1,
"name": "type1"
},
"price": 200
},
{
"id": 3,
"description": "item1",
"date": {
"id": 2,
"name": "202002"
},
"item": {
"id": 2,
"name": "I2"
},
"type": {
"id": 2,
"name": "type2"
},
"price": 300
},
]
I previously did this to reduce it down to an easier way to map it:
items = array.reduce((acc, e) => {
if (!acc[e["item"]["name"]]) {
acc[e["item"]["name"]] = {
[e["date"]["name"]]: e["price"]
}
} else {
acc[e["item"]["name"]][e["date"]["name"]] = e["price"]
}
return acc
}, {})
To show the data before I did
const dates = [...new Set(Object.keys(items_dicc).map(i => Object.keys(items_dicc[i])).flat())]
{
Object.keys(items_dicc).map((item) => {
return (
<tr>
<td>{item}</td>
{dates.map((date) => <td>{items_dicc[item][date] || ''}</td>)}
</tr>
)
})
}
I need to add the description element and type.name to the above. For example for description:
description: e["description"]
To display the elements as in the table:
ITEM
DESCRIPTION
TYPE
202001
202002
I1
item1
type1
100
200
I2
item3
type2
-
300
How do I add and show?
EDIT: console.log(items_dicc[item])
{202001: 100, 202002: 200, description: "item1", type: "type1"}
202001: 100
202002: 200
description: "item1"
type: "type1"
__proto__: Object
{202002: 300, description: "item3", type: "type2"}
202002: 300
description: "item3"
type: "type2"
__proto__: Object
You can add the description and type attribute inside the reduce method like this,
array = [
{
"id": 1,
"description": "item1",
"date": {
"id": 1,
"name": "202001"
},
"item": {
"id": 1,
"name": "I1"
},
"type": {
"id": 1,
"name": "type1"
},
"price": 100
},
{
"id": 2,
"description": "item2",
"date": {
"id": 2,
"name": "202002"
},
"item": {
"id": 1,
"name": "I1"
},
"type": {
"id": 1,
"name": "type1"
},
"price": 200
},
{
"id": 3,
"description": "item3",
"date": {
"id": 2,
"name": "202002"
},
"item": {
"id": 2,
"name": "I2"
},
"type": {
"id": 2,
"name": "type2"
},
"price": 300
},
]
items = array.reduce((acc, e) => {
if (!acc[e["item"]["name"]]) {
acc[e["item"]["name"]] = {
[e["date"]["name"]]: e["price"],
'description': e['description'],
'type': e.type?.name,
}
} else {
acc[e["item"]["name"]][e["date"]["name"]] = e["price"]
}
return acc
}, {})
console.log(items);
To add the for description and name in the table,
const dates = [...new Set(Object.keys(items_dicc).map(i => Object.keys(items_dicc[i])).flat())]
{
Object.keys(items_dicc).map((item) => {
return (
<tr>
<td>{item}</td>
<td>{items_dicc[item]?.description}</td>
<td>{items_dicc[item]?.type}</td>
{dates.map((date) => <td>{items_dicc[item][date] || ''}</td>)}
</tr>
)
})
}
I have been seeing your question regarding these type of tables from yesterday. You have posted several questions with similar things. I suggest you to read some article and understand how JS array methods works instead of asking incremental questions in SO.
Asking in SO might solve your problems for now, but in the long run you will suffer as you don't seem to have a grip on how these things works.
you can simplify your solution like this.
const array = [{
"id": 1,
"description": "item1",
"date": {
"id": 1,
"name": "202001"
},
"item": {
"id": 1,
"name": "I1"
},
"type": {
"id": 1,
"name": "type1"
},
"price": 100
},
{
"id": 2,
"description": "item2",
"date": {
"id": 2,
"name": "202002"
},
"item": {
"id": 1,
"name": "I1"
},
"type": {
"id": 1,
"name": "type1"
},
"price": 200
},
{
"id": 3,
"description": "item3",
"date": {
"id": 2,
"name": "202002"
},
"item": {
"id": 2,
"name": "I2"
},
"type": {
"id": 2,
"name": "type2"
},
"price": 300
}
]
const result = array.map(item => {
return Object.keys(item).reduce((a, c) => {
if (c === "date") {
a[item[c].name] = item.price;
} else if (c !== "price" && c !== "id") {
a[c] = (typeof item[c] === "object") ? item[c].name : item[c];
}
return a;
}, {})
});
console.log(result);
let obj = {
"options": [
{
"id": "a",
"name": "a",
"options": [
{
"id": "a.1",
"options": [
{
"id": "a.1.1",
"name": "a.1.1"
},
{
"id": "a.1.2",
"name": "a.1.2"
},
{
"id": "a.1.3",
"name": "a.1.3"
}
]
},
{
"id": "a.2",
"name": "a.2",
"options": [
{
"id": "a.2.1",
"name": "a.2.1"
},
{
"id": "a.2.2",
"name": "a.2.2"
},
{
"id": "a.2.3",
"name": "a.2.3"
}
]
},
{
"id": "a.3",
"name": "a.3",
"options": [
{
"id": "a.3.1",
"name": "a.3.1"
},
{
"id": "a.3.2",
"name": "a.3.1"
},
{
"id": "a.3.3",
"name": "a.3.1"
}
]
}
]
},
{
"name": "b",
"id": "b",
"options": [
{
"id": "b.1",
"name": "b.1",
"options": [
{
"id": "b.1.1",
"name": "b.1.1"
},
{
"id": "b.1.2",
"name": "b.1.2"
},
{
"id": "b.1.3",
"name": "b.1.3"
}
]
},
{
"id": "b.2",
"name": "b.2",
"options": [
{
"id": "b.2.1",
"name": "b.2.1"
},
{
"id": "b.2.2",
"name": "b.2.2"
},
{
"id": "b.2.3",
"name": "b.2.3"
}
]
},
{
"id": "b.3",
"name": "b.3.1",
"options": [
{
"id": "b.3.1",
"name": "b.3.1"
},
{
"id": "b.3.2",
"name": "b.3.2"
},
{
"id": "b.3.3",
"name": "b.3.3"
}
]
}
]
},
{
"id": "c",
"name": "c",
"options": [
{
"id": "c.1",
"name": "c.1",
"options": [
{
"id": "c.1.1",
"name": "c.1.1"
},
{
"id": "c.1.2",
"name": "c.1.2"
},
{
"id": "c.1.3",
"name": "c.1.3"
}
]
},
{
"id": "c.2",
"name": "c.2",
"options": [
{
"id": "c.2.1",
"name": "c.2.1"
},
{
"id": "c.2.2",
"name": "c.2.2"
},
{
"id": "c.2.3",
"name": "c.2.3"
}
]
},
{
"id": "c.3",
"name": "c.3",
"options": [
{
"id": "c.3.1",
"name": "c.3.1"
},
{
"id": "c.3.2",
"name": "c.3.2"
},
{
"id": "c.3.3",
"name": "c.3.3"
}
]
}
]
}
]
}
" I have this object
I neeed to create a function getHierarchy, that an option ID as its input, finds the option in the
list and returns the ID of all it's parents.
for example,getHierarchy("a.1.3") should return the following result ["a","a.1","a.1.3"]
getHierarchy("c.3.3") should return the following result ["c","c.3","c.3.3"] "
assuming id is unique;
function getHierarchy(object, id, prev) {
if (!object.options) return;
for (const child of object.options) {
if(child.id === id) {
return [...prev, object.id, child.id];
}
result = getHierarchy(child, id, [...prev, object.id]);
if (result) return result;
}
}
getHierarchy(obj, "a.1.3", []);
Here an recursive solution i hope this helps you.
let obj = {
"options": [
{
"id": "a",
"name": "a",
"options": [
{
"id": "a.1",
"options": [
{
"id": "a.1.1",
"name": "a.1.1"
},
{
"id": "a.1.2",
"name": "a.1.2"
},
{
"id": "a.1.3",
"name": "a.1.3"
}
]
},
{
"id": "a.2",
"name": "a.2",
"options": [
{
"id": "a.2.1",
"name": "a.2.1"
},
{
"id": "a.2.2",
"name": "a.2.2"
},
{
"id": "a.2.3",
"name": "a.2.3"
}
]
},
{
"id": "a.3",
"name": "a.3",
"options": [
{
"id": "a.3.1",
"name": "a.3.1"
},
{
"id": "a.3.2",
"name": "a.3.1"
},
{
"id": "a.3.3",
"name": "a.3.1"
}
]
}
]
},
{
"name": "b",
"id": "b",
"options": [
{
"id": "b.1",
"name": "b.1",
"options": [
{
"id": "b.1.1",
"name": "b.1.1"
},
{
"id": "b.1.2",
"name": "b.1.2"
},
{
"id": "b.1.3",
"name": "b.1.3"
}
]
},
{
"id": "b.2",
"name": "b.2",
"options": [
{
"id": "b.2.1",
"name": "b.2.1"
},
{
"id": "b.2.2",
"name": "b.2.2"
},
{
"id": "b.2.3",
"name": "b.2.3"
}
]
},
{
"id": "b.3",
"name": "b.3.1",
"options": [
{
"id": "b.3.1",
"name": "b.3.1"
},
{
"id": "b.3.2",
"name": "b.3.2"
},
{
"id": "b.3.3",
"name": "b.3.3"
}
]
}
]
},
{
"id": "c",
"name": "c",
"options": [
{
"id": "c.1",
"name": "c.1",
"options": [
{
"id": "c.1.1",
"name": "c.1.1"
},
{
"id": "c.1.2",
"name": "c.1.2"
},
{
"id": "c.1.3",
"name": "c.1.3"
}
]
},
{
"id": "c.2",
"name": "c.2",
"options": [
{
"id": "c.2.1",
"name": "c.2.1"
},
{
"id": "c.2.2",
"name": "c.2.2"
},
{
"id": "c.2.3",
"name": "c.2.3"
}
]
},
{
"id": "c.3",
"name": "c.3",
"options": [
{
"id": "c.3.1",
"name": "c.3.1"
},
{
"id": "c.3.2",
"name": "c.3.2"
},
{
"id": "c.3.3",
"name": "c.3.3"
}
]
}
]
}
]
}
function getHierarchy(opts, path, index = 1, result = []) {
if(!opts) return result;
let objPaths = path.split(".");
let _path = objPaths.slice(0, index).join(".");
let option = opts.find(({id}) => id === _path);
if(!option) return result;
let { options, id } = option;
return getHierarchy(options, path, ++index, [...result,id]);
}
let result = getHierarchy(obj.options, "a.1.3");
console.log(result);
In vanilla JavaScript, how would I find unique locations from this object and make them keys, and place all items with that location as values. (can install lodash if necessary).
So this:
[
{
"item": {
"id": "cat"
},
"location": {
"id": "porch"
}
},
{
"item": {
"id": "dog"
},
"location": {
"id": "porch"
}
},
{
"item": {
"id": "snake"
},
"location": {
"id": "forest"
}
},
{
"item": {
"id": "bird"
},
"location": {
"id": "forest"
}
},
{
"item": {
"id": "beer"
},
"location": {
"id": "fridge"
}
}
]
Becomes this:
[
{
"porch": [
{
"id": "cat"
},
{
"id": "dog"
}
]
},
{
"forest": [
{
"id": "snake"
},
{
"id": "bird"
}
]
},
{
"fridge": [
{
"id": "beer"
}
]
}
]
PEN
// modified desired result
[
{
"location": {
"name": "porch",
"items": [
{
"title": "cat"
},
{
"title": "dog"
}
]
}
},
{
"location": {
"name": "forest",
"items": [
{
"title": "snake"
},
{
"title": "bird"
}
]
}
},
{
"location": {
"name": "fridge",
"items": [
{
"title": "beer"
}
]
}
}
]
let obj = [
{
"item": {
"id": "cat"
},
"location": {
"id": "porch"
}
},
{
"item": {
"id": "dog"
},
"location": {
"id": "porch"
}
},
{
"item": {
"id": "snake"
},
"location": {
"id": "forest"
}
},
{
"item": {
"id": "bird"
},
"location": {
"id": "forest"
}
},
{
"item": {
"id": "beer"
},
"location": {
"id": "fridge"
}
}
]
let result = {};
obj.forEach(({item, location}) => {
if(!result[location.id]) result[location.id] = []
result[location.id].push({title: item.id})
})
result = Object.keys(result).map(key => ({
"location": {
"name": key,
"items": result[key]
}
}))
result contains required output.
I have json data format given below. From this data I need to display group11 emotions only in 3D charts.So i need x ,y and z value.how to get these values please give me some logic.we can use anything from this given json.
JSON
{
"status": "success",
"result": {
"duration": "15034.88",
"sessionStatus": "Done",
"analysisSegments": [
{
"offset": 0,
"duration": 10000,
"end": 10000,
"analysis": {
"Temper": {
"Value": "62.00",
"Group": "medium",
"Score": "59.00"
},
"Valence": {
"Value": "96.00",
"Group": "positive",
"Score": "94.00"
},
"Arousal": {
"Value": "98.00",
"Group": "high",
"Score": "97.00"
},
"Vad": {
"Voiced": "70.00"
},
"Mood": {
"Group7": {
"Primary": {
"Id": 1,
"Phrase": "Angry"
},
"Secondary": {
"Id": 3,
"Phrase": "Enthusiastic"
}
},
"Group11": {
"Primary": {
"Id": 11,
"Phrase": "Supremacy, Arrogance"
},
"Secondary": {
"Id": 1,
"Phrase": "Creative, Passionate"
}
},
"Group21": {
"Primary": {
"Id": 9,
"Phrase": "egoism"
},
"Secondary": {
"Id": 18,
"Phrase": "motivation"
}
},
"Composite": {
"Primary": {
"Id": 143,
"Phrase": "Insistence and stubbornness. Possibly childishness."
},
"Secondary": {
"Id": 5,
"Phrase": "Ambitious. Assertiveness to achieve goals."
}
}
}
}
},
{
"offset": 5000,
"duration": 10000,
"end": 15000,
"analysis": {
"Temper": {
"Value": "63.00",
"Group": "medium",
"Score": "57.00"
},
"Valence": {
"Value": "89.00",
"Group": "positive",
"Score": "84.00"
},
"Arousal": {
"Value": "94.00",
"Group": "high",
"Score": "91.00"
},
"Vad": {
"Voiced": "62.00"
},
"Mood": {
"Group7": {
"Primary": {
"Id": 1,
"Phrase": "Angry"
},
"Secondary": {
"Id": 3,
"Phrase": "Enthusiastic"
}
},
"Group11": {
"Primary": {
"Id": 11,
"Phrase": "Supremacy, Arrogance"
},
"Secondary": {
"Id": 6,
"Phrase": "Leadership, Charisma"
}
},
"Group21": {
"Primary": {
"Id": 8,
"Phrase": "dominance"
},
"Secondary": {
"Id": 18,
"Phrase": "motivation"
}
},
"Composite": {
"Primary": {
"Id": 107,
"Phrase": "Possessiveness. Ownership. Authoritative."
},
"Secondary": {
"Id": 41,
"Phrase": "Strong drive."
}
}
}
}
}
],
"analysisSummary": {
"AnalysisResult": {
"Temper": {
"Mode": "medium",
"ModePct": "100.00"
},
"Valence": {
"Mode": "positive",
"ModePct": "100.00"
},
"Arousal": {
"Mode": "high",
"ModePct": "100.00"
}
}
}
}
}
What I have tried
x-Emotion name(Supremacy, Arrogance)
y-Emotion count(how many times repeated)
z-Emotion duration(in minutes)
json parse
var counter4=0;
var val4 =0;
var val4minute =0;
var phrase = rawdata[i]["analysis"]["Mood"]["Group11"]["Primary"]["Phrase"];
if (phrase == "Supremacy, Arrogance") {
counter4++;
val4 = counter4 * 10000;
val4minute = Math.floor(val4 / 60000);
}
Here x is "Supremacy, Arrogance" counter4 is y axis and val4minute is z axis
but this logic is wrong can any one give me a better logic.