I have a function which takes values from two classes and maps it into an array. The array then gets pushed into a send email function.
var p1 = document.getElementsByClassName('emailtest'),
email = [].map.call(p1, function(email) {
return email.value;
}).join(',');
var p2 = document.getElementsByClassName('reciptest'),
rname = [].map.call(p2, function(rname) {
return rname.value;
}).join(',');
var to = [];
var p3 = email.split(',');
var p4 = rname.split(',');
p3.forEach(function(em, i) {
var recipient = {
email: em,
name: null,
type: 'to'
};
if (p4.length > i)
recipient = p4[i];
to.push(recipient);
});
How would I implement this in python and more specifically django ? I have a rough idea on splitting the strings but am not sure how to convert the last section p3.forEach(function(em, i) and to.push(recipient)