This the code that i wrote
<script>
var jobs = ['fault 1','fault 2','fault 3','fault 4','fault 5'];
var assistant =['John :','Martin :','lovemore :'];
var langKeys = {};
for (var i = 0; i < jobs.length; i++) {
var job = jobs[i];
langKeys[job] = assistant[i];
}
console.log(JSON.stringify(langKeys));
</script>
the output:
{"fault 1":"John :","fault 2":"Martin :","fault 3":"lovemore :"}
fault 4 and fault 5 remained unassinged to an assistant
the desired output
{"fault 1":"John :","fault 2":"Martin :","fault 3":"lovemore :","fault 4":"John :","fault 5":"Martin:"}
i would like the jobs to be continuously assigned to a technician
As i said in the comment you need to restart index of assistant to start from the first value like:
const jobs = ['fault 1', 'fault 2', 'fault 3', 'fault 4', 'fault 5'];
const assistant = ['John :', 'Martin :', 'lovemore :'];
const assistantLenght = assistant.length;
let assistantIndex = 0;
const langKeys = {};
for (var i = 0; i < jobs.length; i++) {
var job = jobs[i];
langKeys[job] = assistant[assistantIndex];
assistantIndex++
if (assistantIndex >= assistantLenght) {
assistantIndex = 0;
}
}
console.log(JSON.stringify(langKeys));