PLEASE make sure code is in JAVASCRIPT ONLY!!!! USE the following function header ONLY!
function deviceNamesSystem(devicenames) {
//Write your code here
}
picture of the questions attached below
Create unique device names to be used in a residential loT (Internet of Things) system. If a device name already exists in the system, an integer number is added at the end of the name to make it unique. The integer added starts with 1 and is incremented by 1 for each new request of an existing device name. Given a list of device name requests, process all requests and return an array of the corresponding unique device names. Example n = 6 devicenames = ['switch, tv', 'switch', 'tv, 'switch', 'tv'] = devicenames[0] = "switch" is unique. uniqueDevicename[0]="switch" devicenames[1] = "tV' is unique. unique Devicename[1]="t" devicenames[2] = devicenames[0]. Add 1 at the end the previous unique username "switch, Example n = 6 devicenames = ['switch, tv switch', 'ty! switch, "tv' devicenames[0] = "switch" is unique. uniqueDevicename[0]="switch" devicenames[1] = "t" is unique. uniqueDevicename[1]="v" devicenames[2] = devicenames[0]. Add 1 at the end the previous unique username "switch", unique Devicename[2]="switch1" devicenames[3)= devicenames[1]. Add 1 at the end the previous unique username "tv". uniqueDevicename[3]="t1" devicenames[4] =devicenames[2]. Increment by 1 the number at the end of the previous unique username "switch1", unique Devicenames[4="switch2" devicenames[5] = devicenames[3). Increment by 1 the number at the end of the previous unique username "tv1", unique Devicenames[5]="tV2" Karalian warna aiah devicenames[5] devicenames[3]. Increment by 1 the number at the end of the previous unique username "tv1" uniqueDevicenames[5]="tV2" return uniqueDevicenames = ['switch, tv switch 1: 'tvl 'switch2', 'tv2] Function Description Complete the function deviceNames System in the editor below. deviceNamesSystem has the following parameter(s): string devicenames[n]: an array of device name strings in the order requested. Returns string[n], an array of string usernames in the order assigned Constraints 1sns 104 1 s length of devicenames[i] s 20 deviceNamesSystem has the following parameter(s): string devicenames[n]: an array of device name strings in the order requested. Returns stringn): an array of string usernames in the order assigned Constraints 1sns 104 1 s length of devicenames[i]