# [JavaScript (Node.js)], 72 bytes <!-- language-all: lang-javascript --> s=>Buffer(s).map(c=>Math.random()<n/l--/2?(n-=2,c-32):c,n=l=s.length)+'' [Try it online!][TIO-lutm224x] [JavaScript (Node.js)]: https://nodejs.org [TIO-lutm224x]: https://tio.run/##TY/BbsMgEETvfAXKJSAbEru3kE2k3qt@QNUDwWATYYi8OKoU5dtd15Wr7mn2zaxGe9V3jWbwtyxiauzkYEI4vY7O2YEhl72@MQOnN507OejYpJ7xY9wFIXb1mUUBdWnES80PpowQAGWwsc0dL7bbyaQxZgr08VTEpYF52Ct/rPbLKF8U/EEoRXBsoy@msa7tNlzNaDn8wE9YxXkVRXWoFHkSkyKmYGVILVs8Tu464Fz2frlak@W8jRZX7398eaX3kUn5k0Je0l@kv/4Qn74B "JavaScript (Node.js) – Try It Online" Basic idea: To Choose \$n\$ items from \$l\$ candidates, each item have \$\frac{n}{l}\$ probability to be chosen. And once the first item is chosen, we need to choose \$n-1\$ items from remaining \$l-1\$ candidates. If the first item is not chosen, we need to choose \$n\$ items from remaining \$l-1\$ candidates.