titounnes

statistic

Jun 11th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. function statistic() {
  2. let pendaftar = Sheet.from('Pendaftaran').getAll();
  3. let tabel = {}
  4. let baris =0;
  5. for(let i=0; i< pendaftar.length; i++){
  6. let tanggal = new Date (pendaftar[i][0]);
  7. let index = tanggal.getFullYear()+'-'+(tanggal.getMonth()+1)+'-'+('0'+tanggal.getDay()).substr(-2);
  8. if(tabel[index]){
  9. tabel[index]++;
  10. }else{
  11. tabel[index] = 1;
  12. baris++;
  13. }
  14. }
  15. let pesan = 'Jumlah Pendaftar berdaasrkan hari \n';
  16. for (index in tabel){
  17. pesan += 'Tanggal '+index+': '+tabel[index]+'\n';
  18. }
  19. return pesan;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment