JavaScript — как я могу сказать, если найдено какое-либо из слов в тексте?

как я могу сказать, если найдено какое-либо из слов в тексте?

Я пытаюсь проверить, содержит ли какие-либо слова в тексте console.log(1) или console.log(2) для false, но, тем не менее, я получаю 1,2,1,2 потому что он совпадает, а некоторые не 1,2,1,2 , но я хочу, если содержат только одно слово из заданных слов, тогда ok , но если не ложь, но я получаю правду, ложь

 var keywords = ['aslr', 'ida pro', 'gdb', 'windbg', 'immunity debugger', 'boofuzz', 'peach fuzzer', 'winafl', 'python', 'assembly', 'penetration testing', 'exploits', 'metasploit', 'metasploit framework', 'ethical hacker', 'pentest', 'computer security', 'hacking', 'oscp', 'osce', 'osee', 'penetration testing', 'offensive security', 'mitre att{amp}amp;ck', 'vulnerability research', 'vulnerability researcher', 'fuzzing', 'clang', 'llvm', 'address sanitizer', 'afl', 'fuzzers', 'penetration tester'] var data = "a successful cybersecurity consultancy are seeking an experienced penetration tester to join their melbourne practice on a permanent basis. work across a wide portfolio of clients and help them in identifying security vulnerabilities by conducting web application, network security, and wireless penetration testing. key responsibilities/duties: work with a diverse range of customers to identify and solve security problems, both in-person and remotely undertake application, network, and wireless penetration testing and vulnerability assessments prepare high-quality reports detailing security issues, making recommendations and identifying solutions perform social engineering and physical security assessments and/or undertake secure code reviews, where appropriate key requirements: demonstrated experience in penetration testing penetration testing certifications such as oscp, osce, ceh, sans, crest crt or cct a proven passion for cybersecurity with regular attendance at security events and/or memberships to the likes of owasp understanding of information security principles and security technologies 2   years' work experience in security what the company can offer you: ongoing one-on-one training and development a budget for training courses/certifications flexible working arrangements and the option to work-from-home the opportunity to work in a collaborative environment with experienced security professionals if this position sounds of interest, please click 'apply' or email your cv directly to charlotte@preactarecruitment.com." for (var i = 0; i {amp}lt; keywords.length; i  = 1) { if (data.indexOf(keywords[i])) { console.log(1) } console.log(2) } 
Понравилась статья? Поделиться с друзьями:
JavaScript & TypeScript
Adblock
detector