JSON response incorrectly matches partial key for color data

Below java script code matches to "COMPLETED" due to jsonData.search(key) !== -1 which is wrong because json response doesn't contain COMPLETED, it should show red color instead of green in the output.