Thursday 10 December 2020

How to add an item to a list by replacing the earlier one. In Javascript

I have a list will a list but it only has one item I need to be able to replace that with a new one. But there should one be one. Because there is a condition involve I need to be able to create an variable if something there or not but I found the list to be easier so how can I replace an item in a list with a new one

let subject_reply = [];
if (email.subject.startsWith("Re:") == true) {
  subject_reply.push(email.subject);
}else{
  subject_reply.push(`Re: ${email.subject}`);
}


from How to add an item to a list by replacing the earlier one. In Javascript

No comments:

Post a Comment