Skip to content
Open
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
6 changes: 3 additions & 3 deletions code/bit_manipulation/src/xor_swap/xor_swap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Part of Cosmos by OpenGenus Foundation

function xorSwap(a, b) {
function xorSwap(a: number, b: number): void {
console.log(`Before swap: a = ${a}, b = ${b}`);

a = a ^ b; // Step 1: a now contains the XOR of both
Expand All @@ -11,6 +11,6 @@ function xorSwap(a, b) {
}

// Example usage:
let x = 5;
let y = 10;
let x: number = 5;
let y: number = 10;
xorSwap(x, y);