+ 1
Help please! How console this??
The program has a partNumbers variable that stores an array. Each array element is a product SKU. Write a program that will create a new array based on partNumbers . The new array must contain all elements from partNumber that end in two digits and two alphabetic characters. All other elements must be discarded. Print the value of the new array to the console . Variable value example : partNumbers = [ " ER1234COM " , " FIV987451RU " , " GE123JO " , " P4321NO " ] Result example : [ " FIV987451RU " , " GE123J0 " , " P4321N0 " ]
4 Antworten
+ 1
Abhay sorry, its my mistake) Thank so much!)
0
you can loop over array.
Then check each item the following way,
a="abc45de" // example string.
len=a.length
chr=/[a-zA-Z]/
alpha=/[0-9]/
console.log(chr.test(a[len-1]) && chr.test(a[len-2])&& alpha.test(a[len-3]) && alpha.test(a[len-4]))
;use above condition in if statement . If it is true add item to new array .
0
This example gives false when it should be true
0
Yasha Mayorov gives true to me