OneTrust interview question

Asked to optimize a JS code.