JavaScript
32.1K subscribers
1.05K photos
10 videos
33 files
726 links
A resourceful newsletter featuring the latest and most important news, articles, books and updates in the world of #javascript 🚀 Don't miss our Quizzes!

Let's chat: @nairihar
Download Telegram
CHALLENGE

const userInput = "<script>alert('xss')</script>";
const sanitized = userInput
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#x27;');

const credentials = {
username: 'admin',
password: 'secret123'
};

const safeLog = (obj) => {
const { password, ...safe } = obj;
return JSON.stringify(safe);
};

console.log(sanitized);
console.log(safeLog(credentials));
3🔥3👍1