Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/binary-reversal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
*
* * @param {string} value
*/
function binaryReversal(value) {}
/*My thought process:
- remove the string by converting the value to integar;
- convert to binary usingthe toString method;
- pad the binary num to 8 bits;
- reverse the binary num;
- convert the binary num to a decimal num, as well convert the num to string;
- then return the decimal num;
*/

function binaryReversal(value) {
let toIntegar = parseInt(value);
let toBinary = toIntegar.toString(2);

let paddedNum = toBinary.padStart(8, 0);
let reversedNum = paddedNum.split("").reverse().join("");

let decimalNum = parseInt(reversedNum, 2).toString();
return decimalNum;
};



module.exports = binaryReversal;
20 changes: 19 additions & 1 deletion src/list-sorting/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
function listSorting(needle, haystack) {}
/*My thought process:
- remove the string by converting the value to integar;
- convert to binary usingthe toString method;
- pad the binary num to 8 bits;
- reverse the binary num;
- convert the binary num to a decimal num, as well convert the num to string;
- then return the decimal num;
*/

function binaryReversal(value) {
let toIntegar = parseInt(value);
let toBinary = toIntegar.toString(2);

let paddedNum = toBinary.padStart(8, 0);
let reversedNum = paddedNum.split("").reverse().join("");

let decimalNum = parseInt(reversedNum, 2).toString();
return decimalNum;
};

module.exports = listSorting;