i have a problem with my svelte code. on the line 41 i have a for loop, which doesn’t run anything, as it doesn’t print out the i variable on the 42 line.
here is my code:
<script>
import Toolbar from "./toolbar.svelte";
import Chat from "./chat.svelte";
var loggedInUser = "dev"
//database
var users =
{
"dev":{
"contacts":["Voldemart", "Timur", "Svyat"],
}
}
var chats = {
0:{"name":"None","members":["Voldemart", "dev"], "messages":[
{"content":"hi", "sender":"dev"},
{"content":"pon", "sender":"Voldemart"},
]},
1:{"name":"None","members":["Timur", "dev"], "messages":[
{"content":"hi", "sender":"dev"},
{"content":"pon", "sender":"Timur"},
]},
2:{"name":"None","members":["Svyat", "dev"], "messages":[
{"content":"hi", "sender":"dev"},
{"content":"pon", "sender":"Svyat"},
]},
3:{"name":"None","members":["Voldemart", "Svyat"], "messages":[
{"content":"hi", "sender":"Svyat"},
{"content":"pon", "sender":"Voldemart"},
]},
}
console.log(chats[0].members.includes(loggedInUser))
var loggedInUserChats = []
var i;
var chatsLength = Object.keys(chats).length
console.log(chatsLength)
for (i; i<5; i++) {
console.log(i)
if (chats[0].members.includes(loggedInUser)) {
loggedInUserChats.push(i)
console.log(i)
}
}
console.log(loggedInUserChats)
</script>
<Toolbar contacts="{users[loggedInUser].contacts}"/>
<div class="chaty">
<Chat/>
</div>
<style>
.chaty {
width: 100%;
height: 100vh;
margin-left: 200px;
}
</style>
i have tried asking gemini, i have tried reading mdn docs and w3schools docs but i found nothing.