Skip to content

Commit e082fc1

Browse files
committed
#6 New 'Command x not found' warning on devtools console
1 parent a440def commit e082fc1

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

js/script.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ const commands = [
1919
]
2020

2121
function run(commandInput) {
22-
for (const command of commands) {
23-
if(command.name == commandInput.value){
24-
return command.run()
25-
}
22+
let input = commandInput.value
23+
let command = commands.filter(function (command) {
24+
return command.name === input;
25+
})
26+
if(command === null || command.length === 0) {
27+
return console.log(`Command ${input} not found`)
2628
}
29+
command[0].run()
2730
}
2831

2932
function detectEnter(event,input) {

0 commit comments

Comments
 (0)