Code Review Friday: (Let's Improve your code, ask Corvid Master)

June 19th, 2020
Join this week code review organized by Corvid master,
Comment your code below(as per instruction) we will analyze provide you suggestion or refactored code that will be easy to read, to modify, and plenty of good practice.

We also welcome experience corvid forum members to share the knowledge and expertise.

Instructions:

*1: FULL PAGE CODE is recommended
*2: Include database structure like Collection name & Field type (if you refer them in the code)
3: Is this a live site? If so, drop a link so, we can check the code.
4: Videos or Images for explanation of what the code does is useful!
Marked * are required

Don’ts

1: Do NOT include any sensitive code (like passwords, secrect key).

// try to rewrite it as xxx if it's used inside the code
const key = "XXX-XXX";

2: Asking any questions unrelated to code review or corvid
3: Screenshot the code and not pasting the code in text format
4: Code that was not working before and asking to fix (Please create a new post in the community, This Post is dedicated to improve your current working code)

Comment not related to refactor for the code will be get deleted to organize

Notes

  • We do code review every friday PST timezone!

  • This post will be locked after 24 hours

1 Like

Hello Salman2301 (hello again :grin:)

like every friday a liitle brainwork for you :grin:.

Ok whats the matter?
I have written a code which enables the conversion between DECIMAL-number-system and HEX-system.

Everything works fine, but my question is, if there are improvements possible in my code?

function Decimal_to_Hex (parameter) {
 var PRIMÄR, REST
 var HEX, HEX2
 var myArray=[]
 var myHEX = "#"
    myArray = parameter.slice(5,parameter.length-5).split(",")

 for (var i = 0; i < 3; i++) {
        PRIMÄR = Math.floor((myArray[i]/16))
        REST=Math.floor(myArray[i]-(PRIMÄR*16))

 if (PRIMÄR==0) {HEX=0}
 if (PRIMÄR==1) {HEX=1}
 if (PRIMÄR==2) {HEX=2}
 if (PRIMÄR==3) {HEX=3}
 if (PRIMÄR==4) {HEX=4}
 if (PRIMÄR==5) {HEX=5}
 if (PRIMÄR==6) {HEX=6}
 if (PRIMÄR==7) {HEX=7}
 if (PRIMÄR==8) {HEX=8}
 if (PRIMÄR==9) {HEX=9}
 if (PRIMÄR==10) {HEX="A"}
 if (PRIMÄR==11) {HEX="B"}
 if (PRIMÄR==12) {HEX="C"}
 if (PRIMÄR==13) {HEX="D"}
 if (PRIMÄR==14) {HEX="E"}
 if (PRIMÄR==15) {HEX="F"}

 if (REST==0) {HEX2=0}
 if (REST==1) {HEX2=1}
 if (REST==2) {HEX2=2}
 if (REST==3) {HEX2=3}
 if (REST==4) {HEX2=4}
 if (REST==5) {HEX2=5}
 if (REST==6) {HEX2=6}
 if (REST==7) {HEX2=7}
 if (REST==8) {HEX2=8}
 if (REST==9) {HEX2=9}
 if (REST==10) {HEX2="A"}
 if (REST==11) {HEX2="B"}
 if (REST==12) {HEX2="C"}
 if (REST==13) {HEX2="D"}
 if (REST==14) {HEX2="E"}
 if (REST==15) {HEX2="F"}
        myHEX = myHEX+HEX.toString()+HEX2.toString()
    }
    console.log(myHEX)
    $w('#text1').text=myHEX
}

I tried to use a second for-loop, but it failed.

function Decimal_to_Hex (parameter) {
 var PRIMÄR, REST
 var HEX, HEX2
 var myArray=[]
 var myHEX = "#"
    myArray = parameter.slice(5,parameter.length-5).split(",")

 for (var i = 0; i < 3; i++) {
        PRIMÄR = Math.floor((myArray[i]/16))
        REST=Math.floor(myArray[i]-(PRIMÄR*16))

 for (var a = 0; i < 15; a++) {
 if (PRIMÄR==a) {HEX=a}
//          if (PRIMÄR==1) {HEX=1}
//          if (PRIMÄR==2) {HEX=2}
//          if (PRIMÄR==3) {HEX=3}
//          if (PRIMÄR==4) {HEX=4}
//          if (PRIMÄR==5) {HEX=5}
//          if (PRIMÄR==6) {HEX=6}
//          if (PRIMÄR==7) {HEX=7}
//          if (PRIMÄR==8) {HEX=8}
//          if (PRIMÄR==9) {HEX=9}
 if (PRIMÄR==10) {HEX="A"}
 if (PRIMÄR==11) {HEX="B"}
 if (PRIMÄR==12) {HEX="C"}
 if (PRIMÄR==13) {HEX="D"}
 if (PRIMÄR==14) {HEX="E"}
 if (PRIMÄR==15) {HEX="F"}

 if (REST==a) {HEX2=a}
//          if (REST==1) {HEX2=1}
//          if (REST==2) {HEX2=2}
//          if (REST==3) {HEX2=3}
//          if (REST==4) {HEX2=4}
//          if (REST==5) {HEX2=5}
//          if (REST==6) {HEX2=6}
//          if (REST==7) {HEX2=7}
//          if (REST==8) {HEX2=8}
//          if (REST==9) {HEX2=9}
 if (REST==10) {HEX2="A"}
 if (REST==11) {HEX2="B"}
 if (REST==12) {HEX2="C"}
 if (REST==13) {HEX2="D"}
 if (REST==14) {HEX2="E"}
 if (REST==15) {HEX2="F"}
            myHEX = myHEX+HEX.toString()+HEX2.toString()
        }
    }
    console.log(myHEX)
    $w('#text1').text=myHEX
}

Something like this, but did not work :disappointed_relieved::disappointed_relieved::disappointed_relieved::disappointed_relieved::tired_face:

Ok, i could improve it by myself a little bit.
The new code is like this now


function  Decimal_to_Hex (parameter) {
 var PRIMÄR, REST
 var HEX, HEX2
 var myArray=[]
 var myHEX = "#"
    myArray = parameter.slice(5,parameter.length-5).split(",")

 for (var i = 0; i < 3; i++) {
        PRIMÄR = Math.floor((myArray[i]/16))
        REST=Math.floor(myArray[i]-(PRIMÄR*16))

 for (var a = 0; a <= 9; a++) {
 if (PRIMÄR==a) {HEX=a}
            console.log(a)
 if (PRIMÄR==10) {HEX="A"}
 if (PRIMÄR==11) {HEX="B"}
 if (PRIMÄR==12) {HEX="C"}
 if (PRIMÄR==13) {HEX="D"}
 if (PRIMÄR==14) {HEX="E"}
 if (PRIMÄR==15) {HEX="F"}

 if (REST==a) {HEX2=a}
 if (REST==10) {HEX2="A"}
 if (REST==11) {HEX2="B"}
 if (REST==12) {HEX2="C"}
 if (REST==13) {HEX2="D"}
 if (REST==14) {HEX2="E"}
 if (REST==15) {HEX2="F"}
        }
            myHEX = myHEX+HEX.toString()+HEX2.toString()
    }
    console.log(myHEX)
    $w('#text1').text=myHEX
}

To understand the whole process 
 (additional-info)

parameter <---- this = for example rgba(200,155,255,1.0)

Are there still improvements possible on this code?

OK, so I’m going to cheat:

hexString = decNumber.toString(16);

Might need to tweak it for your purposes.

WOW! :grinning::heart_eyes: BEST-MAN!
I did get it to work.
Really short solution. RESPECT!
But do not know how it works :rofl::sweat_smile::sweat_smile::sweat_smile:

Here is what my code looks like right now


function  convert_Dec2Hex(parameter) {
 var myArray=[], HEX=[]
 var myHEX = "#"
 
    console.log(parameter)
    myArray = parameter.slice(5,parameter.length-5).split(",")
    console.log(parameter)
    console.log(myArray)

 for (var i = 0; i < myArray.length; i++) {
        HEX[i] = Number(myArray[i]).toString(16);
        myHEX = myHEX+HEX[i]
        console.log(HEX[i])
    }
    console.log(myHEX)
}

parameter = for example ----> rgba(255,191,125,1.0)
Works also perfectly!!!

Thank you Yisrael! (I’m learning a lot from you an i hope i will memorize all of the new informations well.)

A little info on toString()

Thanks Yisrael! I will look at that.:slightly_smiling_face:
If i just knew all this before i have created my own code.
But it is a good way to learn! Thanks for your solution and advises it helps me with my learning-process.

And by the way. this is my little exercise-project where i inplement this code.
https://russian-dima.wixsite.com/wixworld/blank-3

Hi masters,

I plan to show a text within a box that announces a new collection item when an item is added to a collection. I have used afterInsert hook and code myself. This feature doesn’t work and I wonder where I made a mistake in. The codes and features such below.

Features

Website: https://www.bizimuhit.com/
Page: https://www.bizimuhit.com/resources
Collection Name: resources
Key field for Gösterim: gosterim
Key field for appName: appName
URL: I use custom path for URL. www.bizimuhit.com/resources/{url} for items.

My Collection Review

Page Items

data.js code

import { publish } from 'wix-realtime-backend';

export function udemy_courses_afterInsert(item, context) {
 const channel = { name: 'new-property' };
 let message = `New ${item.appName} ${item.gosterim} has been added to resources! `;
 let link = item["link-resources-url"];
    publish(channel, { message: message, link: link }, { includePublisher: true });
 return item
}

Page code

import * as realtime from 'wix-realtime';
import wixData from 'wix-data';

$w.onReady(function () {
 if (!$w('#box1').hidden) $w('#box1').hide('fade');
 const channel = { name: 'new-property' };
    realtime.subscribe(channel, newItemAdded);
});

async function newItemAdded({ item }) {

 if ($w('#box1').hidden) {
        $w('#button272').link = item.link;
        $w('#text530').text = item.message;
        $w('#box1').show('fade');
        setTimeout(() => $w('#box1').hide('fade'), 10000);
    } else {
        setTimeout(() => newItemAdded({ item }), 10000);
    }
}

By the way: Forum has a bug that doesn’t allow you to add files with the same name although their types differ from each other.:sleepy:

Could you help me out to fix this issue? :blush::blush::blush:

#hooks #afterInsert

Can someone help me with chart.js. I following this example, https://www.wix.com/corvid/example/chart.js-custom-element, with my collection but its not working.


front-end page code (All the other files are similar to the example):

import wixData from 'wix-data';
import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import { getAvr, getMember, getElyiumData } from 'backend/queries';
import { ChartJSAPI } from 'public/chart-api';
import { chartCustomization } from 'public/chart-customization';

$w.onReady(function () {
 //TODO: write your page related code here...
 //let memberSlides = $w('#memberSlides').currentIndex;
    profilePopulate();
    elysiumData();
    profileCharts();
    $w('#dashboardButton').onClick((event) => {
        $w('#memberSlides').changeSlide(0);
 //Dashboard
    })
    $w('#memberResults').onClick((event) => {
        $w('#memberSlides').changeSlide(1);
    })
    $w('#memberInterventions').onClick((event) => {
        $w('#memberSlides').changeSlide(2);
    })
    $w('#memberBookings').onClick((event) => {
        $w('#memberSlides').changeSlide(3);
    })
    $w('#memberRequests').onClick((event) => {
        $w('#memberSlides').changeSlide(4);
    })
    $w('#memberSandbox').onClick((event) => {
        $w('#memberSlides').changeSlide(5);
    })
    $w('#memberExperiment').onClick((event) => {
        $w('#memberSlides').changeSlide(6);
    })
 let buttonsToChange = [$w("#dashboardButton"), $w("#memberResults"), $w("#memberInterventions"),
        $w("#memberBookings"), $w('#memberRequests'), $w('#memberSandbox'), $w('#memberExperiment')
    ];
    buttonsToChange.forEach(button => {
        $w("#dashboardButton").style.color = "rgb(181,209,42)";
        button.style.color = "rgb(255,255,255)";
        button.onClick((event) => {
            buttonsToChange.forEach(b => {
                b.style.color = "rgb(255,255,255)"
            });
            button.style.color = "rgb(181,209,42)";
        })
    })
    $w("#elysiumData1").onReady(() => {
        changeAverageSliders();
        populateyearDropdown1();
        $w("#elysiumData1").onCurrentIndexChanged((index) => {
            changeAverageSliders();
        });

    })

});

export async function profileCharts() {
 let chart = new ChartJSAPI($w('#CustomElement1'));
    chart.customization = chartCustomization;
 const chartItems = await wixData
        .query("elysiumData")
        .find()
        .then(res => res.items);
 const labels = chartItems.map(item => item.userName);
 const data = chartItems.map(item => Number(item.hsCrp));
 const backgroundColor = chartItems.map(item => item.backgroundColor);
 const borderColor = chartItems.map(item => item.borderColor);
    chart.data = {
        labels,
        datasets: [{ data, backgroundColor, borderColor }]
    }

}

OMG, paste this as code block :tired_face:

My apologies, I thought it was in a code snippet. It has been corrected. Btw, this is my chart-api.js


import wixSeo from 'wix-seo';

export class ChartJSAPI {
    constructor(elem) {
 this.elem = elem;
    }

    get data() {
 return this._data;
    }

    set data(d) {
 this._data = d;
 this.render();
    }

    get customization() {
 return this._customization;
    }

    set customization(c) {
 this._customization = c;
 this.render();
    }

    render() {
 if (this.customization) {
 const { label } = this.customization;
            wixSeo.setTitle(label);
        }

 if (this.data && this.customization) {
 const datasets = Object.assign({}, this.data.datasets[0], this.customization);
 this.data.datasets[0] = datasets;

 this.elem.setAttribute('chart-data', JSON.stringify(this.data));
        }
    }
}

and chart.js under the folder custom-elements:


import Chart from 'chart.js';

class ChartElem extends HTMLElement {
    constructor() {
 super();
 this._shadow = this.attachShadow({ mode: 'open' });
 this._root = document.createElement('canvas');
 this._root.setAttribute("id", "myChart");
 this._root.setAttribute("style", "width: 100%");
 this._shadow.appendChild(this._root);
    }

 static get observedAttributes() {
 return ['chart-data'];
    }

    attributeChangedCallback(name, oldValue, newValue) {
 if (name === 'chart-data') {
 this.chartData = newValue;
            console.log(chartData)
        }
    }

    get chartData() {
 return this._chartData;
    }

    set chartData(d) {
 this._chartData = JSON.parse(d);
        sessionStorage.setItem('chartData', d);
 if (this._connected)
 this.render();
    }

    connectedCallback() {
 let savedData = sessionStorage.getItem('chartData');
 if (savedData && savedData !== 'undefined' && !this._chartData)
 this._chartData = savedData;
 this._connected = true;
 if (this._chartData) {
 this.render();
        }
    }

    render() {
 const ctx = this._shadow.getElementById('myChart').getContext('2d');
 const myChart = new Chart(ctx, {
            type: 'bar',
            data: this.chartData,
            options: {
                legend: {
                    labels: {
                        boxWidth: 0,
                    }
                },
                scales: {
                    yAxes: [{
                        ticks: {
                            beginAtZero: true,
                        },
                    }, ],
                },
            },
        });
    }
}

window.customElements.define('chart-elem', ChartElem);

Hi there,

I’ve built a mega search page (airbnb type) with different user inputs that filter the database. This page also origins from another search in the home page (sorry I know this is a bit confusing).

The code is working fine except for linking the repeater to a dynamic page (which I will post somewhere else) but it’s quite slow.

Live site is: https://www.omniaveterinary.com/resultados-de-busqueda

Database is mainly text fields apart from “precio”, which is a number field.

Full code:

import {local} from 'wix-storage';
import wixData from 'wix-data';
import wixLocation from 'wix-location';

let formacioninfo = [];

// Results re-direction
$w.onReady(function () {

 var sameWord = local.getItem("searchWord");

    $w("#searchBar").value = sameWord;
    $w("#searchBar").placeholder = sameWord;
    $w('#dataset1').onReady(function () {
        search();
    });

});

 

export function searchButton_click() {
    search();
}

 

function search() {
    wixData.query('FORMACION')
   .contains('nombreCurso', $w("#searchBar").value)
   .or(wixData.query('FORMACION').contains('especialidad', $w("#searchBar").value))
   .or(wixData.query('FORMACION').contains('empresa', $w("#searchBar").value))
      .find()
       .then(res => {
  $w('#listRepeater').data = res.items;
    });

}

// Filters
$w.onReady(function () {

//Query to get the information from the database    
      wixData.query("FORMACION")
        .find()
        .then((results) => {
            formacioninfo = results.items;
            $w(`#listRepeater`).data = formacioninfo;
        })
        .catch((err) => {
 let errorMsg = err;
        });
//Set the information to the repeater     
      $w(`#listRepeater`).onItemReady(($w, itemData, index) => {          
        $w('#title').text = itemData.nombreCurso;
        $w('#text12').text = itemData.especialidad;
        $w('#button2').label = '€' + String(itemData.precio);
        $w('#text14').text = itemData.fecha;
        $w('#button1').label = itemData.tipo;
        $w ('#text15').text = itemData.modalidad;
      });
});


//Filter function
function filterResults(results){
    results = [];
 const especialidad = $w('#iEspecialidad').value;
 const tipo = $w ('#iType').value;
 const modalidad = $w('#iModalidad').value;
 const maxprice = $w('#iMaxPrice').value
 const minprice = $w('#iMinPrice').value

    results = formacioninfo.slice();


 if (especialidad && especialidad !== 'Escoge especialidad') {
          results = results.filter(item => item.especialidad === especialidad);}
 
 if (tipo && tipo !== 'Escoge tipo') {
          results = results.filter(item => item.tipo === tipo);
          }

 if (modalidad && modalidad !== 'Escoge modalidad') {
          results = results.filter(item => item.modalidad === modalidad);
          }
 if (maxprice && maxprice !== 'Escoge max precio') {      
    results = results.filter(item => item.precio <= maxprice); 
        } 
 if (minprice && minprice !== 'Escoge min precio') {      
    results = results.filter(item => item.precio >= minprice); 
        } 

 return results; 
    }


//Input filter
export function iEspecialidad_change(event) {
 //filtering the results
 const filteredResults = filterResults(formacioninfo);
 //setting the data
        $w(`#listRepeater`).data = filteredResults;
        $w(`#listRepeater`).onItemReady(($w, itemData) => {
            console.log(itemData.title);
                    $w('#logo').src = itemData.logo;
                    $w('#title').text = itemData.nombreCurso;
                    $w('#text12').text = itemData.especialidad;
                    $w('#button2').label = '€' + (itemData.precio);
                    $w('#text14').text = itemData.fecha;
                    $w('#button1').label = itemData.tipo;
                    $w ('#text15').text = itemData.modalidad;
        }); 
 
}

export function iType_click(event) {
const filteredResults = filterResults(formacioninfo);
 //setting the data
        $w(`#listRepeater`).data = filteredResults;
        $w(`#listRepeater`).onItemReady(($w, itemData) => {
            console.log(itemData.title);
                    $w('#logo').src = itemData.logo;
                    $w('#title').text = itemData.nombreCurso;
                    $w('#text12').text = itemData.especialidad;
                    $w('#button2').label = '€' + (itemData.precio);
                    $w('#text14').text = itemData.fecha;
                    $w('#button1').label = itemData.tipo;
                    $w ('#text15').text = itemData.modalidad;
        }); 
 
}

export function iModalidad_click(event) {
const filteredResults = filterResults(formacioninfo);
 //setting the data
        $w(`#listRepeater`).data = filteredResults;
        $w(`#listRepeater`).onItemReady(($w, itemData) => {
            console.log(itemData.title);
                    $w('#logo').src = itemData.logo;
                    $w('#title').text = itemData.nombreCurso;
                    $w('#text12').text = itemData.especialidad;
                    $w('#button2').label = '€' + (itemData.precio);
                    $w('#text14').text = itemData.fecha;
                    $w('#button1').label = itemData.tipo;
                    $w ('#text15').text = itemData.modalidad;
        }); 
}

export function iMaxPrice_change(event) {
const filteredResults = filterResults(formacioninfo);
 //setting the data
        $w(`#listRepeater`).data = filteredResults;
        $w(`#listRepeater`).onItemReady(($w, itemData) => {
            console.log(itemData.title);
                    $w('#logo').src = itemData.logo;
                    $w('#title').text = itemData.nombreCurso;
                    $w('#text12').text = itemData.especialidad;
                    $w('#button2').label = '€' + (itemData.precio);
                    $w('#text14').text = itemData.fecha;
                    $w('#button1').label = itemData.tipo;
                    $w ('#text15').text = itemData.modalidad;
        }); 
}

export function iMinPrice_change(event) {
const filteredResults = filterResults(formacioninfo);
 //setting the data
        $w(`#listRepeater`).data = filteredResults;
        $w(`#listRepeater`).onItemReady(($w, itemData) => {
            console.log(itemData.title);
                    $w('#logo').src = itemData.logo;
                    $w('#title').text = itemData.nombreCurso;
                    $w('#text12').text = itemData.especialidad;
                    $w('#button2').label = '€' + (itemData.precio);
                    $w('#text14').text = itemData.fecha;
                    $w('#button1').label = itemData.tipo;
                    $w ('#text15').text = itemData.modalidad;
        });
}

Thanks very much for your help!

/*
I have update the code
I think you used formacioninfo to query the database
and use javascript to filter the array
this will take a lot of compute power
better way to do is to query the result from the database

I have update the search function
if there is a dropdown value or input value
It will filter based on that

For another simillar sample check my site
you can see the code
https://salman2301/multiple-filter

*/

import { local } from ‘wix-storage’ ;
import wixData from ‘wix-data’ ;

let formacioninfo = ;

// Results re-direction
// refactorNotes: Just use one onPageReady
$w . onReady ( function () {
// UPDATE UI SECTION
// refactorNotes: Use “let” or “const” try to avoid “var”
let sameWord = local . getItem ( “searchWord” );

$w ( “#searchBar” ). value = sameWord ;
$w ( “#searchBar” ). placeholder = sameWord ;

// HANDLE EVENT SECTION
$w ( ‘#dataset1’ ). onReady ( function () {
search ();
});

//Set the information to the repeater
// refactorNotes: You can call this function once
// refactorNotes: this will run everytime the data change
$w ( #listRepeater ). onItemReady (( $w , itemData , index ) => {
console . log ( itemData . title );
$w ( ‘#logo’ ). src = itemData . logo ;
$w ( ‘#title’ ). text = itemData . nombreCurso ;
$w ( ‘#text12’ ). text = itemData . especialidad ;
$w ( ‘#button2’ ). label = ‘€’ + String ( itemData . precio );
$w ( ‘#text14’ ). text = itemData . fecha ;
$w ( ‘#button1’ ). label = itemData . tipo ;
$w ( ‘#text15’ ). text = itemData . modalidad ;
});

$w ( ‘#iEspecialidad, #iMaxPrice, #iMinPrice’ ). onChange ( search );

$w ( ‘#iType, #iModalidad’ ). onClick ( search );

});

export function searchButton_click () {
search ();
}

//Filter function
// refactorNotes: get the data from the collection
// refactorNotes: avoid filtering the data using high order .filter() function
// refactorNotes: I am not sure about the purpost of “formacioninfo”
function search () {

let query = wixData . query ( ‘FORMACION’ );

const especialidad = $w ( ‘#iEspecialidad’ ). value ;
const tipo = $w ( ‘#iType’ ). value ;
const modalidad = $w ( ‘#iModalidad’ ). value ;
const maxprice = $w ( ‘#iMaxPrice’ ). value
const minprice = $w ( ‘#iMinPrice’ ). value
const searchBar = $w ( “#searchBar” ). value ;
// results = formacioninfo.slice();

if ( searchBar ) {
query = query . contains ( ‘nombreCurso’ , searchBar )
. or ( wixData . query ( ‘FORMACION’ ). contains ( ‘especialidad’ , searchBar ))
. or ( wixData . query ( ‘FORMACION’ ). contains ( ‘empresa’ , searchBar ))
}

if ( especialidad && especialidad !== ‘Escoge especialidad’ ) {
query = query . eq ( “especialidad” , especialidad );
}

if ( tipo && tipo !== ‘Escoge tipo’ ) {
query = query . eq ( “tipo” , tipo );
}

if ( modalidad && modalidad !== ‘Escoge modalidad’ ) {
query = query . eq ( “modalidad” , modalidad );
}
if ( maxprice && maxprice !== ‘Escoge max precio’ ) {
query = query . le ( “precio” , maxprice );
}
if ( minprice && minprice !== ‘Escoge min precio’ ) {
query = query . ge ( “precio” , minprice );
}

query . find ()
. then ( res => {
$w ( ‘#listRepeater’ ). data = res . items ;
})
. catch ( console . log );

}

for bugs and question create a new post on the forum
This section is for user, who need to refactor the existing code
Thank you

Closing the thread
hope this was useful,
We(Corvid master) will do Code review on every Friday ,
get ready for the next code review on 26th June
Happy coding :v: