Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let companies = input.shift()
- .split(input.shift());
- let sentences = input.map(s => s.toLowerCase());
- let valid = [];
- let invalid = [];
- let count = 1;
- sentences
- .forEach(s => {
- let isValid = true;
- companies
- .forEach(c => {
- if (s.indexOf(c) < 0) {
- isValid = false;
- }
- });
- isValid ? valid.push(s) : invalid.push(s);
- });
- if (valid.length > 0) {
- console.log("ValidSentences");
- valid.forEach(s => {
- console.log(`${count++}. ${s}`);
- });
- }
- if (valid.length > 0 && invalid.length > 0) {
- console.log("=".repeat(30));
- }
- if (invalid.length > 0) {
- count = 1;
- console.log("InvalidSentences");
- invalid.forEach(s => {
- console.log(`${count++}. ${s}`);
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement