title: How to replace an image?
body: <p>I'm learning to use APIs and I use a public API for getting images.</p>
  <p>I noticed that most of the images end with <code>large.jpg</code> and they have small versions, so I used <code>replace()</code> to auto resize them:</p>
  <pre><code>img.replace(&quot;large&quot;, &quot;small&quot;);
  </code></pre>
  <p>The problem is that not all of the image URLs end with large.jpg or small.jpg. Some are just &quot;1091034.jpg&quot; and it gives me <code>GET 404</code>.</p>
  <p>Is it possible to ask with JavaScript to recognize this case and replace with my placeholder image URL?</p>