Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49259

Alert with Fisher – Yates shuffle / Market App

$
0
0

I’ve a list of market items, every time the customer confirms the alert, the list must be mixed up. I’m using Fisher - Yates shuffle, but when I look at the “serve --lab” result, the shuffling doesn’t happen.

public Vegetables = [‘Carrot.’, ‘Broccoli.’, ‘Asparagus.’, ‘Cauliflower.’, ‘Corn.’, ‘Cucumber.’, ‘Eggplant.’, ‘Lettuce.’, ‘Radish.’, ‘Okra.’]

async Vegatableslist() {

const alert = await this.alert.create({

  cssClass: 'my-custom-class',

  message: 'Do you want to reorder items?',

  buttons: [

    {

        text: 'No.',

        handler: () => {

        }

    },

    {

       text: 'Yes, please.',

       handler: () => {

function shuffle(array) {

var Vegetables = array.length, t, i;

while (Vegetables) {

i = Math.floor(Math.random() * Vegetables- -);

t = array[Vegetables];

array[Vegetables] = array[i];

array[i] = t;

}

return array;

}

       }

   }

],

});

await alert.present();

}

I used this code: Fisher–Yates Shuffle. My Ts does not report an error, but the action does not happen in “serve --lab” and this message appears on function shuffle: " ‘shuffle’ is declared but its value is never read."

Can someone help me? Alert and scrambling are company criteria.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49259

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>