Challenge: Filter Failure Messages
Oppgave
Swipe to start coding
Imagine you have a list of system messages, and you need to extract only those containing the word "failure".
Write a program that creates a new array with only these messages and then prints them to the console.
- In the
extractFailureLogs()
method, loop through thelogs
array and check each message for the presence of the keyword "failure" (case-insensitive, using thetoLowerCase()
method). - Count how many messages contain the word "failure" and store the result in a variable
count
. - Loop through the
logs
array again, and add only the messages containing "failure" into theerrorLogs
array.
Løsning
solution.java
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 5. Kapittel 4
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 2.7
Challenge: Filter Failure Messages
Sveip for å vise menyen
Oppgave
Swipe to start coding
Imagine you have a list of system messages, and you need to extract only those containing the word "failure".
Write a program that creates a new array with only these messages and then prints them to the console.
- In the
extractFailureLogs()
method, loop through thelogs
array and check each message for the presence of the keyword "failure" (case-insensitive, using thetoLowerCase()
method). - Count how many messages contain the word "failure" and store the result in a variable
count
. - Loop through the
logs
array again, and add only the messages containing "failure" into theerrorLogs
array.
Løsning
solution.java
Alt var klart?
Takk for tilbakemeldingene dine!
Awesome!
Completion rate improved to 2.7Seksjon 5. Kapittel 4
single