Skip to content

Commit 5c84fad

Browse files
committed
Further refined percentage detection values array validation by first eliminating non-numeric entries.
1 parent c09e1a7 commit 5c84fad

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

gtm/spotify-audio.json.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ spotifyPlayer.contentWindow.postMessage({
103103
// the correct format.
104104
var spotifyPercentagesToBeDetected = (
105105
function(arr) {
106-
var truncatedList = arr.map(function(element) {
106+
var truncatedList = arr.filter(function(element) {
107+
return typeof element === 'number';
108+
}).map(function(element) {
107109
return Math.trunc(element);
108110
}).filter(function(element) {
109111
return element > 0 && element < 100;
@@ -120,9 +122,9 @@ var spotifyPercentagesToBeDetected = (
120122
});
121123
return uniqueList;
122124
}
123-
(
125+
)(
124126
// - Edit the list below to setup progress events' percentage values:
125-
[99, 20, 10.5, 60, 100, 40.05, 80, 90, 30, 50, 70, 0, 99.3]
127+
[99, 20, 10.5, 60, 100, 40.05, 80, 90, 30, 50, 70, 0, 99.3, "no"]
126128
// (Expected: list with unique integer values ranging from 1 to 99, sorted in ascending order)
127129
);
128130
// List is certainly [10, 20, 30, 40, 50, 60, 70, 80, 90, 99] after being processed.

gtm/spotify-audio.json.pt-br.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ reprodutorSpotify.contentWindow.postMessage({
103103
// the correct format.
104104
var spotifyPercentagesToBeDetected = (
105105
function(arr) {
106-
var truncatedList = arr.map(function(element) {
106+
var truncatedList = arr.filter(function(element) {
107+
return typeof element === 'number';
108+
}).map(function(element) {
107109
return Math.trunc(element);
108110
}).filter(function(element) {
109111
return element > 0 && element < 100;
@@ -120,9 +122,9 @@ var spotifyPercentagesToBeDetected = (
120122
});
121123
return uniqueList;
122124
}
123-
(
125+
)(
124126
// - Edit the list below to setup progress events' percentage values:
125-
[99, 20, 10.5, 60, 100, 40.05, 80, 90, 30, 50, 70, 0, 99.3]
127+
[99, 20, 10.5, 60, 100, 40.05, 80, 90, 30, 50, 70, 0, 99.3, "no"]
126128
// (Expected: list with unique integer values ranging from 1 to 99, sorted in ascending order)
127129
);
128130
// List is certainly [10, 20, 30, 40, 50, 60, 70, 80, 90, 99] after being processed.

0 commit comments

Comments
 (0)