LisahMan / Chat-Application

Initialization in variable declarations against recommended approach JS-0119
Anti-pattern
Minor
a year agoa year old
Variable 'room' should be initialized on declaration.
 73    
 74    let sendtoSocketId = await findUserByName(data.sendto);
 75    try{
 76            let room; 77     
 78            let rooms = await userController.get_rooms(data.sendby);
 79            for(let r of rooms.rooms){
Variable 'room' should be initialized on declaration.
114
115 socket.on('typing',async (data)=>{
116    let rooms = await userController.get_rooms(data.sendby);
117    let room;118    for(let r of rooms.rooms){
119        if(r==(data.sendto+data.sendby+"Room")||r==(data.sendby+data.sendto+"Room")){
120            room = r;
Variable 'room' should be initialized on declaration.
129
130socket.on('nottyping',async (data)=>{
131    let rooms = await userController.get_rooms(data.sendby);
132    let room;133    for(let r of rooms.rooms){
134        if(r==(data.sendto+data.sendby+"Room")||r==(data.sendby+data.sendto+"Room")){
135            room = r;
Variable 'sendby' should be initialized on declaration.
67
68socket.on('receivemsg',(data)=>{
69    console.log("data"+data.content);
70 let sendby;71 if(data.sendby===name){
72     sendby = "you";
73 }else{