JavaScript JavaScript - Running a forEach in array of objects. Would like to check a substring in a string and replace it with a new substring [closed]

Try this

var profUrlFunc = function() {
  var objTableArray = dataJson;

  objTableArray.forEach(function(user) {
    var httpsLinkCloudFront = "https://d153fwbf2sefnf.cloudfront.net";
    var httpLinkCloudFront = "http://d153fwbf2sefnf.cloudfront.net";
    var prefixLink = "http://www.bucketfeet.com";
    var placeHolderForLink = user.profile_image_url;
    var condition = new RegExp([httpsLinkCloudFront, httpLinkCloudFront].join('|'));

    if (user.profile_image_url) {
      if (!condition.test(user.profile_image_url)) {
        user.profile_image_url = prefixLink + user.profile_image_url;
      } else {
        user.profile_image_url = user.profile_image_url.replace(condition, prefixLink);
      }
    } else {
      user.profile_image_url = "http://www.google.com/favicon.ico";
    }
  });

  return objTableArray;
};

Example

Answer:1

I have a string like this : var name="C:\Users\Desktop\task.txt"; I want to get the last index of backslash in the above string. How to do it ?

I have a string like this : var name="C:\Users\Desktop\task.txt"; I want to get the last index of backslash in the above string. How to do it ?

I am using the Bubbles plugin with the Flot charting library for JQuery. The data I have is dynamic and can be quite varied within the X, Y, and Z values. The main issue I am having is the size of the ...

I am using the Bubbles plugin with the Flot charting library for JQuery. The data I have is dynamic and can be quite varied within the X, Y, and Z values. The main issue I am having is the size of the ...

  1. flow bubbles plugin - bubble size

const columns = ['dataA', 'dataD', 'dataB', 'dataE']; const data = [{ dataA: '001a', dataB: '123456', dataC: 'true', dataD: 'normal', dataE: 'ON' }, { dataA: '...

const columns = ['dataA', 'dataD', 'dataB', 'dataE']; const data = [{ dataA: '001a', dataB: '123456', dataC: 'true', dataD: 'normal', dataE: 'ON' }, { dataA: '...

  1. values_list json
  2. django values_list json
  3. python list json values
  4. array list json values
  5. convert list values to json

I'm struggling with the issue of onclick function and replacing html in DOM. The function is responsible for: 1. reading the whole list from the DOM, 2. changing its order accordingly to ID I get ...

I'm struggling with the issue of onclick function and replacing html in DOM. The function is responsible for: 1. reading the whole list from the DOM, 2. changing its order accordingly to ID I get ...

  1. function of beauty
  2. function notation
  3. function definition
  4. function calculator
  5. function of mitochondria
  6. function of nucleus
  7. function of carbohydrates
  8. function of cell membrane
  9. function of proteins
  10. function of beauty reviews
  11. function of lipids
  12. function of cytoplasm
  13. function synonym
  14. function of nucleic acids
  15. function of dna
  16. function of liver
  17. function math definition
  18. function of vacuole
  19. function of pancreas
  20. function of cerebellum