You are browsing as a guest. Sign up (or log in) to start making projects!

40m 17s logged

The idea was already very clear in the beginning. After executing every
command, save it to local storage in a JSON. First I played around with
local storage and after I understood how it worked I started with the
task. But I ran into a major problem. Local storage only accepts
strings, so it is kinda impossible to store the history in JSON / array.
I first tried to slice the strings where the separator was, but this
solution wasnt elegant and will cause problems when I wanna implement
the arrow up to the last used command, simply just the command history
thing from kitty terminal. After wasting some time on the separator
solution, I came back to JSON and after looking through what I did in
other projects, I realized that there is a build in function to turn a
JSON into a string and back, called JSON stringify, it used to be my
favorite build in function, because it is sooooooo handy. After this
thing was solved, it was time to implement clear history and clear.
clear history was easy, its just simply delete the local storage entry
and I solved it with an if statement, ik its not great, cause hardcode n
stuff, but who care, not my problem currently, future Maximilian
problem. The clear command was something else. My final approach was to
simply clear the history container with .innerHTML = “” and run it as a
function. Enough yap, bye

0
15

Comments 0

No comments yet. Be the first!