# Console Result with some text and without

**URL:** <https://forum.freecodecamp.org/t/console-result-with-some-text-and-without/250330>\
**Category:** General\
**Created:** [January 9, 2019, 10:44am UTC](https://forum.freecodecamp.org/t/console-result-with-some-text-and-without/250330 "2019-01-09T10:44:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LightTest](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lighttest/32/159248_2.png) [@LightTest](https://forum.freecodecamp.org/u/LightTest)\
**Post date:** [January 9, 2019, 10:44am UTC](https://forum.freecodecamp.org/t/console-result-with-some-text-and-without/250330/1 "2019-01-09T10:44:45Z")

</div>

I was wondering why with some text put in console.log(): (example: console.log(" some " + arr)😉 this function  
works as designed and without it only works first time ??  
FOR SIMPLICITY, shuffle change the order in a random way --\> not exactly random but almost 😉

I know that array is a reference type and I only give an address to calculate and I am aware that sort changes the original array.

WITH SOMETHING IN CONSOLE "text " + arrx

```auto
let arr = [1, 2, 3];

function shuffle(arrx){
  arrx.sort(callback);

  function callback(a,b){
    let x = 0.49 - Math.random();
    return x;
  }

  console.log("arx " + arrx);
} 

```

shuffle(arr);  
RESULT(example): arx 1,2,3  
shuffle(arr);  
RESULT(example): arx 1,2,3  
shuffle(arr);  
RESULT(example): arx 2,3,1  
shuffle(arr);  
RESULT(example): arx 2,3,1  
shuffle(arr);  
RESULT(example): arx 1,3,2

AND WITHOUT TEXT

```auto
let arr = [1, 2, 3];

function shuffle(arrx){
    arrx.sort(callback);

    function callback(a,b) {
      let x = 0.49 - Math.random();
      return x;
    }

    console.log(arrx);
}

```

shuffle(arr);  
shuffle(arr);  
shuffle(arr);  
shuffle(arr);  
shuffle(arr);  
RESULT ALWAYS THE SAME example [1,2,3] or something else multiplied with every shuffle

Regards ;),

---

<div class="post-metadata">

**Author:** ![DanCouper](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dancouper/32/158608_2.png) [@DanCouper](https://forum.freecodecamp.org/u/DanCouper)\
**Post date:** [January 9, 2019, 10:59am UTC](https://forum.freecodecamp.org/t/console-result-with-some-text-and-without/250330/2 "2019-01-09T10:59:28Z")

</div>

I’m assuming you meant

```auto
console.log(arrx);

```

In the second example?

They work exactly the same, no difference: result is always random, it makes no difference what is in the console log in addition to the shuffled array. Are sure it’s just not giving you the same result back randomly? For example, I got nine [1,2,3]'s in a row on one run, it doesn’t mean it’s not random

---

<div class="post-metadata">

**Author:** ![LightTest](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lighttest/32/159248_2.png) [@LightTest](https://forum.freecodecamp.org/u/LightTest)\
**Post date:** [January 9, 2019, 12:34pm UTC](https://forum.freecodecamp.org/t/console-result-with-some-text-and-without/250330/3 "2019-01-09T12:34:02Z")

</div>

Hmm, I used codesandbox. and it gives me some different results when is text it works normally as expected but only with array it works first time and next results are the same as first one

---

<div class="post-metadata">

**Author:** ![LightTest](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lighttest/32/159248_2.png) [@LightTest](https://forum.freecodecamp.org/u/LightTest)\
**Post date:** [January 9, 2019, 12:36pm UTC](https://forum.freecodecamp.org/t/console-result-with-some-text-and-without/250330/4 "2019-01-09T12:36:17Z")

</div>

I’m sorry I make mistake when pasted here

in first one there is console.log("arx " + arrx);

and second function have only

console.log(arrx);

First one  
 ![image](https://global.discourse-cdn.com/freecodecamp/original/3X/f/7/f7aa47869241f02502b6d71fe46838a657d0b361.png)

Second One  
 ![image](https://global.discourse-cdn.com/freecodecamp/original/3X/e/d/ed09eec5c064d728b9695fcb3e96566a20f3f693.png)

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:02pm UTC](https://forum.freecodecamp.org/t/console-result-with-some-text-and-without/250330/5 "2021-01-17T20:02:07Z")

</div>

Closed on January 17, 2021, 8:02pm UTC


