Question: I am trying to display image using javascript but the image is not displaying. I have used ajax to get data and then append the value of the image to a URL before display the image. after appending the image to URL I check the console, I can see that the URL of the image is correct which is pointing to the image. I can even copy the URL from the console and paste it on the browser and the image display well. However, the image is not displaying when i append the url to img2.appendChild(image); 

```js
const URL="http://test/somtest?random=random";
const url="Http://test/document/img/";

function getdata() {
    let xhr = new XMLHttpRequest();
    let img2 = document.getElementById("image");
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
            var data = JSON.parse(xhr.responseText);
            var image = document.createElement("img");
            image.src=url+data.image;
          console.log(image);

     while (img2.firstChild) {
                     img2.removeChild(img2.firstChild);
                 }
   img2.appendChild(image);    

        }
 }

       xhr.open('GET', URL);
        xhr.send();
    }
```

Answer: 
Your solution is fine, of course. The errors in the original code were caused by an incorrect use of `if`, please read the [docs](https://docs.racket-lang.org/reference/if.html). The code you found online is simply traversing both lists at the same time, and if one ends before the other it's because it's shorter.

A better option would be to just use the `list-length` procedure you already have - this has the advantage of not having to write an explicit loop. In Scheme we try to reuse existing procedures instead of writing new ones; for example:

```
(define (list-length lst)
  (if (null? lst)
      0
      (+ 1 (list-length (cdr lst)))))

(define (longer-list lst1 lst2)
  (if (or (not (list? lst1)) (not (list? lst2)))
      #f
      (let ((len1 (list-length lst1))
            (len2 (list-length lst2)))
        (cond ((> len1 len2) lst1)
              ((< len1 len2) lst2)
              (else #t)))))

```

It works as expected, and is easier to understand!

```
(longer-list '(1 2 3 4) '(a b c d e))
=> '(a b c d e)
(longer-list '(d e f) '(4 5 6))
=> #t
(longer-list '(g h i) 3)
=> #f

```
this appears to have worked

```
#lang racket

(define (longer-list lst1 lst2)
  (and (list? lst1)
     (list? lst2)

     (let comp ((x lst1) (y lst2))
       (cond
         ((and (null? x) (null? y)) #t)
         ((null? x) lst2)
         ((null? y) lst1)
         (else (comp (cdr x) (cdr y)))))))

```