OneTrust Interview Question

Asked to optimize a JS code.