Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function building(input) {
- let floor = parseInt(input[0]);
- let volume = parseInt(input[1]);
- for (let f = floor; f > 0; f--){
- let currentFloor = ``;
- for (let v = 0; v < volume; v++){
- if (floor === f){
- currentFloor += `L${f}${v} `;
- } else{
- if (f % 2 === 0) {
- currentFloor += `O${f}${v} `
- } else {
- currentFloor += `A${f}${v} `;
- }
- }
- }
- console.log(currentFloor);
- }
- }
- Решение с тернарен оператор:
- function building(input) {
- let floor = parseInt(input[0]);
- let volume = parseInt(input[1]);
- for (let f = floor; f > 0; f--){
- let currentFloor = ``;
- for (let v = 0; v < volume; v++){
- currentFloor += `${floor === f ? 'L': f % 2 === 0 ? 'O' : 'A'}${f}${v} `;
- }
- console.log(currentFloor);
- }
- }
Add Comment
Please, Sign In to add comment